@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.61

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 (173) hide show
  1. package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +25 -17
  2. package/example/src/chevre/confirmationNumber/testRandomness.ts +49 -0
  3. package/example/src/chevre/emailMessage/createEmailMessageText.ts +63 -0
  4. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +2 -2
  5. package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +30 -0
  6. package/example/src/chevre/eventSeries/unsetVideoFormat.ts +31 -0
  7. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -43
  8. package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
  9. package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +8 -3
  10. package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
  11. package/example/src/chevre/orderNumber/testRandomness.ts +54 -0
  12. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  13. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  14. package/example/src/chevre/place/findRooms.ts +24 -0
  15. package/example/src/chevre/place/findSections.ts +28 -0
  16. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  17. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  18. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  19. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  20. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  21. package/example/src/chevre/reIndex.ts +1 -1
  22. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
  23. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
  24. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  25. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  26. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  27. package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
  28. package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
  29. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
  30. package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
  31. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  32. package/lib/chevre/emailMessageBuilder.js +1 -0
  33. package/lib/chevre/factory/event.d.ts +1 -1
  34. package/lib/chevre/factory/event.js +11 -5
  35. package/lib/chevre/factory/transactionNumber.d.ts +19 -0
  36. package/lib/chevre/factory/transactionNumber.js +54 -0
  37. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
  38. package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
  39. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  40. package/lib/chevre/repo/aggregateOffer.js +11 -3
  41. package/lib/chevre/repo/aggregateOrder.js +0 -93
  42. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  43. package/lib/chevre/repo/aggregateReservation.js +0 -2
  44. package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
  45. package/lib/chevre/repo/confirmationNumber.js +32 -25
  46. package/lib/chevre/repo/event.d.ts +3 -18
  47. package/lib/chevre/repo/event.js +94 -83
  48. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  49. package/lib/chevre/repo/eventOffer.js +11 -0
  50. package/lib/chevre/repo/eventSeries.d.ts +17 -30
  51. package/lib/chevre/repo/eventSeries.js +204 -146
  52. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  53. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +20 -5
  54. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
  55. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
  56. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  57. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
  58. package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
  59. package/lib/chevre/repo/offerCatalog.d.ts +14 -1
  60. package/lib/chevre/repo/offerCatalog.js +41 -19
  61. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  62. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  63. package/lib/chevre/repo/orderNumber.d.ts +6 -0
  64. package/lib/chevre/repo/orderNumber.js +110 -35
  65. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  66. package/lib/chevre/repo/place/entranceGate.js +172 -0
  67. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  68. package/lib/chevre/repo/place/movieTheater.js +77 -6
  69. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  70. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  71. package/lib/chevre/repo/place/seat.d.ts +47 -45
  72. package/lib/chevre/repo/place/seat.js +175 -45
  73. package/lib/chevre/repo/place/section.d.ts +60 -30
  74. package/lib/chevre/repo/place/section.js +337 -127
  75. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
  76. package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
  77. package/lib/chevre/repo/setting.d.ts +1 -1
  78. package/lib/chevre/repo/setting.js +2 -2
  79. package/lib/chevre/repo/task.d.ts +1 -1
  80. package/lib/chevre/repo/transactionNumber.d.ts +5 -0
  81. package/lib/chevre/repo/transactionNumber.js +63 -27
  82. package/lib/chevre/repository.d.ts +8 -0
  83. package/lib/chevre/repository.js +16 -0
  84. package/lib/chevre/service/assetTransaction/fixInformAction.d.ts +3 -0
  85. package/lib/chevre/service/assetTransaction/fixInformAction.js +3 -0
  86. package/lib/chevre/service/assetTransaction/pay/cancel.d.ts +12 -0
  87. package/lib/chevre/service/assetTransaction/pay/cancel.js +25 -0
  88. package/lib/chevre/service/assetTransaction/pay/check.d.ts +23 -0
  89. package/lib/chevre/service/assetTransaction/pay/check.js +37 -0
  90. package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +24 -0
  91. package/lib/chevre/service/assetTransaction/pay/confirm.js +72 -0
  92. package/lib/chevre/service/assetTransaction/pay/exportTasksById.d.ts +18 -0
  93. package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +111 -0
  94. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +48 -0
  95. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +164 -0
  96. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +20 -0
  97. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +59 -0
  98. package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.d.ts +2 -2
  99. package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.js +1 -1
  100. package/lib/chevre/service/assetTransaction/pay/{factory.d.ts → start/factory.d.ts} +1 -1
  101. package/lib/chevre/service/assetTransaction/pay/{factory.js → start/factory.js} +1 -1
  102. package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.d.ts → start/preStart/validateAcceptedPaymentMethodIfNeeded.d.ts} +4 -4
  103. package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.js → start/preStart/validateAcceptedPaymentMethodIfNeeded.js} +1 -4
  104. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +8 -0
  105. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +54 -0
  106. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.d.ts +13 -0
  107. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +49 -0
  108. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +29 -0
  109. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +37 -0
  110. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +42 -0
  111. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +31 -0
  112. package/lib/chevre/service/assetTransaction/pay/start.d.ts +60 -0
  113. package/lib/chevre/service/assetTransaction/pay/start.js +145 -0
  114. package/lib/chevre/service/assetTransaction/pay.d.ts +8 -170
  115. package/lib/chevre/service/assetTransaction/pay.js +16 -623
  116. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
  117. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  118. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  119. package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
  120. package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
  121. package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
  122. package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
  123. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  124. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  125. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  126. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
  127. package/lib/chevre/service/offer/onEventChanged.js +10 -6
  128. package/lib/chevre/service/offer/product.js +1 -1
  129. package/lib/chevre/service/offer.d.ts +5 -0
  130. package/lib/chevre/service/offer.js +34 -9
  131. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  132. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  133. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  134. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
  135. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
  136. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
  137. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
  138. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
  139. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
  140. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
  141. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
  142. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
  143. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
  144. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
  145. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
  146. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
  148. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  149. package/lib/chevre/service/task/onResourceDeleted.js +168 -0
  150. package/lib/chevre/service/task/onResourceUpdated.js +205 -42
  151. package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
  152. package/lib/chevre/service/taskHandler.js +1 -0
  153. package/package.json +9 -9
  154. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  155. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
  156. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  157. package/example/src/chevre/settings/addSettings.ts +0 -46
  158. package/lib/chevre/service/eventOld.d.ts +0 -60
  159. package/lib/chevre/service/eventOld.js +0 -864
  160. package/lib/chevre/service/task/createEvent/createEvent.d.ts +0 -25
  161. package/lib/chevre/service/task/createEvent/createEvent.js +0 -45
  162. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +0 -22
  163. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +0 -188
  164. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +0 -15
  165. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +0 -116
  166. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +0 -25
  167. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +0 -107
  168. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +0 -13
  169. package/lib/chevre/service/task/createEvent/createEventSeries.js +0 -118
  170. package/lib/chevre/service/task/createEvent.d.ts +0 -6
  171. package/lib/chevre/service/task/createEvent.js +0 -46
  172. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
  173. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
@@ -1,191 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import * as moment from 'moment-timezone';
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 ADDITIONAL_PROPERTY_NAME = 'sampleCreateId';
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
15
-
16
- const today = moment()
17
- .tz('Asia/Tokyo')
18
- .format('YYYY-MM-DD');
19
- const identifier = `fromSamples:${moment()
20
- .format('YYYY-MM-DD HH:mm')}`;
21
- const settingEvent: chevre.factory.event.screeningEvent.IAttributes = {
22
- identifier,
23
- additionalProperty: [
24
- { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
25
- ],
26
- project: {
27
- id: project.id,
28
- typeOf: chevre.factory.organizationType.Project
29
- },
30
- organizer: {
31
- id: '59d20831e53ebc2b4e774466'
32
- },
33
- typeOf: chevre.factory.eventType.ScreeningEvent,
34
- name: {
35
- en: 'pet IMAX2D',
36
- ja: 'ペット IMAX2D'
37
- },
38
- doorTime: moment(`${today}T13:00:00Z`)
39
- .toDate(),
40
- startDate: moment(`${today}T13:00:00Z`)
41
- .toDate(),
42
- endDate: moment(`${today}T14:00:00Z`)
43
- .toDate(),
44
- eventStatus: chevre.factory.eventStatusType.EventScheduled,
45
- location: {
46
- typeOf: chevre.factory.placeType.ScreeningRoom,
47
- branchCode: '70',
48
- name: {
49
- ja: 'シネマ7',
50
- en: 'CINEMA7'
51
- },
52
- address: {
53
- ja: '',
54
- en: ''
55
- }
56
- },
57
- superEvent: {
58
- typeOf: chevre.factory.eventType.ScreeningEventSeries,
59
- id: 'al9s38bj6',
60
- videoFormat: [
61
- {
62
- typeOf: '2D',
63
- name: '2D'
64
- },
65
- {
66
- typeOf: 'IMAX',
67
- name: 'IMAX'
68
- }
69
- ],
70
- soundFormat: [],
71
- workPerformed: {
72
- typeOf: chevre.factory.creativeWorkType.Movie,
73
- identifier: '1622100',
74
- id: '5bfb841d5a78d7948369980a',
75
- name: {
76
- en: 'Pet',
77
- ja: 'ペット'
78
- },
79
- duration: 'PT2H3M'
80
- },
81
- location: {
82
- typeOf: chevre.factory.placeType.MovieTheater,
83
- id: '5bfb841d5a78d7948369979a',
84
- branchCode: '118',
85
- name: {
86
- ja: 'シネモーション赤坂 ',
87
- en: 'CineMotion Akasaka'
88
- }
89
- },
90
- kanaName: 'ペット IMAX2D',
91
- name: {
92
- en: 'pet IMAX2D',
93
- ja: 'ペット IMAX2D'
94
- },
95
- additionalProperty: [],
96
- startDate: moment('2022-09-30T15:00:00.000Z')
97
- .toDate(),
98
- endDate: moment('2029-07-31T15:00:00.000Z')
99
- .toDate(),
100
- headline: {
101
- ja: 'IMAX2D上映'
102
- }
103
- },
104
- offers: {
105
- typeOf: chevre.factory.offerType.Offer,
106
- eligibleQuantity: {
107
- typeOf: 'QuantitativeValue',
108
- unitCode: chevre.factory.unitCode.C62,
109
- maxValue: 6
110
- },
111
- itemOffered: {
112
- id: '655dc6b02cbb99d946cb6081',
113
- name: {
114
- ja: '通常興行カタログ(サブカタログ版)'
115
- },
116
- serviceOutput: {
117
- typeOf: chevre.factory.reservationType.EventReservation,
118
- reservedTicket: {
119
- typeOf: 'Ticket',
120
- ticketedSeat: {
121
- typeOf: chevre.factory.placeType.Seat
122
- }
123
- }
124
- },
125
- typeOf: chevre.factory.product.ProductType.EventService,
126
- availableChannel: {
127
- typeOf: 'ServiceChannel',
128
- serviceLocation: {
129
- typeOf: chevre.factory.placeType.ScreeningRoom,
130
- branchCode: '70',
131
- name: {
132
- ja: 'シネマ7',
133
- en: 'CINEMA7'
134
- },
135
- containedInPlace: {
136
- typeOf: chevre.factory.placeType.MovieTheater,
137
- id: '5bfb841d5a78d7948369979a',
138
- branchCode: '118',
139
- name: {
140
- ja: 'シネモーション赤坂 ',
141
- en: 'CineMotion Akasaka'
142
- }
143
- }
144
- }
145
- }
146
- },
147
- seller: {
148
- typeOf: chevre.factory.organizationType.Corporation,
149
- id: '59d20831e53ebc2b4e774466',
150
- name: {
151
- ja: 'シネモーション赤坂',
152
- en: 'CineMotion Akasaka'
153
- },
154
- makesOffer: [
155
- ]
156
- }
157
- }
158
- };
159
-
160
- const createResult = await eventRepo.upsertManyScreeningEventByIdentifier(
161
- [
162
- {
163
- $set: settingEvent,
164
- $unset: {}
165
- }
166
- ],
167
- { update: false }
168
- );
169
- // tslint:disable-next-line:no-null-keyword
170
- console.dir(createResult, { depth: null });
171
-
172
- const updateResult = await eventRepo.upsertManyScreeningEventByIdentifier(
173
- [
174
- {
175
- $set: {
176
- ...settingEvent,
177
- eventStatus: chevre.factory.eventStatusType.EventCancelled
178
- },
179
- $unset: {}
180
- }
181
- ],
182
- { update: true }
183
- );
184
- // tslint:disable-next-line:no-null-keyword
185
- console.dir(updateResult, { depth: null });
186
-
187
- }
188
-
189
- main()
190
- .then()
191
- .catch(console.error);
@@ -1,93 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
- const DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET = 'MovieTicket';
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
15
-
16
- const cursor = eventSeriesRepo.getCursor(
17
- {
18
- 'project.id': { $eq: 'xxx' },
19
- 'offers.unacceptedPaymentMethod': {
20
- $exists: true,
21
- $ne: DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
22
- },
23
- startDate: {
24
- $lte: moment()
25
- .add(-1, 'year')
26
- .toDate()
27
- }
28
- // _id: { $eq: 'bliy11ffa' }
29
- },
30
- {
31
- // _id: 1,
32
- // offers: 1,
33
- // startDate: 1,
34
- // project: 1,
35
- // typeOf: 1
36
- }
37
- );
38
- console.log('docs found');
39
-
40
- let i = 0;
41
- let updateCount = 0;
42
- await cursor.eachAsync(async (doc) => {
43
- i += 1;
44
- const eventSeries: Pick<
45
- chevre.factory.eventSeries.IEvent,
46
- 'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
47
- > = doc.toObject();
48
-
49
- console.log(
50
- 'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
51
- const unacceptedPaymentMethod = eventSeries.offers?.unacceptedPaymentMethod;
52
- const alreadyMigrated = !Array.isArray(unacceptedPaymentMethod)
53
- || (Array.isArray(unacceptedPaymentMethod)
54
- && unacceptedPaymentMethod.every(
55
- (paymentMethodType) => paymentMethodType === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
56
- ));
57
-
58
- if (alreadyMigrated) {
59
- console.log(
60
- 'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
61
- } else {
62
- if (Array.isArray(unacceptedPaymentMethod)) {
63
- const newUnacceptedPaymentMethod = unacceptedPaymentMethod.filter(
64
- (paymentMethod) => paymentMethod === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
65
- );
66
- console.log(
67
- 'updating project...',
68
- newUnacceptedPaymentMethod,
69
- eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
70
- await eventSeriesRepo.saveEventSeries({
71
- id: eventSeries.id,
72
- attributes: <any>{
73
- ...{
74
- typeOf: eventSeries.typeOf,
75
- 'offers.unacceptedPaymentMethod': newUnacceptedPaymentMethod
76
- }
77
- }
78
- });
79
- updateCount += 1;
80
- console.log(
81
- 'updated.',
82
- eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
83
- }
84
- }
85
- });
86
-
87
- console.log(i, 'docs checked');
88
- console.log(updateCount, 'docs updated');
89
- }
90
-
91
- main()
92
- .then()
93
- .catch(console.error);
@@ -1,154 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
- const NUM_CREATE_OFFERS = 300;
8
- const NUM_CREATE_SUB_CATALOGS = 10;
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
15
- const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
16
- const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
17
- const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
18
-
19
- const savingOffers: Omit<chevre.factory.unitPriceOffer.IUnitPriceOffer, 'id'>[] =
20
- // tslint:disable-next-line:prefer-array-literal
21
- [...Array(NUM_CREATE_OFFERS)].map<Omit<chevre.factory.unitPriceOffer.IUnitPriceOffer, 'id'>>((__, i) => {
22
- const identifier = `sampleFreeOffer${i}`;
23
- const priceSpecification: chevre.factory.unitPriceOffer.IUnitPriceOfferPriceSpecification = {
24
- typeOf: chevre.factory.priceSpecificationType.UnitPriceSpecification,
25
- priceCurrency: chevre.factory.priceCurrency.JPY,
26
- valueAddedTaxIncluded: true,
27
- price: 0,
28
- referenceQuantity: {
29
- value: 1,
30
- typeOf: 'QuantitativeValue',
31
- unitCode: chevre.factory.unitCode.C62
32
- },
33
- accounting: {
34
- typeOf: 'Accounting',
35
- accountsReceivable: 0
36
- }
37
- };
38
-
39
- return {
40
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
41
- typeOf: chevre.factory.offerType.Offer,
42
- identifier,
43
- description: { en: identifier, ja: identifier },
44
- alternateName: { ja: identifier },
45
- name: { en: identifier, ja: identifier },
46
- availability: chevre.factory.itemAvailability.InStock,
47
- availableAtOrFrom: [
48
- { id: '51qbjcfr72h62m06vtv5kkhgje' }
49
- ],
50
- itemOffered: { typeOf: chevre.factory.product.ProductType.EventService },
51
- priceCurrency: chevre.factory.priceCurrency.JPY,
52
- priceSpecification
53
- };
54
- });
55
- const saveOfferResult = await aggregateOfferRepo.upsertByIdentifier(savingOffers);
56
- console.log('saveOfferResult:', saveOfferResult);
57
-
58
- const offerIds: string[] = (Array.isArray(saveOfferResult?.modifiedOffers)) ? saveOfferResult.modifiedOffers.map(({ id }) => id) : [];
59
- const catalogIdentifier = 'sampleFreeOffersCatalog';
60
- const savingOfferCatalog: chevre.factory.offerCatalog.IOfferCatalog = {
61
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
62
- typeOf: 'OfferCatalog',
63
- identifier: catalogIdentifier,
64
- description: { en: catalogIdentifier, ja: catalogIdentifier },
65
- name: { en: catalogIdentifier, ja: catalogIdentifier },
66
- itemListElement: offerIds.map((id) => ({ id, typeOf: chevre.factory.offerType.Offer })),
67
- itemOffered: { typeOf: chevre.factory.product.ProductType.EventService }
68
- };
69
- const saveCatalogResult = await offerCatalogRepo.saveByIdentifier(savingOfferCatalog);
70
- console.log('saveCatalogResult:', saveCatalogResult);
71
-
72
- const productId = 'sampleFreeEventService';
73
- const savingProduct: chevre.factory.product.IProduct & {
74
- offers?: never;
75
- } = {
76
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
77
- typeOf: chevre.factory.product.ProductType.EventService,
78
- name: { en: productId, ja: productId },
79
- productID: productId,
80
- hasOfferCatalog: {
81
- typeOf: 'OfferCatalog',
82
- itemListElement: [{ id: saveCatalogResult.id }]
83
- }
84
- };
85
- const saveProductResult = await productRepo.upsertManyByProductId([{
86
- $set: savingProduct
87
- }]);
88
- console.log('saveProductResult:', saveProductResult);
89
-
90
- // 以下サブカタログ
91
- const offerIds4subCatalog: string[] = (Array.isArray(saveOfferResult?.modifiedOffers))
92
- // tslint:disable-next-line:no-magic-numbers
93
- ? saveOfferResult.modifiedOffers.slice(0, 100)
94
- .map(({ id }) => id) :
95
- [];
96
- const savingSubOfferCatalogs: chevre.factory.offerCatalog.IOfferCatalog[] =
97
- // tslint:disable-next-line:prefer-array-literal
98
- [...Array(NUM_CREATE_SUB_CATALOGS)].map<chevre.factory.offerCatalog.IOfferCatalog>((__, i) => {
99
- const subCatalogIdentifier = `sampleFreeOffersSubCatalog${i}`;
100
-
101
- return {
102
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
103
- typeOf: 'OfferCatalog',
104
- identifier: subCatalogIdentifier,
105
- description: { en: subCatalogIdentifier, ja: subCatalogIdentifier },
106
- name: { en: subCatalogIdentifier, ja: subCatalogIdentifier },
107
- itemListElement: offerIds4subCatalog.map((id) => ({ id, typeOf: chevre.factory.offerType.Offer })),
108
- itemOffered: { typeOf: chevre.factory.product.ProductType.EventService }
109
- };
110
- });
111
- const saveSubCatalogResult = await offerCatalogItemRepo.upsertManyByIdentifier(savingSubOfferCatalogs.map((savingSubOfferCatalog) => {
112
- return {
113
- $set: savingSubOfferCatalog
114
- };
115
- }));
116
- console.log('saveSubCatalogResult:', saveSubCatalogResult);
117
-
118
- const subCatalogIds: string[] =
119
- (Array.isArray(saveSubCatalogResult?.modifiedCatalogs)) ? saveSubCatalogResult.modifiedCatalogs.map(({ id }) => id) : [];
120
- const catalogBySubCatalogIdentifier = 'sampleFreeOffersCatalogBySub';
121
- const savingOfferCatalogBySubCatalog: chevre.factory.offerCatalog.IOfferCatalog = {
122
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
123
- typeOf: 'OfferCatalog',
124
- identifier: catalogBySubCatalogIdentifier,
125
- description: { en: catalogBySubCatalogIdentifier, ja: catalogBySubCatalogIdentifier },
126
- name: { en: catalogBySubCatalogIdentifier, ja: catalogBySubCatalogIdentifier },
127
- itemListElement: subCatalogIds.map((id) => ({ id, typeOf: 'OfferCatalog' })),
128
- itemOffered: { typeOf: chevre.factory.product.ProductType.EventService }
129
- };
130
- const saveCatalogBySubResult = await offerCatalogRepo.saveByIdentifier(savingOfferCatalogBySubCatalog);
131
- console.log('saveCatalogBySubResult:', saveCatalogBySubResult);
132
-
133
- const productIdBySubCatalog = 'sampleFreeEventServiceBySub';
134
- const savingProductBySubCatalog: chevre.factory.product.IProduct & {
135
- offers?: never;
136
- } = {
137
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
138
- typeOf: chevre.factory.product.ProductType.EventService,
139
- name: { en: productIdBySubCatalog, ja: productIdBySubCatalog },
140
- productID: productIdBySubCatalog,
141
- hasOfferCatalog: {
142
- typeOf: 'OfferCatalog',
143
- itemListElement: [{ id: saveCatalogBySubResult.id }]
144
- }
145
- };
146
- const saveProductBySubCatalogResult = await productRepo.upsertManyByProductId([{
147
- $set: savingProductBySubCatalog
148
- }]);
149
- console.log('saveProductBySubCatalogResult:', saveProductBySubCatalogResult);
150
- }
151
-
152
- main()
153
- .then()
154
- .catch(console.error);
@@ -1,46 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- const { INFORM_TASK_AGG_URL } = process.env;
7
- if (typeof INFORM_TASK_AGG_URL !== 'string') {
8
- throw new Error('INFORM_TASK_AGG_URL required');
9
- }
10
-
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
15
- // const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['onTaskStatusChanged']);
16
- // update
17
- await settingRepo.updateByProject(
18
- { project: { id: { $eq: '*' } } },
19
- {
20
- onTaskStatusChanged: {
21
- informTask: [{
22
- recipient: {
23
- name: 'Aggregation Service',
24
- url: INFORM_TASK_AGG_URL
25
- }
26
- }],
27
- informTaskNames: [
28
- chevre.factory.taskName.Pay,
29
- chevre.factory.taskName.InvalidatePaymentUrl,
30
- chevre.factory.taskName.Refund,
31
- chevre.factory.taskName.VoidPayment
32
- // chevre.factory.taskName.ConfirmReserveTransaction
33
- ],
34
- informTaskStatuses: [
35
- chevre.factory.taskStatus.Aborted
36
- // chevre.factory.taskStatus.Running
37
- ]
38
- }
39
- }
40
- );
41
- console.log('updated.');
42
- }
43
-
44
- main()
45
- .then()
46
- .catch(console.error);
@@ -1,60 +0,0 @@
1
- /**
2
- * マスターデータ同期サービス
3
- */
4
- import type * as COA from '@motionpicture/coa-service';
5
- import type { ActionRepo } from '../repo/action';
6
- import type { CategoryCodeRepo } from '../repo/categoryCode';
7
- import type { CreativeWorkRepo } from '../repo/creativeWork';
8
- import type { EventRepo } from '../repo/event';
9
- import type { EventSeriesRepo } from '../repo/eventSeries';
10
- import type { MovieTheaterRepo } from '../repo/place/movieTheater';
11
- import type { ScreeningRoomRepo } from '../repo/place/screeningRoom';
12
- import type { SellerRepo } from '../repo/seller';
13
- import * as factory from '../factory';
14
- interface IImportFromCOAParams {
15
- project: {
16
- id: string;
17
- typeOf: factory.organizationType.Project;
18
- };
19
- /**
20
- * 施設コード
21
- */
22
- locationBranchCode: string;
23
- importFrom: Date;
24
- importThrough: Date;
25
- /**
26
- * 施設を保管するかどうか
27
- */
28
- saveMovieTheater: boolean;
29
- /**
30
- * 施設コンテンツを保管するかどうか
31
- */
32
- saveScreeningEventSeries: boolean;
33
- saveScreeningEventSeriesPeriodInMonth: number;
34
- }
35
- /**
36
- * イベントをインポートする
37
- */
38
- declare function importFromCOA(params: IImportFromCOAParams): (repos: {
39
- action: ActionRepo;
40
- categoryCode: CategoryCodeRepo;
41
- creativeWork: CreativeWorkRepo;
42
- event: EventRepo;
43
- eventSeries: EventSeriesRepo;
44
- movieTheater: MovieTheaterRepo;
45
- screeningRoom: ScreeningRoomRepo;
46
- seller: SellerRepo;
47
- masterService: COA.service.Master;
48
- }) => Promise<void>;
49
- /**
50
- * COA情報からイベントIDを作成する
51
- */
52
- declare function createScreeningEventIdFromCOA(params: {
53
- theaterCode: string;
54
- titleCode: string;
55
- titleBranchNum: string;
56
- dateJouei: string;
57
- screenCode: string;
58
- timeBegin: string;
59
- }): string;
60
- export { importFromCOA, createScreeningEventIdFromCOA };