@chevre/domain 21.2.0-alpha.3 → 21.2.0-alpha.31

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 (177) hide show
  1. package/example/src/chevre/countDelayedTasks.ts +17 -0
  2. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  3. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  5. package/example/src/chevre/lockStockHolder.ts +48 -0
  6. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  7. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  8. package/example/src/chevre/searchAbortedTasks.ts +30 -0
  9. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  10. package/example/src/chevre/transaction/makeExpired.ts +18 -0
  11. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  12. package/example/src/chevre/transaction/startExportTasks.ts +19 -0
  13. package/example/src/chevre/updateTransaction.ts +1 -1
  14. package/lib/chevre/credentials.d.ts +1 -0
  15. package/lib/chevre/credentials.js +2 -1
  16. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  17. package/lib/chevre/eventEmitter/assetTransaction.js +28 -0
  18. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  19. package/lib/chevre/eventEmitter/task.js +28 -0
  20. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  21. package/lib/chevre/eventEmitter/transaction.js +28 -0
  22. package/lib/chevre/eventEmitter.d.ts +4 -0
  23. package/lib/chevre/eventEmitter.js +9 -0
  24. package/lib/chevre/index.d.ts +3 -2
  25. package/lib/chevre/index.js +5 -3
  26. package/lib/chevre/repo/account.js +0 -4
  27. package/lib/chevre/repo/accountTitle.js +0 -4
  28. package/lib/chevre/repo/accountTransaction.d.ts +0 -10
  29. package/lib/chevre/repo/accountTransaction.js +0 -57
  30. package/lib/chevre/repo/accountingReport.js +0 -4
  31. package/lib/chevre/repo/action.js +0 -4
  32. package/lib/chevre/repo/additionalProperty.js +0 -4
  33. package/lib/chevre/repo/aggregation.js +0 -4
  34. package/lib/chevre/repo/assetTransaction.d.ts +9 -6
  35. package/lib/chevre/repo/assetTransaction.js +132 -48
  36. package/lib/chevre/repo/categoryCode.js +0 -4
  37. package/lib/chevre/repo/code.js +0 -4
  38. package/lib/chevre/repo/comment.js +0 -4
  39. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  40. package/lib/chevre/repo/confirmationNumber.js +3 -15
  41. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  42. package/lib/chevre/repo/creativeWork.js +0 -4
  43. package/lib/chevre/repo/customer.js +0 -4
  44. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  45. package/lib/chevre/repo/emailMessage.js +0 -4
  46. package/lib/chevre/repo/event.d.ts +5 -1
  47. package/lib/chevre/repo/event.js +0 -4
  48. package/lib/chevre/repo/member.js +0 -4
  49. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  50. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  51. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  52. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  53. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  54. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  55. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  56. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  57. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  58. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  59. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  60. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  61. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  62. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  63. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  64. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  65. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
  66. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +3 -1
  67. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  68. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  69. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  70. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  71. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  72. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  73. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  74. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  75. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  76. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  77. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  78. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  79. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  80. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  81. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  82. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  83. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  84. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  85. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  86. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  87. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  88. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  89. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  90. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  91. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  92. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  93. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  94. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  95. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  96. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  97. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  98. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  99. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  100. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  101. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
  102. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  103. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  104. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  105. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  106. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
  107. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  108. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  109. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  110. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  111. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  112. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  113. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
  114. package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
  115. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  116. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  117. package/lib/chevre/repo/offer.js +0 -5
  118. package/lib/chevre/repo/offerCatalog.js +0 -4
  119. package/lib/chevre/repo/order.d.ts +25 -0
  120. package/lib/chevre/repo/order.js +5 -4
  121. package/lib/chevre/repo/orderNumber.d.ts +0 -1
  122. package/lib/chevre/repo/orderNumber.js +2 -12
  123. package/lib/chevre/repo/ownershipInfo.js +0 -4
  124. package/lib/chevre/repo/permit.js +0 -4
  125. package/lib/chevre/repo/place.d.ts +5 -1
  126. package/lib/chevre/repo/place.js +1 -10
  127. package/lib/chevre/repo/priceSpecification.js +0 -4
  128. package/lib/chevre/repo/product.js +0 -4
  129. package/lib/chevre/repo/project.js +0 -4
  130. package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
  131. package/lib/chevre/repo/rateLimit/offer.js +14 -14
  132. package/lib/chevre/repo/reservation.js +0 -4
  133. package/lib/chevre/repo/role.js +0 -4
  134. package/lib/chevre/repo/seller.js +0 -4
  135. package/lib/chevre/repo/serviceOutput.js +0 -4
  136. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
  137. package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
  138. package/lib/chevre/repo/stockHolder.d.ts +1 -0
  139. package/lib/chevre/repo/stockHolder.js +74 -7
  140. package/lib/chevre/repo/task.d.ts +17 -2
  141. package/lib/chevre/repo/task.js +61 -10
  142. package/lib/chevre/repo/telemetry.js +0 -4
  143. package/lib/chevre/repo/transaction.d.ts +10 -2
  144. package/lib/chevre/repo/transaction.js +144 -55
  145. package/lib/chevre/repo/transactionNumber.d.ts +2 -1
  146. package/lib/chevre/repo/transactionNumber.js +14 -15
  147. package/lib/chevre/repo/trip.js +0 -4
  148. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -5
  149. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  150. package/lib/chevre/service/assetTransaction/pay.js +2 -2
  151. package/lib/chevre/service/assetTransaction/refund.js +1 -1
  152. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  153. package/lib/chevre/service/assetTransaction/reserve.js +1 -1
  154. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  155. package/lib/chevre/service/assetTransaction.js +9 -5
  156. package/lib/chevre/service/notification.d.ts +3 -1
  157. package/lib/chevre/service/notification.js +2 -6
  158. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
  159. package/lib/chevre/service/order/placeOrder.js +1 -1
  160. package/lib/chevre/service/order/returnOrder.js +1 -5
  161. package/lib/chevre/service/order/sendOrder.js +1 -1
  162. package/lib/chevre/service/payment/any.js +25 -10
  163. package/lib/chevre/service/reserve/useReservation.js +1 -8
  164. package/lib/chevre/service/task.d.ts +9 -0
  165. package/lib/chevre/service/task.js +43 -4
  166. package/lib/chevre/service/transaction/moneyTransfer.js +1 -3
  167. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +16 -16
  168. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  169. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  170. package/lib/chevre/service/transaction/returnOrder.js +1 -5
  171. package/lib/chevre/service/transaction.d.ts +6 -0
  172. package/lib/chevre/service/transaction.js +9 -7
  173. package/lib/chevre/settings.d.ts +2 -1
  174. package/lib/chevre/settings.js +4 -5
  175. package/package.json +4 -4
  176. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  177. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
@@ -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);