@chevre/domain 21.2.0-alpha.2 → 21.2.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/countDelayedTasks.ts +17 -0
  3. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  4. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  5. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  6. package/example/src/chevre/lockStockHolder.ts +48 -0
  7. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  8. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  9. package/example/src/chevre/processReserve.ts +2 -2
  10. package/example/src/chevre/searchEventSeats.ts +42 -0
  11. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  12. package/example/src/chevre/transaction/makeExpired.ts +18 -0
  13. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  14. package/example/src/chevre/transaction/startExportTasks.ts +19 -0
  15. package/example/src/chevre/updateTransaction.ts +1 -1
  16. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  17. package/lib/chevre/eventEmitter/task.js +28 -0
  18. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  19. package/lib/chevre/eventEmitter/transaction.js +28 -0
  20. package/lib/chevre/eventEmitter.d.ts +3 -0
  21. package/lib/chevre/eventEmitter.js +7 -0
  22. package/lib/chevre/index.d.ts +3 -2
  23. package/lib/chevre/index.js +5 -3
  24. package/lib/chevre/repo/account.js +0 -4
  25. package/lib/chevre/repo/accountTitle.js +0 -4
  26. package/lib/chevre/repo/accountTransaction.d.ts +0 -10
  27. package/lib/chevre/repo/accountTransaction.js +0 -57
  28. package/lib/chevre/repo/accountingReport.js +0 -4
  29. package/lib/chevre/repo/action.js +0 -4
  30. package/lib/chevre/repo/additionalProperty.js +0 -4
  31. package/lib/chevre/repo/aggregation.js +0 -4
  32. package/lib/chevre/repo/assetTransaction.d.ts +4 -6
  33. package/lib/chevre/repo/assetTransaction.js +69 -45
  34. package/lib/chevre/repo/categoryCode.js +0 -4
  35. package/lib/chevre/repo/code.js +0 -4
  36. package/lib/chevre/repo/comment.js +0 -4
  37. package/lib/chevre/repo/confirmationNumber.js +1 -1
  38. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  39. package/lib/chevre/repo/creativeWork.js +0 -4
  40. package/lib/chevre/repo/customer.js +0 -4
  41. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  42. package/lib/chevre/repo/emailMessage.js +0 -4
  43. package/lib/chevre/repo/event.d.ts +5 -1
  44. package/lib/chevre/repo/event.js +0 -4
  45. package/lib/chevre/repo/member.js +0 -4
  46. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  47. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  48. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  49. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  50. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  51. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  52. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  53. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  54. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  55. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  56. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  57. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  58. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  59. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  60. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  61. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  62. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +42 -3
  63. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +2 -1
  64. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  65. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  66. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  67. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  68. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  69. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  70. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  71. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  72. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  73. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  74. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  75. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  76. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  77. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  78. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  79. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  80. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  81. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  82. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  83. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  84. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  85. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  86. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  87. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  88. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  89. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  90. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  91. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  92. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  93. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  94. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  95. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  96. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  97. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  98. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
  99. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  100. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  101. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  102. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  103. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
  104. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  105. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  106. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  107. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  108. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  109. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  110. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +38 -3
  111. package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
  112. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  113. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  114. package/lib/chevre/repo/offer.js +0 -5
  115. package/lib/chevre/repo/offerCatalog.js +0 -4
  116. package/lib/chevre/repo/order.d.ts +25 -0
  117. package/lib/chevre/repo/order.js +5 -4
  118. package/lib/chevre/repo/orderNumber.d.ts +0 -1
  119. package/lib/chevre/repo/orderNumber.js +2 -12
  120. package/lib/chevre/repo/ownershipInfo.js +0 -4
  121. package/lib/chevre/repo/permit.js +0 -4
  122. package/lib/chevre/repo/place.d.ts +5 -1
  123. package/lib/chevre/repo/place.js +1 -10
  124. package/lib/chevre/repo/priceSpecification.js +0 -4
  125. package/lib/chevre/repo/product.js +0 -4
  126. package/lib/chevre/repo/project.js +0 -4
  127. package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
  128. package/lib/chevre/repo/rateLimit/offer.js +14 -14
  129. package/lib/chevre/repo/reservation.js +0 -4
  130. package/lib/chevre/repo/role.js +0 -4
  131. package/lib/chevre/repo/seller.js +0 -4
  132. package/lib/chevre/repo/serviceOutput.js +0 -4
  133. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
  134. package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
  135. package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +5 -6
  136. package/lib/chevre/repo/stockHolder.js +273 -0
  137. package/lib/chevre/repo/task.d.ts +17 -2
  138. package/lib/chevre/repo/task.js +61 -10
  139. package/lib/chevre/repo/telemetry.js +0 -4
  140. package/lib/chevre/repo/transaction.d.ts +3 -2
  141. package/lib/chevre/repo/transaction.js +116 -54
  142. package/lib/chevre/repo/transactionNumber.d.ts +2 -1
  143. package/lib/chevre/repo/transactionNumber.js +14 -15
  144. package/lib/chevre/repo/trip.js +0 -4
  145. package/lib/chevre/repository.d.ts +3 -5
  146. package/lib/chevre/repository.js +5 -8
  147. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  148. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
  149. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -5
  150. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  151. package/lib/chevre/service/assetTransaction/pay.js +2 -2
  152. package/lib/chevre/service/assetTransaction/refund.js +1 -1
  153. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  154. package/lib/chevre/service/assetTransaction/reserve.d.ts +4 -4
  155. package/lib/chevre/service/assetTransaction/reserve.js +8 -5
  156. package/lib/chevre/service/assetTransaction.d.ts +0 -2
  157. package/lib/chevre/service/assetTransaction.js +0 -1
  158. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  159. package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
  160. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  161. package/lib/chevre/service/offer.d.ts +2 -2
  162. package/lib/chevre/service/offer.js +5 -2
  163. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
  164. package/lib/chevre/service/order/placeOrder.js +1 -1
  165. package/lib/chevre/service/order/returnOrder.js +1 -5
  166. package/lib/chevre/service/order/sendOrder.js +1 -1
  167. package/lib/chevre/service/payment/any.js +1 -1
  168. package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
  169. package/lib/chevre/service/reserve/cancelReservation.js +6 -6
  170. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
  171. package/lib/chevre/service/task/cancelPendingReservation.js +3 -3
  172. package/lib/chevre/service/task/cancelReservation.js +3 -3
  173. package/lib/chevre/service/task/voidReserveTransaction.js +3 -3
  174. package/lib/chevre/service/task.d.ts +9 -0
  175. package/lib/chevre/service/task.js +22 -1
  176. package/lib/chevre/service/transaction/moneyTransfer.js +1 -3
  177. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  178. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  179. package/lib/chevre/service/transaction/returnOrder.js +1 -5
  180. package/lib/chevre/service/transaction.d.ts +1 -0
  181. package/lib/chevre/service/transaction.js +1 -7
  182. package/lib/chevre/settings.d.ts +2 -1
  183. package/lib/chevre/settings.js +5 -4
  184. package/package.json +4 -4
  185. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  186. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  187. package/lib/chevre/repo/itemAvailability/screeningEvent.js +0 -193
@@ -311,7 +311,7 @@ function authorizeAward(params) {
311
311
  if (Array.isArray(givePointAwardParams)) {
312
312
  const pointAwardIdentifiers = givePointAwardParams.map((g) => { var _a; return String((_a = g.object) === null || _a === void 0 ? void 0 : _a.identifier); });
313
313
  // 取引にインセンティブ付与アクションパラメータを保管する
314
- yield repos.transaction.findByIdAndUpdate({
314
+ yield repos.transaction.findByIdAndUpdateInProgress({
315
315
  id: transaction.id,
316
316
  update: {
317
317
  $set: {
@@ -339,7 +339,7 @@ function voidAward(params) {
339
339
  if (transaction.agent.id !== params.agent.id) {
340
340
  throw new factory.errors.Forbidden('Transaction not yours');
341
341
  }
342
- yield repos.transaction.findByIdAndUpdate({
342
+ yield repos.transaction.findByIdAndUpdateInProgress({
343
343
  id: transaction.id,
344
344
  update: {
345
345
  $unset: {
@@ -384,11 +384,7 @@ function exportTasksById(params) {
384
384
  transaction,
385
385
  runsAt: taskRunsAt
386
386
  });
387
- // saveManyに変更(2023-02-01~)
388
- yield repos.task.saveMany(taskAttributes);
389
- // await Promise.all(taskAttributes.map(async (taskAttribute) => {
390
- // await repos.task.save(taskAttribute);
391
- // }));
387
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
392
388
  });
393
389
  }
394
390
  exports.exportTasksById = exportTasksById;
@@ -45,6 +45,7 @@ export declare function exportTasks<T extends factory.transactionType>(params: {
45
45
  typeOf?: {
46
46
  $in: T[];
47
47
  };
48
+ id?: string;
48
49
  }): IExportTasksOperation<void>;
49
50
  /**
50
51
  * 取引に関わるリソースを削除する
@@ -77,15 +77,10 @@ exports.updateAgent = updateAgent;
77
77
  */
78
78
  function exportTasks(params) {
79
79
  return (repos) => __awaiter(this, void 0, void 0, function* () {
80
- const transaction = yield repos.transaction.startExportTasks({
81
- project: params.project,
82
- typeOf: params.typeOf,
83
- status: params.status
84
- });
80
+ const transaction = yield repos.transaction.startExportTasks(Object.assign({ project: params.project, typeOf: params.typeOf, status: params.status }, (typeof params.id === 'string') ? { id: params.id } : undefined));
85
81
  if (transaction === null) {
86
82
  return;
87
83
  }
88
- // let tasks: factory.task.ITask<factory.taskName>[] = [];
89
84
  // 失敗してもここでは戻さない(RUNNINGのまま待機)
90
85
  switch (transaction.typeOf) {
91
86
  case factory.transactionType.MoneyTransfer:
@@ -109,7 +104,6 @@ function exportTasks(params) {
109
104
  default:
110
105
  }
111
106
  yield repos.transaction.setTasksExportedById({ id: transaction.id });
112
- // return tasks;
113
107
  });
114
108
  }
115
109
  exports.exportTasks = exportTasks;
@@ -30,7 +30,8 @@ export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
30
30
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
31
31
  export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
32
32
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
33
- export declare const USE_NEW_ORDER_NUMBER_KEY_FROM: moment.Moment;
33
+ export declare const USE_NEW_CONFIRMATION_NUMBER_KEY_FROM: moment.Moment;
34
+ export declare const USE_EVENT_EMITTERS: boolean;
34
35
  /**
35
36
  * グローバル設定
36
37
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.USE_NEW_ORDER_NUMBER_KEY_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
3
+ exports.settings = exports.USE_EVENT_EMITTERS = exports.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -48,10 +48,11 @@ exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTIO
48
48
  exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
49
49
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
50
50
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
51
- : moment('2023-07-23T15:00:00Z');
52
- exports.USE_NEW_ORDER_NUMBER_KEY_FROM = (typeof process.env.USE_NEW_ORDER_NUMBER_KEY_FROM === 'string')
53
- ? moment(process.env.USE_NEW_ORDER_NUMBER_KEY_FROM)
51
+ : moment('2023-08-31T15:00:00Z');
52
+ exports.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM = (typeof process.env.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM === 'string')
53
+ ? moment(process.env.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM)
54
54
  : moment('2023-04-30T15:00:00Z');
55
+ exports.USE_EVENT_EMITTERS = process.env.USE_EVENT_EMITTERS === '1';
55
56
  /**
56
57
  * グローバル設定
57
58
  */
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.310.0",
12
+ "@chevre/factory": "4.311.0",
13
13
  "@cinerino/sdk": "3.154.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -58,7 +58,7 @@
58
58
  "googleapis": "^85.0.0",
59
59
  "json2csv": "4.5.4",
60
60
  "mocha": "^5.2.0",
61
- "mongoose": "6.10.4",
61
+ "mongoose": "7.0.5",
62
62
  "nock": "^9.6.1",
63
63
  "nyc": "^15.1.0",
64
64
  "power-assert": "^1.6.1",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "peerDependencies": {
76
76
  "aws-sdk": "^2.0.0",
77
- "mongoose": "^6.0.0",
77
+ "mongoose": "^7.0.5",
78
78
  "redis": "^4.6.5"
79
79
  },
80
80
  "engines": {
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.2"
120
+ "version": "21.2.0-alpha.21"
121
121
  }
@@ -1,96 +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
-
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 accountTransactionRepo = new chevre.repository.AccountTransaction(mongoose.connection);
14
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
15
-
16
- const cursor = assetTransactionRepo.getCursor(
17
- {
18
- 'project.id': { $eq: project.id },
19
- typeOf: { $eq: chevre.factory.assetTransactionType.MoneyTransfer },
20
- startDate: {
21
- $gte: moment('2023-02-17T15:00:00Z')
22
- .toDate()
23
- }
24
- // _id: { $eq: 'al6aff83w' }
25
- },
26
- {
27
- // _id: 1,
28
- }
29
- );
30
- console.log('assetTransactions found');
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- // tslint:disable-next-line:max-func-body-length
35
- await cursor.eachAsync(async (doc) => {
36
- i += 1;
37
- const moneyTransferTransaction: chevre.factory.assetTransaction.moneyTransfer.ITransaction = doc.toObject();
38
-
39
- const description = moneyTransferTransaction.object.description;
40
- if (description !== '鑑賞' && description !== '受け取り') {
41
- console.log(
42
- 'no operation needed',
43
- description,
44
- moneyTransferTransaction.project.id,
45
- moneyTransferTransaction.transactionNumber,
46
- moneyTransferTransaction.startDate
47
- );
48
- } else {
49
- const pendingTransactionIdentifier = moneyTransferTransaction.object.pendingTransaction?.identifier;
50
- if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
51
- console.log(
52
- 'pendingTransactionIdentifier found',
53
- description,
54
- moneyTransferTransaction.project.id,
55
- moneyTransferTransaction.transactionNumber,
56
- moneyTransferTransaction.startDate
57
- );
58
- } else {
59
- // 口座取引からidentifierを取得
60
- const accountTransaction =
61
- await accountTransactionRepo.findByTransactionNumber({ transactionNumber: moneyTransferTransaction.transactionNumber });
62
- console.log(
63
- 'updating identifier...',
64
- accountTransaction.identifier,
65
- description,
66
- moneyTransferTransaction.project.id,
67
- moneyTransferTransaction.transactionNumber,
68
- moneyTransferTransaction.startDate
69
- );
70
- if (typeof accountTransaction.identifier === 'string') {
71
- await assetTransactionRepo.findByIdAndUpdate({
72
- id: moneyTransferTransaction.id,
73
- update: {
74
- 'object.pendingTransaction.identifier': accountTransaction.identifier
75
- }
76
- });
77
- }
78
- console.log(
79
- 'ientifier updated',
80
- accountTransaction.identifier,
81
- description,
82
- moneyTransferTransaction.project.id,
83
- moneyTransferTransaction.transactionNumber,
84
- moneyTransferTransaction.startDate
85
- );
86
- updateCount += 1;
87
- }
88
- }
89
- });
90
- console.log(i, 'assetTransactions checked');
91
- console.log(updateCount, 'assetTransactions updated');
92
- }
93
-
94
- main()
95
- .then()
96
- .catch(console.error);
@@ -1,98 +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 EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
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 additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
15
- const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
16
-
17
- const cursor = creativeWorkRepo.getCursor(
18
- {
19
- // 'project.id': { $eq: project.id },
20
- 'project.id': { $ne: EXCLUDED_PROJECT_ID }
21
- },
22
- {
23
- // _id: 1,
24
- }
25
- );
26
- console.log('movies found');
27
-
28
- const additionalPropertyNames: string[] = [];
29
- const projectIds: string[] = [];
30
- const unexpextedprojectIds: string[] = [];
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
37
-
38
- const additionalPropertyNamesOnEvent = movie.additionalProperty?.map((p) => p.name);
39
- if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
40
- console.log(
41
- additionalPropertyNamesOnEvent.length,
42
- 'additionalPropertyNamesOnEvent found',
43
- movie.project.id,
44
- movie.id
45
- );
46
- additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
47
- projectIds.push(movie.project.id);
48
- additionalPropertyNamesOnEvent.forEach((name) => {
49
- if (!name.match(/^[a-zA-Z]*$/)) {
50
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
51
- unexpextedprojectIds.push(movie.project.id);
52
- }
53
- // tslint:disable-next-line:no-magic-numbers
54
- if (name.length < 5) {
55
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
56
- unexpextedprojectIds.push(movie.project.id);
57
- }
58
- });
59
-
60
- for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
61
- const existings = await additionalPropertyRepo.search({
62
- project: { id: { $eq: movie.project.id } },
63
- limit: 1,
64
- page: 1,
65
- name: { $regex: `^${additionalPropertyNameOnEvent}$` }
66
- });
67
- if (existings.length > 0) {
68
- console.log('already existed', additionalPropertyNameOnEvent, movie.id, movie.project.id);
69
- } else {
70
- updateCount += 1;
71
- const newAdditionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
72
- project: movie.project,
73
- typeOf: 'CategoryCode',
74
- codeValue: additionalPropertyNameOnEvent,
75
- inCodeSet: {
76
- typeOf: 'CategoryCodeSet',
77
- identifier: <chevre.factory.creativeWorkType.Movie>movie.typeOf
78
- },
79
- name: { ja: additionalPropertyNameOnEvent }
80
- };
81
- await additionalPropertyRepo.save({
82
- attributes: newAdditionalProperty
83
- });
84
- console.log('created', additionalPropertyNameOnEvent, movie.id, movie.project.id);
85
- }
86
- }
87
- }
88
- });
89
- console.log(i, 'events checked');
90
- console.log(updateCount, 'properties updated');
91
- console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
92
- console.log('projectIds:', [...new Set(projectIds)]);
93
- console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
94
- }
95
-
96
- main()
97
- .then()
98
- .catch(console.error);
@@ -1,193 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RedisRepository = void 0;
13
- const createDebug = require("debug");
14
- const moment = require("moment");
15
- const factory = require("../../factory");
16
- const settings_1 = require("../../settings");
17
- const debug = createDebug('chevre-domain:repo');
18
- /**
19
- * イベントストックホルダーリポジトリ
20
- */
21
- class RedisRepository {
22
- constructor(redisClient) {
23
- this.redisClient = redisClient;
24
- }
25
- static offer2field(params) {
26
- var _a, _b;
27
- // 予約IDをfieldにする場合
28
- const serviceOutputId = (_b = (_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id;
29
- if (typeof serviceOutputId === 'string') {
30
- return serviceOutputId;
31
- }
32
- return `${params.seatSection}:${params.seatNumber}`;
33
- }
34
- static createKey(params) {
35
- const useNewKey = params.startDate instanceof Date
36
- && moment(params.startDate)
37
- .isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
38
- if (useNewKey) {
39
- return `${RedisRepository.KEY_PREFIX_NEW}:${params.eventId}`;
40
- }
41
- else {
42
- return `${RedisRepository.KEY_PREFIX}:${params.eventId}`;
43
- }
44
- }
45
- /**
46
- * 座席をロックする(maxキャパシティチェック有)
47
- */
48
- lockIfNotLimitExceeded(lockKey, maximum) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const key = RedisRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
51
- yield this.redisClient.watch(key);
52
- const hashCount = yield this.redisClient.hLen(key);
53
- // Process result
54
- // Heavy and time consuming operation here
55
- debug('checking hash count...hashCount:', hashCount);
56
- if (hashCount + lockKey.offers.length > maximum) {
57
- throw new factory.errors.Argument('Event', 'maximumAttendeeCapacity exceeded');
58
- }
59
- yield this.lock(lockKey);
60
- });
61
- }
62
- /**
63
- * 座席をロックする
64
- */
65
- lock(lockKey) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const key = RedisRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
68
- const value = lockKey.holder;
69
- const multi = this.redisClient.multi();
70
- const fields = lockKey.offers.map((offer) => RedisRepository.offer2field(offer));
71
- fields.forEach((field) => {
72
- multi.hSetNX(key, field, value);
73
- });
74
- const results = yield multi.expireAt(key, moment(lockKey.expires)
75
- .unix())
76
- .exec();
77
- debug('results:', results);
78
- const lockedFields = [];
79
- if (Array.isArray(results)) {
80
- results.slice(0, fields.length)
81
- .forEach((r, index) => {
82
- if (r === 1 || r === true) {
83
- lockedFields.push(fields[index]);
84
- }
85
- });
86
- }
87
- debug('locked fields:', lockedFields);
88
- const lockedAll = lockedFields.length === fields.length;
89
- debug('lockedAll?', lockedAll);
90
- if (!lockedAll) {
91
- if (lockedFields.length > 0) {
92
- // 全て仮押さえできなければ仮押さえできたものは解除
93
- yield this.redisClient.multi()
94
- .hDel(key, lockedFields)
95
- .exec();
96
- }
97
- throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
98
- }
99
- });
100
- }
101
- /**
102
- * 座席ロックを解除する
103
- */
104
- unlock(params) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
107
- const field = RedisRepository.offer2field(params.offer);
108
- yield this.redisClient.multi()
109
- .hDel(key, field)
110
- .exec();
111
- });
112
- }
113
- /**
114
- * 空席でない座席を検索する
115
- */
116
- findUnavailableOffersByEventId(params) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
119
- const reply = yield this.redisClient.hGetAll(key);
120
- let offers = [];
121
- if (reply !== null) {
122
- offers = Object.keys(reply)
123
- .map((field) => {
124
- const seatSection = field.split(':')[0];
125
- const seatNumber = field.split(':')[1];
126
- return { seatSection, seatNumber };
127
- });
128
- }
129
- return offers;
130
- });
131
- }
132
- /**
133
- * 空席でない座席をカウントする
134
- */
135
- countUnavailableOffers(params) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- const key = RedisRepository.createKey({ eventId: params.event.id, startDate: params.event.startDate });
138
- const reply = yield this.redisClient.hLen(key);
139
- let fieldCount = 0;
140
- if (typeof reply === 'number') {
141
- fieldCount = Number(reply);
142
- }
143
- return fieldCount;
144
- });
145
- }
146
- /**
147
- * 保持者を取得する
148
- */
149
- getHolder(params) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
152
- const field = RedisRepository.offer2field(params.offer);
153
- return this.redisClient.hGet(key, field);
154
- });
155
- }
156
- /**
157
- * 在庫状況を検索する
158
- * offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
159
- */
160
- searchAvailability(params) {
161
- return __awaiter(this, void 0, void 0, function* () {
162
- const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
163
- const fields = params.offers.map((o) => {
164
- return RedisRepository.offer2field(o);
165
- });
166
- // Array reply: list of values associated with the given fields, in the same order as they are requested.
167
- const result = yield this.redisClient.hmGet(key, fields);
168
- if (!Array.isArray(result)) {
169
- throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
170
- }
171
- // return params.offers.map((o, index) => {
172
- // const value4offer = result[index];
173
- // return {
174
- // ...o,
175
- // availability: (typeof value4offer === 'string')
176
- // ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
177
- // : factory.itemAvailability.InStock
178
- // };
179
- // });
180
- // availabilityのみ返却(2023-04-17~)
181
- return result.map((holder) => {
182
- return {
183
- availability: (typeof holder === 'string')
184
- ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
185
- : factory.itemAvailability.InStock
186
- };
187
- });
188
- });
189
- }
190
- }
191
- RedisRepository.KEY_PREFIX_NEW = 'stockHolder';
192
- RedisRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
193
- exports.RedisRepository = RedisRepository;