@chevre/domain 23.2.0-alpha.5 → 23.2.0-alpha.51

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 (116) hide show
  1. package/example/src/chevre/confirmationNumber/testRandomness.ts +49 -0
  2. package/example/src/chevre/emailMessage/createEmailMessageText.ts +63 -0
  3. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  4. package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +30 -0
  5. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  6. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
  7. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -42
  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/decryptOrderNumber.ts +14 -0
  12. package/example/src/chevre/orderNumber/testRandomness.ts +54 -0
  13. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  14. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  15. package/example/src/chevre/place/findRooms.ts +24 -0
  16. package/example/src/chevre/place/findSections.ts +28 -0
  17. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  18. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  19. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  20. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  21. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  22. package/example/src/chevre/reIndex.ts +1 -1
  23. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  24. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
  25. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
  26. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  27. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  28. package/example/src/chevre/settings/addOrderNumberSetting.ts +40 -0
  29. package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
  30. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
  31. package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
  32. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  33. package/lib/chevre/emailMessageBuilder.d.ts +3 -0
  34. package/lib/chevre/emailMessageBuilder.js +15 -4
  35. package/lib/chevre/factory/event.js +7 -4
  36. package/lib/chevre/factory/transactionNumber.d.ts +19 -0
  37. package/lib/chevre/factory/transactionNumber.js +54 -0
  38. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  39. package/lib/chevre/repo/aggregateOffer.js +11 -3
  40. package/lib/chevre/repo/aggregateOrder.js +0 -93
  41. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  42. package/lib/chevre/repo/aggregateReservation.js +0 -2
  43. package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
  44. package/lib/chevre/repo/confirmationNumber.js +32 -25
  45. package/lib/chevre/repo/creativeWork.js +8 -4
  46. package/lib/chevre/repo/event.d.ts +2 -2
  47. package/lib/chevre/repo/event.js +20 -8
  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 +10 -4
  51. package/lib/chevre/repo/eventSeries.js +56 -28
  52. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  53. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
  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 +35 -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 +4 -0
  64. package/lib/chevre/repo/orderNumber.js +99 -17
  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 +62 -24
  82. package/lib/chevre/repository.d.ts +8 -0
  83. package/lib/chevre/repository.js +16 -0
  84. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +9 -3
  85. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  86. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  87. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  88. package/lib/chevre/service/event/saveScreeningEvents.js +10 -14
  89. package/lib/chevre/service/offer/event/authorize/factory.js +7 -1
  90. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  91. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  92. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  93. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -13
  94. package/lib/chevre/service/offer/onEventChanged.js +7 -5
  95. package/lib/chevre/service/offer/product.js +1 -1
  96. package/lib/chevre/service/offer.d.ts +5 -0
  97. package/lib/chevre/service/offer.js +34 -9
  98. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  99. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  101. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  102. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  103. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  104. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  105. package/lib/chevre/service/task/onResourceDeleted.js +60 -0
  106. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -7
  107. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +19 -7
  108. package/lib/chevre/service/task/onResourceUpdated.js +206 -42
  109. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  110. package/lib/chevre/service/taskHandler.js +1 -0
  111. package/package.json +11 -8
  112. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  113. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  114. package/example/src/chevre/settings/addSettings.ts +0 -46
  115. package/lib/chevre/service/eventOld.d.ts +0 -60
  116. package/lib/chevre/service/eventOld.js +0 -864
@@ -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 }
@@ -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,75 @@
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 eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
12
+
13
+ const cursor = eventSeriesRepo.getCursor(
14
+ {
15
+ // _id: { $eq: 'bmd7x21f2' },
16
+ // 'project.id': { $eq: 'xxx' },
17
+ 'offers.typeOf': {
18
+ $exists: true,
19
+ $eq: chevre.factory.offerType.AggregateOffer
20
+ }
21
+ },
22
+ {
23
+ // _id: 1,
24
+ // offers: 1,
25
+ // startDate: 1,
26
+ // project: 1,
27
+ // typeOf: 1
28
+ }
29
+ );
30
+ console.log('docs found');
31
+
32
+ let i = 0;
33
+ let updateCount = 0;
34
+ await cursor.eachAsync(async (doc) => {
35
+ i += 1;
36
+ const eventSeries: Pick<
37
+ chevre.factory.eventSeries.IEvent,
38
+ 'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
39
+ > = doc.toObject();
40
+
41
+ console.log(
42
+ 'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
43
+ const alreadyMigrated = eventSeries.offers?.typeOf === chevre.factory.offerType.Offer;
44
+
45
+ if (alreadyMigrated) {
46
+ console.log(
47
+ 'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
48
+ } else {
49
+ console.log(
50
+ 'updating...',
51
+ eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
52
+ await eventSeriesRepo.saveEventSeries({
53
+ id: eventSeries.id,
54
+ attributes: <any>{
55
+ ...{
56
+ typeOf: eventSeries.typeOf,
57
+ 'offers.typeOf': chevre.factory.offerType.Offer
58
+ }
59
+ }
60
+ });
61
+ updateCount += 1;
62
+ console.log(
63
+ 'updated.',
64
+ eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
65
+
66
+ }
67
+ });
68
+
69
+ console.log(i, 'docs checked');
70
+ console.log(updateCount, 'docs updated');
71
+ }
72
+
73
+ main()
74
+ .then()
75
+ .catch(console.error);
@@ -0,0 +1,80 @@
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 eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
12
+
13
+ const cursor = eventSeriesRepo.getCursor(
14
+ {
15
+ // _id: { $eq: 'al9s38bj6' },
16
+ 'project.id': { $nin: ['sskts-development', 'sskts-test', 'sskts-production'] }
17
+ },
18
+ {
19
+ // _id: 1,
20
+ // offers: 1,
21
+ // startDate: 1,
22
+ // project: 1,
23
+ // typeOf: 1
24
+ }
25
+ );
26
+ console.log('docs found');
27
+
28
+ let i = 0;
29
+ let updateCount = 0;
30
+ await cursor.eachAsync(async (doc) => {
31
+ i += 1;
32
+ const eventSeries: Pick<
33
+ chevre.factory.eventSeries.IEvent,
34
+ 'id' | 'videoFormat' | 'subEvent' | 'project' | 'startDate' | 'typeOf'
35
+ > = doc.toObject();
36
+
37
+ const videoFormatByOldAttribute: string[] =
38
+ (Array.isArray(eventSeries.videoFormat)) ? eventSeries.videoFormat.map(({ typeOf }) => typeOf) : [];
39
+ const videoFormatByNewAttribute: string[] =
40
+ (Array.isArray(eventSeries.subEvent?.videoFormat)) ? eventSeries.subEvent.videoFormat : [];
41
+ const alreadyMigrated = videoFormatByOldAttribute.length === videoFormatByNewAttribute.length
42
+ && videoFormatByOldAttribute.every((codeValue) => videoFormatByNewAttribute.includes(codeValue))
43
+ && eventSeries.subEvent?.typeOf === chevre.factory.eventType.ScreeningEvent;
44
+
45
+ if (alreadyMigrated) {
46
+ console.log(
47
+ 'already migrated.', eventSeries.project.id, eventSeries.id, eventSeries.startDate, i);
48
+ } else {
49
+ const subEvent: chevre.factory.eventSeries.ISubEvent = {
50
+ typeOf: chevre.factory.eventType.ScreeningEvent,
51
+ ...(videoFormatByOldAttribute.length > 0) ? { videoFormat: videoFormatByOldAttribute } : undefined
52
+ };
53
+ console.log(
54
+ 'updating...',
55
+ eventSeries.project.id, eventSeries.id, eventSeries.startDate, i, videoFormatByOldAttribute, subEvent
56
+ );
57
+ await eventSeriesRepo.saveEventSeries({
58
+ id: eventSeries.id,
59
+ attributes: <any>{
60
+ ...{
61
+ typeOf: eventSeries.typeOf,
62
+ subEvent
63
+ }
64
+ }
65
+ });
66
+ updateCount += 1;
67
+ console.log(
68
+ 'updated.',
69
+ eventSeries.project.id, eventSeries.id, eventSeries.startDate, i);
70
+
71
+ }
72
+ });
73
+
74
+ console.log(i, 'docs checked');
75
+ console.log(updateCount, 'docs updated');
76
+ }
77
+
78
+ main()
79
+ .then()
80
+ .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
 
@@ -19,14 +19,18 @@ async function main() {
19
19
  eventStatus: chevre.factory.eventStatusType.EventScheduled,
20
20
  videoFormat: [],
21
21
  soundFormat: [],
22
+ subEvent: {
23
+ typeOf: chevre.factory.eventType.ScreeningEvent,
24
+ videoFormat: []
25
+ },
22
26
  kanaName: '',
23
27
  startDate: moment('2023-12-08T15:00:00Z')
24
28
  .toDate(),
25
- endDate: moment('2123-12-08T15:00:00Z')
29
+ endDate: moment('2027-12-08T15:00:00Z')
26
30
  .toDate(),
27
31
  typeOf: chevre.factory.eventType.ScreeningEventSeries,
28
32
  duration: 'PT2H',
29
- name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
33
+ name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
30
34
  offers: {
31
35
  typeOf: chevre.factory.offerType.Offer
32
36
  },
@@ -53,46 +57,47 @@ async function main() {
53
57
  headline: { ja: 'xxx', en: '' }
54
58
  },
55
59
  $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
60
  }
95
- ]
61
+ // {
62
+ // $set: {
63
+ // eventStatus: chevre.factory.eventStatusType.EventScheduled,
64
+ // videoFormat: [],
65
+ // soundFormat: [],
66
+ // kanaName: '',
67
+ // startDate: moment('2023-12-08T15:00:00Z')
68
+ // .toDate(),
69
+ // endDate: moment('2123-12-08T15:00:00Z')
70
+ // .toDate(),
71
+ // typeOf: chevre.factory.eventType.ScreeningEventSeries,
72
+ // duration: 'PT2H',
73
+ // name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
74
+ // offers: {
75
+ // typeOf: chevre.factory.offerType.Offer
76
+ // },
77
+ // project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
78
+ // additionalProperty: [
79
+ // ],
80
+ // location: {
81
+ // branchCode: '118',
82
+ // id: '5bfb841d5a78d7948369979a',
83
+ // name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
84
+ // typeOf: chevre.factory.placeType.MovieTheater
85
+ // },
86
+ // workPerformed: {
87
+ // typeOf: chevre.factory.creativeWorkType.Movie,
88
+ // id: '5bfb841d5a78d79483699801',
89
+ // identifier: '071953',
90
+ // name: {
91
+ // ja: '男はつらいよ 純情篇'
92
+ // },
93
+ // duration: 'PT1H29M',
94
+ // version: '6'
95
+ // },
96
+ // organizer: { id: '59d20831e53ebc2b4e774466' }
97
+ // }
98
+ // }
99
+ ],
100
+ { upsert: false }
96
101
  );
97
102
  console.log('result:', result);
98
103
  }
@@ -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,14 @@
1
+ // tslint:disable:no-console
2
+ // tslint:disable-next-line:no-require-imports no-var-requires
3
+ const fpe = require('node-fpe-v1');
4
+
5
+ // const orderNumber = 'CIN1-3796505-5174753';
6
+
7
+ const timestamp = '1769837978000';
8
+ const cipher = fpe({ secret: '3:v2-xxxxxx' });
9
+ // .encrypt(orderNumber);
10
+
11
+ const orderNumber = cipher.encrypt(`${timestamp}1`);
12
+ console.log(orderNumber);
13
+ console.log(cipher.decrypt(orderNumber));
14
+ // '1234567'
@@ -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);