@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
@@ -16,27 +16,17 @@ async function main() {
16
16
  const validThrough = moment(validFrom)
17
17
  .add(1, 'hour')
18
18
  .toDate();
19
- const settingOffer: Omit<chevre.factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer, 'id'> = {
20
- typeOf: chevre.factory.offerType.Offer,
21
- identifier: '20251202acceptedPaymentMethod',
22
- itemOffered: {
23
- id: '7k9ayl8hc',
24
- typeOf: chevre.factory.eventType.ScreeningEventSeries
25
- },
19
+ const settingOffer: Pick<chevre.factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer, 'acceptedPaymentMethod' | 'identifier' | 'validFrom' | 'validThrough'> = {
20
+ identifier: '20260206acceptedPaymentMethod',
26
21
  acceptedPaymentMethod: {
27
22
  id: '5f9a52994f3709000abe6417',
28
23
  typeOf: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
29
24
  },
30
25
  validFrom,
31
- validThrough,
32
- seller: {
33
- id: '59d20831e53ebc2b4e774466',
34
- typeOf: chevre.factory.organizationType.Corporation
35
- },
36
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
26
+ validThrough
37
27
  };
38
28
 
39
- let result = await acceptedPaymentMethodRepo.upsertAcceptedPaymentMethodsByIdentifier(
29
+ let result = await acceptedPaymentMethodRepo.addAcceptedPaymentMethodsByIdentifier(
40
30
  [
41
31
  {
42
32
  $set: settingOffer,
@@ -44,12 +34,21 @@ async function main() {
44
34
  }
45
35
  ],
46
36
  {
47
- update: false
37
+ upsert: false,
38
+ itemOffered: {
39
+ id: '7k9ayl8hc',
40
+ typeOf: chevre.factory.eventType.ScreeningEventSeries
41
+ },
42
+ seller: {
43
+ id: '59d20831e53ebc2b4e774466',
44
+ typeOf: chevre.factory.organizationType.Corporation
45
+ },
46
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
48
47
  }
49
48
  );
50
49
  console.log(result);
51
50
 
52
- result = await acceptedPaymentMethodRepo.upsertAcceptedPaymentMethodsByIdentifier(
51
+ result = await acceptedPaymentMethodRepo.addAcceptedPaymentMethodsByIdentifier(
53
52
  [
54
53
  {
55
54
  $set: settingOffer,
@@ -57,7 +56,16 @@ async function main() {
57
56
  }
58
57
  ],
59
58
  {
60
- update: true
59
+ upsert: true,
60
+ itemOffered: {
61
+ id: '7k9ayl8hc',
62
+ typeOf: chevre.factory.eventType.ScreeningEventSeries
63
+ },
64
+ seller: {
65
+ id: '59d20831e53ebc2b4e774466',
66
+ typeOf: chevre.factory.organizationType.Corporation
67
+ },
68
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
61
69
  }
62
70
  );
63
71
  console.log(result);
@@ -0,0 +1,49 @@
1
+ // tslint:disable:object-literal-key-quotes no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function testGeneration() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const confirmationNumberRepo = await chevre.repository.ConfirmationNumber.createInstance({
10
+ connection: mongoose.connection
11
+ });
12
+
13
+ const ts = new Date(); // 同一ミリ秒固定
14
+ const results: Record<string, string>[] = [];
15
+
16
+ console.log(`--- 同一ミリ秒(${ts})内での連続生成テスト ---`);
17
+
18
+ // tslint:disable-next-line:no-magic-numbers
19
+ for (let i = 0; i < 100; i += 1) {
20
+ // 同一ミリ秒内でシーケンス(00-99)だけが変わる状況を再現
21
+ const confirmationNumber = await confirmationNumberRepo.publish({
22
+ orderDate: ts
23
+
24
+ });
25
+
26
+ // 復号して元のデータに戻るかチェック
27
+ const decoded = await confirmationNumberRepo.decrypt(confirmationNumber);
28
+ const decodedShouldBe = `${i.toString()
29
+ // tslint:disable-next-line:no-magic-numbers
30
+ .padStart(4, '0')}`;
31
+ const isSuccess = decoded === decodedShouldBe;
32
+
33
+ results.push({
34
+ timestamp: ts.valueOf()
35
+ .toString(),
36
+ 'シーケンス': i.toString(),
37
+ '生成された番号': confirmationNumber,
38
+ // tslint:disable-next-line:no-magic-numbers
39
+ 'ソルト': confirmationNumber[0],
40
+ '復号結果': decoded,
41
+ '復号結果(should be)': decodedShouldBe,
42
+ '復号確認': isSuccess ? '✅OK' : '❌NG'
43
+ });
44
+ }
45
+
46
+ console.table(results);
47
+ }
48
+
49
+ testGeneration();
@@ -0,0 +1,63 @@
1
+ // tslint:disable:no-console
2
+ // import * as moment from 'moment';
3
+ import * as fs from 'fs';
4
+ import * as mongoose from 'mongoose';
5
+
6
+ import { createSendOrderMessage } from '../../../../lib/chevre/emailMessageBuilder';
7
+ import { chevre } from '../../../../lib/index';
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+ const emailMessageRepo = await chevre.repository.EmailMessage.createInstance(mongoose.connection);
13
+ const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
14
+
15
+ const order = (await orderRepo.projectFields(
16
+ {
17
+ limit: 1,
18
+ page: 1,
19
+ orderNumbers: ['CA60-9911941-1096810']
20
+ },
21
+ {
22
+ inclusion: ['confirmationNumber', 'customer', 'identifier', 'orderDate', 'orderNumber', 'orderStatus', 'orderedItem', 'paymentMethods', 'price', 'priceCurrency', 'project', 'seller', 'typeOf']
23
+ }
24
+ )).shift();
25
+ if (order === undefined) {
26
+ throw new Error('order not found');
27
+ }
28
+ console.trace(order);
29
+
30
+ // デフォルトEメールメッセージを検索
31
+ let emailMessageOnOrderSent: chevre.factory.creativeWork.message.email.ICreativeWork | undefined;
32
+ const searchEmailMessagesResult = await emailMessageRepo.search({
33
+ limit: 1,
34
+ page: 1,
35
+ project: { id: { $eq: order.project.id } },
36
+ about: { identifier: { $eq: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
37
+ });
38
+ emailMessageOnOrderSent = searchEmailMessagesResult.shift();
39
+ console.trace(emailMessageOnOrderSent);
40
+
41
+ const emailMessage = await createSendOrderMessage(
42
+ {
43
+ order,
44
+ // email: {
45
+ // template: ''
46
+ // },
47
+ // emailMessage?: factory.creativeWork.message.email.ICreativeWork;
48
+ index: 0,
49
+ ...(emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined
50
+ },
51
+ {
52
+ defaultSenderEmail: 'defaultSenderEmail@example.com'
53
+ }
54
+ );
55
+
56
+ console.trace(emailMessage);
57
+ // tslint:disable-next-line:non-literal-fs-path no-null-keyword
58
+ fs.writeFileSync(`${__dirname}/../../../emailMessage.json`, JSON.stringify(emailMessage, null, ' '));
59
+ }
60
+
61
+ main()
62
+ .then()
63
+ .catch(console.error);
@@ -67,7 +67,7 @@ async function main() {
67
67
  }
68
68
  console.log('movieTheater:', movieTheater);
69
69
 
70
- const screeningRooms = await roomRepo.searchScreeningRooms({
70
+ const screeningRooms = await roomRepo.findRooms({
71
71
  project: { id: { $eq: project.id } },
72
72
  containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
73
73
  branchCode: { $eq: roomCode }
@@ -87,7 +87,7 @@ async function main() {
87
87
  [
88
88
  'project', 'typeOf', 'eventStatus', 'identifier',
89
89
  'name', 'kanaName', 'alternativeHeadline', 'location',
90
- 'organizer', 'videoFormat', 'soundFormat', 'workPerformed',
90
+ 'organizer', 'soundFormat', 'workPerformed',
91
91
  'duration', 'endDate', 'startDate', 'coaInfo',
92
92
  'offers', 'additionalProperty'
93
93
  ]
@@ -0,0 +1,30 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // const excludedProject = { id: String(process.env.EXCLUDED_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
+ let updateResult: any;
14
+
15
+ updateResult = await eventRepo.unsetUnnecessaryFields({
16
+ filter: {
17
+ 'superEvent.videoFormat': { $exists: true }
18
+ },
19
+ $unset: {
20
+ 'superEvent.videoFormat': 1
21
+ } as any
22
+ });
23
+ console.log(updateResult);
24
+ }
25
+
26
+ main()
27
+ .then(() => {
28
+ console.log('success!');
29
+ })
30
+ .catch(console.error);
@@ -0,0 +1,31 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
12
+
13
+ let updateResult: any;
14
+
15
+ updateResult = await eventSeriesRepo.unsetUnnecessaryFields({
16
+ filter: {
17
+ // _id: { $eq: 'akewitdke' },
18
+ videoFormat: { $exists: true }
19
+ },
20
+ $unset: {
21
+ videoFormat: 1
22
+ }
23
+ });
24
+ console.log(updateResult);
25
+ }
26
+
27
+ main()
28
+ .then(() => {
29
+ console.log('success!');
30
+ })
31
+ .catch(console.error);
@@ -2,7 +2,7 @@
2
2
  import * as moment from 'moment';
3
3
  import * as mongoose from 'mongoose';
4
4
 
5
- import { chevre } from '../../../lib/index';
5
+ import { chevre } from '../../../../lib/index';
6
6
 
7
7
  const PROJECT_ID = String(process.env.PROJECT_ID);
8
8
 
@@ -17,16 +17,19 @@ async function main() {
17
17
  {
18
18
  $set: {
19
19
  eventStatus: chevre.factory.eventStatusType.EventScheduled,
20
- videoFormat: [],
21
20
  soundFormat: [],
21
+ subEvent: {
22
+ typeOf: chevre.factory.eventType.ScreeningEvent,
23
+ videoFormat: []
24
+ },
22
25
  kanaName: '',
23
26
  startDate: moment('2023-12-08T15:00:00Z')
24
27
  .toDate(),
25
- endDate: moment('2123-12-08T15:00:00Z')
28
+ endDate: moment('2027-12-08T15:00:00Z')
26
29
  .toDate(),
27
30
  typeOf: chevre.factory.eventType.ScreeningEventSeries,
28
31
  duration: 'PT2H',
29
- name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
32
+ name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
30
33
  offers: {
31
34
  typeOf: chevre.factory.offerType.Offer
32
35
  },
@@ -53,46 +56,47 @@ async function main() {
53
56
  headline: { ja: 'xxx', en: '' }
54
57
  },
55
58
  $unset: {}
56
- },
57
- {
58
- $set: {
59
- eventStatus: chevre.factory.eventStatusType.EventScheduled,
60
- videoFormat: [],
61
- soundFormat: [],
62
- kanaName: '',
63
- startDate: moment('2023-12-08T15:00:00Z')
64
- .toDate(),
65
- endDate: moment('2123-12-08T15:00:00Z')
66
- .toDate(),
67
- typeOf: chevre.factory.eventType.ScreeningEventSeries,
68
- duration: 'PT2H',
69
- name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
70
- offers: {
71
- typeOf: chevre.factory.offerType.Offer
72
- },
73
- project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
74
- additionalProperty: [
75
- ],
76
- location: {
77
- branchCode: '118',
78
- id: '5bfb841d5a78d7948369979a',
79
- name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
80
- typeOf: chevre.factory.placeType.MovieTheater
81
- },
82
- workPerformed: {
83
- typeOf: chevre.factory.creativeWorkType.Movie,
84
- id: '5bfb841d5a78d79483699801',
85
- identifier: '071953',
86
- name: {
87
- ja: '男はつらいよ 純情篇'
88
- },
89
- duration: 'PT1H29M',
90
- version: '6'
91
- },
92
- organizer: { id: '59d20831e53ebc2b4e774466' }
93
- }
94
59
  }
95
- ]
60
+ // {
61
+ // $set: {
62
+ // eventStatus: chevre.factory.eventStatusType.EventScheduled,
63
+ // videoFormat: [],
64
+ // soundFormat: [],
65
+ // kanaName: '',
66
+ // startDate: moment('2023-12-08T15:00:00Z')
67
+ // .toDate(),
68
+ // endDate: moment('2123-12-08T15:00:00Z')
69
+ // .toDate(),
70
+ // typeOf: chevre.factory.eventType.ScreeningEventSeries,
71
+ // duration: 'PT2H',
72
+ // name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
73
+ // offers: {
74
+ // typeOf: chevre.factory.offerType.Offer
75
+ // },
76
+ // project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
77
+ // additionalProperty: [
78
+ // ],
79
+ // location: {
80
+ // branchCode: '118',
81
+ // id: '5bfb841d5a78d7948369979a',
82
+ // name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
83
+ // typeOf: chevre.factory.placeType.MovieTheater
84
+ // },
85
+ // workPerformed: {
86
+ // typeOf: chevre.factory.creativeWorkType.Movie,
87
+ // id: '5bfb841d5a78d79483699801',
88
+ // identifier: '071953',
89
+ // name: {
90
+ // ja: '男はつらいよ 純情篇'
91
+ // },
92
+ // duration: 'PT1H29M',
93
+ // version: '6'
94
+ // },
95
+ // organizer: { id: '59d20831e53ebc2b4e774466' }
96
+ // }
97
+ // }
98
+ ],
99
+ { upsert: false }
96
100
  );
97
101
  console.log('result:', result);
98
102
  }
@@ -1,7 +1,7 @@
1
1
  // tslint:disable:no-console
2
2
  import * as mongoose from 'mongoose';
3
3
 
4
- import { chevre } from '../../../lib/index';
4
+ import { chevre } from '../../../../lib/index';
5
5
 
6
6
  const PROJECT_ID = String(process.env.PROJECT_ID);
7
7
 
@@ -35,8 +35,11 @@ async function main() {
35
35
  },
36
36
  $unset: {}
37
37
  }
38
- ]
39
- // { replace: true }
38
+ ],
39
+ {
40
+ update: true,
41
+ productType: chevre.factory.product.ProductType.EventService
42
+ }
40
43
  );
41
44
  console.log('result:', result);
42
45
  }
@@ -1,7 +1,7 @@
1
1
  // tslint:disable:no-console
2
2
  import * as mongoose from 'mongoose';
3
3
 
4
- import { chevre } from '../../../lib/index';
4
+ import { chevre } from '../../../../lib/index';
5
5
 
6
6
  const PROJECT_ID = String(process.env.PROJECT_ID);
7
7
 
@@ -35,8 +35,13 @@ async function main() {
35
35
  },
36
36
  $unset: {}
37
37
  }
38
- ]
39
- // { replace: true }
38
+ ],
39
+ {
40
+ update: false,
41
+ productType: chevre.factory.product.ProductType.EventService,
42
+ itemListElementType: chevre.factory.offerType.Offer
43
+ }
44
+ // { update: false }
40
45
  );
41
46
  console.log('result:', result);
42
47
  }
@@ -1,7 +1,7 @@
1
1
  // tslint:disable:no-console
2
2
  import * as mongoose from 'mongoose';
3
3
 
4
- import { chevre } from '../../../lib/index';
4
+ import { chevre } from '../../../../lib/index';
5
5
 
6
6
  const PROJECT_ID = String(process.env.PROJECT_ID);
7
7
  const PRICE = 1234;
@@ -49,8 +49,10 @@ async function main() {
49
49
  project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
50
50
  typeOf: chevre.factory.offerType.Offer
51
51
  }
52
- ]
53
- // { replace: true }
52
+ ],
53
+ {
54
+ productType: chevre.factory.product.ProductType.EventService
55
+ }
54
56
  );
55
57
  // tslint:disable-next-line:no-null-keyword
56
58
  console.dir(result, { depth: null });
@@ -0,0 +1,54 @@
1
+ // tslint:disable:object-literal-key-quotes no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function testGeneration() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const orderNumberRepo = await chevre.repository.OrderNumber.createInstance({
10
+ connection: mongoose.connection
11
+ });
12
+
13
+ const ts = new Date(); // 同一ミリ秒固定
14
+ const results: Record<string, string>[] = [];
15
+
16
+ console.log(`--- 同一ミリ秒(${ts})内での連続生成テスト ---`);
17
+
18
+ // tslint:disable-next-line:no-magic-numbers
19
+ for (let i = 0; i < 100; i += 1) {
20
+ // 同一ミリ秒内でシーケンス(00-99)だけが変わる状況を再現
21
+ const orderNumber = await orderNumberRepo.publishByTimestamp({
22
+ project: { alternateName: 'CIN' },
23
+ orderDate: ts
24
+
25
+ });
26
+
27
+ // 復号して元のデータに戻るかチェック
28
+ let decoded: string;
29
+ let isSuccess: boolean = false;
30
+ try {
31
+ decoded = await orderNumberRepo.decrypt(orderNumber);
32
+ isSuccess = decoded === `${ts.valueOf()}${(i + 1).toString()
33
+ // tslint:disable-next-line:no-magic-numbers
34
+ .padStart(2, '0')}`;
35
+ } catch (error) {
36
+ decoded = error.message;
37
+ }
38
+
39
+ results.push({
40
+ timestamp: ts.valueOf()
41
+ .toString(),
42
+ 'シーケンス': (i + 1).toString(),
43
+ '生成された番号 (17桁)': orderNumber,
44
+ // tslint:disable-next-line:no-magic-numbers
45
+ 'ソルト(2文字目)': orderNumber[2],
46
+ '復号結果': decoded,
47
+ '復号確認': isSuccess ? '✅OK' : '❌NG'
48
+ });
49
+ }
50
+
51
+ console.table(results);
52
+ }
53
+
54
+ testGeneration();
@@ -0,0 +1,69 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../../lib/index';
6
+
7
+ const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const entranceGateRepo =
13
+ await chevre.repository.place.EntranceGate.createInstance(mongoose.connection, { id: '5bfb841d5a78d7948369979a' });
14
+
15
+ const gates = await entranceGateRepo.findEntranceGates({
16
+ limit: 10,
17
+ page: 1,
18
+ project: { id: { $eq: project.id } }
19
+ // identifier: { $in: ['GATE01', 'GATE03', 'xx'] }
20
+ });
21
+ console.log(gates);
22
+ console.log(gates.length);
23
+
24
+ let result = await entranceGateRepo.addEntranceGatesByIdentifierIfNotExist(
25
+ [
26
+ {
27
+ $set: {
28
+ identifier: 'sample001',
29
+ name: { ja: 'gateNameJa' }
30
+ }
31
+ }
32
+ ],
33
+ {
34
+ project: { id: project.id }
35
+ }
36
+ );
37
+ console.log(result);
38
+
39
+ result = await entranceGateRepo.updateEntranceGatesByIdentifier(
40
+ [
41
+ {
42
+ $set: {
43
+ identifier: 'sample001',
44
+ name: { ja: 'gateNameJaUpdated' }
45
+ }
46
+ }
47
+ ],
48
+ {
49
+ project: { id: project.id }
50
+ }
51
+ );
52
+ console.log(result);
53
+
54
+ result = await entranceGateRepo.deleteEntranceGatesByIdentifier(
55
+ [
56
+ {
57
+ identifier: 'sample001'
58
+ }
59
+ ],
60
+ {
61
+ project: { id: project.id }
62
+ }
63
+ );
64
+ console.log(result);
65
+ }
66
+
67
+ main()
68
+ .then(console.log)
69
+ .catch(console.error);
@@ -0,0 +1,82 @@
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 excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
14
+
15
+ const cursor = movieTheaterRepo.getCursor(
16
+ {
17
+ // 'project.id': {
18
+ // $ne: 'sskts-development',
19
+ // $eq: 'ttts-development'
20
+ // }
21
+ // _id: { $eq: '67de46777ec0510590b68922' }
22
+ },
23
+ {
24
+ // _id: 1,
25
+ // about: 1,
26
+ // project: 1,
27
+ // typeOf: 1,
28
+ // issuedBy: 1
29
+ }
30
+ );
31
+ console.log('docs found');
32
+
33
+ let i = 0;
34
+ let updateCount = 0;
35
+ await cursor.eachAsync(async (doc) => {
36
+ const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
37
+
38
+ i += 1;
39
+ const { hasEntranceGate } = movieTheater;
40
+ if (!Array.isArray(hasEntranceGate)) {
41
+ throw new Error('hasEntranceGateLength must be an array');
42
+ }
43
+ const hasEntranceGateLength = hasEntranceGate?.length;
44
+ if (typeof hasEntranceGateLength !== 'number') {
45
+ throw new Error('hasEntranceGateLength undefined');
46
+ }
47
+ const uniqueIdentifiersByMovieTheater = hasEntranceGate.map(({ identifier }) => identifier);
48
+
49
+ const entranceGateRepo = await chevre.repository.place.EntranceGate.createInstance(mongoose.connection, { id: movieTheater.id });
50
+ const entranceGates = await entranceGateRepo.findEntranceGates({
51
+ limit: 100,
52
+ page: 1,
53
+ project: { id: { $eq: movieTheater.project.id } }
54
+ });
55
+ const entranceGateCount = entranceGates.length;
56
+ const uniqueIdentifiers = entranceGates.map(({ identifier }) => identifier);
57
+
58
+ const countMatched = hasEntranceGateLength === entranceGateCount;
59
+ const identifiersMatched = uniqueIdentifiersByMovieTheater.length === uniqueIdentifiers.length
60
+ && uniqueIdentifiersByMovieTheater.every((identifier) => uniqueIdentifiers.includes(identifier));
61
+ console.log(uniqueIdentifiersByMovieTheater, uniqueIdentifiers);
62
+
63
+ console.log(
64
+ 'checking...', movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
65
+ if (countMatched && identifiersMatched) {
66
+ console.log(
67
+ 'matched.', movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
68
+ } else {
69
+ updateCount += 1;
70
+ console.log(
71
+ 'unmatched.',
72
+ movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
73
+ }
74
+ });
75
+
76
+ console.log(i, 'docs checked');
77
+ console.log(updateCount, 'docs updated');
78
+ }
79
+
80
+ main()
81
+ .then()
82
+ .catch(console.error);