@chevre/domain 21.12.0 → 21.13.0-alpha.1

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 (219) hide show
  1. package/example/src/chevre/searchEvents.ts +1 -1
  2. package/example/src/chevre/searchOrders.ts +1 -1
  3. package/example/src/chevre/transaction/processReturnOrder.ts +8 -8
  4. package/example/src/chevre/transaction/startExportTasks.ts +1 -1
  5. package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +1 -1
  6. package/example/src/chevre/unsetUnnecessaryFields.ts +1 -1
  7. package/example/src/chevre/updateOfferCatalogs.ts +1 -1
  8. package/example/src/chevre/updateTransaction.ts +1 -1
  9. package/lib/chevre/index.d.ts +1 -2
  10. package/lib/chevre/index.js +2 -3
  11. package/lib/chevre/repo/account.js +1 -1
  12. package/lib/chevre/repo/accountTitle.js +1 -1
  13. package/lib/chevre/repo/accountTransaction.js +1 -1
  14. package/lib/chevre/repo/accountingReport.js +1 -1
  15. package/lib/chevre/repo/action.js +1 -1
  16. package/lib/chevre/repo/additionalProperty.js +1 -1
  17. package/lib/chevre/repo/aggregateOffer.js +1 -1
  18. package/lib/chevre/repo/aggregation.js +1 -1
  19. package/lib/chevre/repo/assetTransaction.js +1 -1
  20. package/lib/chevre/repo/categoryCode.js +1 -1
  21. package/lib/chevre/repo/code.js +1 -1
  22. package/lib/chevre/repo/comment.js +1 -1
  23. package/lib/chevre/repo/creativeWork.js +1 -1
  24. package/lib/chevre/repo/customer.js +1 -1
  25. package/lib/chevre/repo/emailMessage.js +1 -1
  26. package/lib/chevre/repo/event.d.ts +2 -2
  27. package/lib/chevre/repo/event.js +6 -2
  28. package/lib/chevre/repo/member.js +1 -1
  29. package/lib/chevre/repo/merchantReturnPolicy.js +1 -1
  30. package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -56
  31. package/lib/chevre/repo/mongoose/schemas/account.js +80 -32
  32. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +4 -90
  33. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +81 -44
  34. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +4 -95
  35. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +129 -62
  36. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +4 -68
  37. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +108 -63
  38. package/lib/chevre/repo/mongoose/schemas/action.d.ts +4 -113
  39. package/lib/chevre/repo/mongoose/schemas/action.js +345 -215
  40. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +4 -74
  41. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +65 -32
  42. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +4 -73
  43. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +258 -155
  44. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -56
  45. package/lib/chevre/repo/mongoose/schemas/aggregation.js +28 -10
  46. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +4 -113
  47. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +258 -146
  48. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +4 -77
  49. package/lib/chevre/repo/mongoose/schemas/authorization.js +110 -61
  50. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +4 -86
  51. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +85 -46
  52. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +4 -89
  53. package/lib/chevre/repo/mongoose/schemas/comments.js +59 -28
  54. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +4 -104
  55. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +121 -70
  56. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +4 -86
  57. package/lib/chevre/repo/mongoose/schemas/customer.js +56 -26
  58. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +4 -80
  59. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +41 -17
  60. package/lib/chevre/repo/mongoose/schemas/event.d.ts +4 -158
  61. package/lib/chevre/repo/mongoose/schemas/event.js +307 -193
  62. package/lib/chevre/repo/mongoose/schemas/member.d.ts +4 -68
  63. package/lib/chevre/repo/mongoose/schemas/member.js +65 -37
  64. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +4 -80
  65. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +29 -11
  66. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +4 -91
  67. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +85 -45
  68. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +4 -91
  69. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +29 -10
  70. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +4 -73
  71. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +37 -12
  72. package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -128
  73. package/lib/chevre/repo/mongoose/schemas/order.js +407 -259
  74. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +4 -86
  75. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +187 -111
  76. package/lib/chevre/repo/mongoose/schemas/place.d.ts +4 -128
  77. package/lib/chevre/repo/mongoose/schemas/place.js +159 -93
  78. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +4 -92
  79. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +94 -49
  80. package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -95
  81. package/lib/chevre/repo/mongoose/schemas/product.js +109 -61
  82. package/lib/chevre/repo/mongoose/schemas/project.d.ts +4 -83
  83. package/lib/chevre/repo/mongoose/schemas/project.js +20 -9
  84. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +4 -143
  85. package/lib/chevre/repo/mongoose/schemas/reservation.js +377 -229
  86. package/lib/chevre/repo/mongoose/schemas/role.d.ts +4 -65
  87. package/lib/chevre/repo/mongoose/schemas/role.js +43 -19
  88. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +4 -95
  89. package/lib/chevre/repo/mongoose/schemas/seller.js +96 -51
  90. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +4 -65
  91. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +112 -63
  92. package/lib/chevre/repo/mongoose/schemas/task.d.ts +4 -95
  93. package/lib/chevre/repo/mongoose/schemas/task.js +214 -126
  94. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +4 -80
  95. package/lib/chevre/repo/mongoose/schemas/telemetry.js +44 -24
  96. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +4 -107
  97. package/lib/chevre/repo/mongoose/schemas/transaction.js +291 -176
  98. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +4 -65
  99. package/lib/chevre/repo/mongoose/schemas/trip.js +20 -9
  100. package/lib/chevre/repo/offer.js +5 -4
  101. package/lib/chevre/repo/offerCatalog.d.ts +1 -1
  102. package/lib/chevre/repo/offerCatalog.js +2 -2
  103. package/lib/chevre/repo/offerCatalogItem.js +1 -1
  104. package/lib/chevre/repo/offerItemCondition.js +1 -1
  105. package/lib/chevre/repo/order.js +1 -1
  106. package/lib/chevre/repo/ownershipInfo.js +1 -1
  107. package/lib/chevre/repo/paymentServiceProvider.js +1 -1
  108. package/lib/chevre/repo/permit.js +1 -1
  109. package/lib/chevre/repo/place/hasPOS.js +1 -1
  110. package/lib/chevre/repo/place.js +1 -1
  111. package/lib/chevre/repo/priceSpecification.js +1 -1
  112. package/lib/chevre/repo/product.js +1 -1
  113. package/lib/chevre/repo/productOffer.js +1 -1
  114. package/lib/chevre/repo/project.js +1 -1
  115. package/lib/chevre/repo/reservation.js +1 -1
  116. package/lib/chevre/repo/role.js +1 -1
  117. package/lib/chevre/repo/seller.js +1 -1
  118. package/lib/chevre/repo/serviceOutput.js +1 -1
  119. package/lib/chevre/repo/task.js +1 -1
  120. package/lib/chevre/repo/telemetry.js +1 -1
  121. package/lib/chevre/repo/transaction.js +1 -1
  122. package/lib/chevre/repo/trip.js +1 -1
  123. package/lib/chevre/repository.d.ts +160 -137
  124. package/lib/chevre/repository.js +531 -223
  125. package/lib/chevre/service/account.d.ts +2 -2
  126. package/lib/chevre/service/accountTransaction/deposit.d.ts +2 -2
  127. package/lib/chevre/service/accountTransaction/transfer.d.ts +2 -2
  128. package/lib/chevre/service/accountTransaction/withdraw.d.ts +2 -2
  129. package/lib/chevre/service/accountTransaction.d.ts +1 -1
  130. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +7 -7
  131. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +6 -6
  132. package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +4 -4
  133. package/lib/chevre/service/aggregation/event/importFromCOA.d.ts +1 -1
  134. package/lib/chevre/service/aggregation/project.d.ts +3 -3
  135. package/lib/chevre/service/aggregation/system.d.ts +5 -5
  136. package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +4 -4
  137. package/lib/chevre/service/assetTransaction/moneyTransfer.d.ts +4 -4
  138. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  139. package/lib/chevre/service/assetTransaction/pay/account/validation.d.ts +1 -1
  140. package/lib/chevre/service/assetTransaction/pay.d.ts +10 -10
  141. package/lib/chevre/service/assetTransaction/refund.d.ts +4 -4
  142. package/lib/chevre/service/assetTransaction/registerService.d.ts +8 -8
  143. package/lib/chevre/service/assetTransaction/reserve.d.ts +14 -14
  144. package/lib/chevre/service/assetTransaction.d.ts +2 -2
  145. package/lib/chevre/service/code.d.ts +2 -2
  146. package/lib/chevre/service/code.js +1 -2
  147. package/lib/chevre/service/delivery.d.ts +5 -5
  148. package/lib/chevre/service/event/createEvent.d.ts +4 -4
  149. package/lib/chevre/service/event.d.ts +7 -7
  150. package/lib/chevre/service/iam.d.ts +2 -2
  151. package/lib/chevre/service/moneyTransfer.d.ts +5 -5
  152. package/lib/chevre/service/notification.d.ts +2 -2
  153. package/lib/chevre/service/offer/event/authorize.d.ts +15 -15
  154. package/lib/chevre/service/offer/event/cancel.d.ts +7 -7
  155. package/lib/chevre/service/offer/event/importFromCOA.d.ts +3 -3
  156. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
  157. package/lib/chevre/service/offer/event/voidTransaction.d.ts +7 -7
  158. package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +1 -1
  159. package/lib/chevre/service/offer/eventServiceByCOA.d.ts +5 -5
  160. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -6
  161. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.d.ts +5 -5
  162. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -2
  163. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +3 -3
  164. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +3 -3
  165. package/lib/chevre/service/offer/product.d.ts +14 -14
  166. package/lib/chevre/service/offer.d.ts +6 -6
  167. package/lib/chevre/service/order/confirmPayTransaction.d.ts +10 -10
  168. package/lib/chevre/service/order/deleteOrder.d.ts +5 -5
  169. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +1 -1
  170. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +5 -5
  171. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -2
  172. package/lib/chevre/service/order/onOrderUpdated.d.ts +1 -1
  173. package/lib/chevre/service/order/payOrder.d.ts +4 -4
  174. package/lib/chevre/service/order/placeOrder.d.ts +6 -6
  175. package/lib/chevre/service/order/returnOrder.d.ts +6 -6
  176. package/lib/chevre/service/order/sendOrder.d.ts +6 -6
  177. package/lib/chevre/service/payment/any/onPaid.d.ts +3 -3
  178. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +1 -1
  179. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +1 -1
  180. package/lib/chevre/service/payment/any/onPaymentStatusChanged.d.ts +2 -2
  181. package/lib/chevre/service/payment/any/onRefund.d.ts +3 -3
  182. package/lib/chevre/service/payment/any.d.ts +10 -10
  183. package/lib/chevre/service/payment/creditCard.d.ts +6 -6
  184. package/lib/chevre/service/payment/faceToFace.d.ts +6 -6
  185. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +2 -2
  186. package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
  187. package/lib/chevre/service/payment/movieTicket/validation.d.ts +5 -5
  188. package/lib/chevre/service/payment/movieTicket.d.ts +6 -6
  189. package/lib/chevre/service/payment/paymentCard.d.ts +7 -7
  190. package/lib/chevre/service/payment.d.ts +9 -9
  191. package/lib/chevre/service/permit.d.ts +2 -2
  192. package/lib/chevre/service/product.d.ts +3 -3
  193. package/lib/chevre/service/project.d.ts +16 -16
  194. package/lib/chevre/service/report/telemetry.d.ts +19 -16
  195. package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
  196. package/lib/chevre/service/reserve/checkInReservation.d.ts +5 -5
  197. package/lib/chevre/service/reserve/confirmReservation.d.ts +4 -4
  198. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +1 -1
  199. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +2 -2
  200. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
  201. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
  202. package/lib/chevre/service/reserve/useReservation.d.ts +5 -5
  203. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +1 -1
  204. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +2 -2
  205. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +3 -3
  206. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +15 -15
  207. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +2 -2
  208. package/lib/chevre/service/task.d.ts +1 -1
  209. package/lib/chevre/service/task.js +3 -4
  210. package/lib/chevre/service/transaction/deleteTransaction.d.ts +9 -9
  211. package/lib/chevre/service/transaction/moneyTransfer.d.ts +9 -9
  212. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +2 -2
  213. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -2
  214. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +7 -7
  215. package/lib/chevre/service/transaction/returnOrder.d.ts +10 -10
  216. package/lib/chevre/service/transaction.d.ts +2 -2
  217. package/lib/chevre/settings.d.ts +1 -0
  218. package/lib/chevre/settings.js +2 -1
  219. package/package.json +1 -1
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.schema = exports.modelName = void 0;
3
+ exports.createSchema = exports.indexes = exports.modelName = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const factory = require("../../../factory");
6
6
  const writeConcern_1 = require("../writeConcern");
7
+ const settings_1 = require("../../../settings");
7
8
  const modelName = 'Transaction';
8
9
  exports.modelName = modelName;
9
- /**
10
- * 取引スキーマ
11
- */
12
- const schema = new mongoose_1.Schema({
10
+ const schemaDefinition = {
13
11
  project: mongoose_1.SchemaTypes.Mixed,
14
12
  status: String,
15
13
  typeOf: String,
@@ -26,14 +24,16 @@ const schema = new mongoose_1.Schema({
26
24
  tasksExportedAt: Date,
27
25
  tasksExportationStatus: String,
28
26
  potentialActions: mongoose_1.SchemaTypes.Mixed
29
- }, {
27
+ };
28
+ const schemaOptions = {
29
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
30
+ autoCreate: false,
30
31
  collection: 'transactions',
31
32
  id: true,
32
33
  read: 'primary',
33
34
  writeConcern: writeConcern_1.writeConcern,
34
35
  strict: true,
35
36
  strictQuery: false,
36
- useNestedStrict: true,
37
37
  timestamps: {
38
38
  createdAt: 'createdAt',
39
39
  updatedAt: 'updatedAt'
@@ -50,173 +50,288 @@ const schema = new mongoose_1.Schema({
50
50
  minimize: false,
51
51
  versionKey: false
52
52
  }
53
- });
54
- exports.schema = schema;
55
- schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
56
- schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
57
- schema.index({ 'project.id': 1, startDate: -1 }, {
58
- name: 'searchByProjectId-v20220721'
59
- });
60
- schema.index({ typeOf: 1, startDate: -1 }, { name: 'searchByTypeOfAndStartDate' });
61
- schema.index({ status: 1, startDate: -1 }, { name: 'searchByStatusAndStartDate' });
62
- schema.index({ startDate: -1 }, { name: 'searchByStartDateDescending' });
63
- schema.index({ endDate: 1, startDate: -1 }, {
64
- name: 'searchByEndDateAndStartDate',
65
- partialFilterExpression: {
66
- endDate: { $exists: true }
67
- }
68
- });
69
- schema.index({ expires: 1, startDate: -1 }, { name: 'searchByExpiresAndStartDate' });
70
- schema.index({ tasksExportationStatus: 1, startDate: -1 }, { name: 'searchByTasksExportationStatusAndStartDate' });
71
- schema.index({ tasksExportedAt: 1, startDate: -1 }, {
72
- name: 'searchByTasksExportedAtAndStartDate',
73
- partialFilterExpression: {
74
- tasksExportedAt: { $exists: true }
75
- }
76
- });
77
- schema.index({ 'result.order.confirmationNumber': 1, startDate: -1 }, {
78
- name: 'searchByResultOrderConfirmationNumber',
79
- partialFilterExpression: {
80
- 'result.order.confirmationNumber': { $exists: true }
81
- }
82
- });
83
- schema.index({ 'result.order.orderNumber': 1, startDate: -1 }, {
84
- name: 'searchByResultOrderNumberAndStartDate',
85
- partialFilterExpression: {
86
- 'result.order.orderNumber': { $exists: true }
87
- }
88
- });
89
- schema.index({ 'object.confirmationNumber': 1, startDate: -1 }, {
90
- name: 'searchByObjectConfirmationNumber',
91
- partialFilterExpression: {
92
- 'object.confirmationNumber': { $exists: true }
93
- }
94
- });
95
- schema.index({ 'object.orderNumber': 1, startDate: -1 }, {
96
- name: 'searchByObjectOrderNumber',
97
- partialFilterExpression: {
98
- 'object.orderNumber': { $exists: true }
99
- }
100
- });
101
- schema.index({ 'object.identifier': 1, startDate: -1 }, {
102
- name: 'searchByObjectIdentifier',
103
- partialFilterExpression: {
104
- 'object.identifier': { $exists: true }
105
- }
106
- });
107
- schema.index({ 'object.order.orderNumber': 1, startDate: -1 }, {
108
- name: 'searchByObjectOrderNumberAndStartDate',
109
- partialFilterExpression: {
110
- 'object.order.orderNumber': { $exists: true }
111
- }
112
- });
113
- // 結果の注文番号はユニークなはず
114
- schema.index({
115
- typeOf: 1,
116
- 'result.order.orderNumber': 1
117
- }, {
118
- name: 'searchPlaceOrderByOrderNumber',
119
- unique: true,
120
- partialFilterExpression: {
121
- 'result.order.orderNumber': { $exists: true }
122
- }
123
- });
124
- schema.index({
125
- typeOf: 1,
126
- 'object.order.orderNumber': 1
127
- }, {
128
- name: 'searchReturnOrderByOrderNumber',
129
- partialFilterExpression: {
130
- 'object.order.orderNumber': { $exists: true }
131
- }
132
- });
133
- // ひとつの注文取引に対する確定返品取引はユニークなはず
134
- schema.index({ 'object.order.orderNumber': 1 }, {
135
- unique: true,
136
- partialFilterExpression: {
137
- typeOf: factory.transactionType.ReturnOrder,
138
- status: factory.transactionStatusType.Confirmed,
139
- 'object.order.orderNumber': { $exists: true }
140
- }
141
- });
142
- schema.index({ 'agent.typeOf': 1, startDate: -1 }, {
143
- name: 'searchByAgentTypeOfAndStartDate',
144
- partialFilterExpression: {
145
- 'agent.typeOf': { $exists: true }
146
- }
147
- });
148
- schema.index({ 'agent.id': 1, startDate: -1 }, {
149
- name: 'searchByAgentIdAndStartDate',
150
- partialFilterExpression: {
151
- 'agent.id': { $exists: true }
152
- }
153
- });
154
- schema.index({ 'agent.identifier': 1, startDate: -1 }, {
155
- name: 'searchByAgentIdentifierAndStartDate',
156
- partialFilterExpression: {
157
- 'agent.identifier': { $exists: true }
158
- }
159
- });
160
- schema.index({ 'agent.familyName': 1, startDate: -1 }, {
161
- name: 'searchByAgentFamilyName',
162
- partialFilterExpression: {
163
- 'agent.familyName': { $exists: true }
164
- }
165
- });
166
- schema.index({ 'agent.givenName': 1, startDate: -1 }, {
167
- name: 'searchByAgentGivenName',
168
- partialFilterExpression: {
169
- 'agent.givenName': { $exists: true }
170
- }
171
- });
172
- schema.index({ 'agent.email': 1, startDate: -1 }, {
173
- name: 'searchByAgentEmail',
174
- partialFilterExpression: {
175
- 'agent.email': { $exists: true }
176
- }
177
- });
178
- schema.index({ 'agent.telephone': 1, startDate: -1 }, {
179
- name: 'searchByAgentTelephone',
180
- partialFilterExpression: {
181
- 'agent.telephone': { $exists: true }
182
- }
183
- });
184
- schema.index({ 'seller.typeOf': 1, startDate: -1 }, {
185
- name: 'searchBySellerTypeOfAndStartDate',
186
- partialFilterExpression: {
187
- 'seller.typeOf': { $exists: true }
188
- }
189
- });
190
- schema.index({ 'seller.id': 1, startDate: -1 }, {
191
- name: 'searchBySellerIdAndStartDate',
192
- partialFilterExpression: {
193
- 'seller.id': { $exists: true }
194
- }
195
- });
196
- schema.index({ typeOf: 1, status: 1, tasksExportationStatus: 1 }, {
197
- name: 'startExportTasks'
198
- });
199
- schema.index({ 'project.id': 1, typeOf: 1, status: 1, tasksExportationStatus: 1 }, {
200
- name: 'startExportTasks-v2',
201
- partialFilterExpression: {
202
- 'project.id': { $exists: true }
203
- }
204
- });
205
- schema.index({ tasksExportationStatus: 1, updatedAt: 1 }, {
206
- name: 'reexportTasks'
207
- });
208
- schema.index({ 'project.id': 1, tasksExportationStatus: 1, updatedAt: 1 }, {
209
- name: 'reexportTasks-v2',
210
- partialFilterExpression: {
211
- 'project.id': { $exists: true }
212
- }
213
- });
214
- schema.index({ status: 1, expires: 1 }, {
215
- name: 'makeExpired'
216
- });
217
- schema.index({ 'project.id': 1, status: 1, expires: 1 }, {
218
- name: 'makeExpired-v2',
219
- partialFilterExpression: {
220
- 'project.id': { $exists: true }
53
+ };
54
+ /**
55
+ * 取引スキーマ
56
+ */
57
+ let schema;
58
+ function createSchema() {
59
+ if (schema === undefined) {
60
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
221
61
  }
222
- });
62
+ return schema;
63
+ }
64
+ exports.createSchema = createSchema;
65
+ const indexes = [
66
+ [
67
+ { createdAt: 1 },
68
+ { name: 'searchByCreatedAt' }
69
+ ],
70
+ [
71
+ { updatedAt: 1 },
72
+ { name: 'searchByUpdatedAt' }
73
+ ],
74
+ [
75
+ { 'project.id': 1, startDate: -1 },
76
+ {
77
+ name: 'searchByProjectId-v20220721'
78
+ }
79
+ ],
80
+ [
81
+ { typeOf: 1, startDate: -1 },
82
+ { name: 'searchByTypeOfAndStartDate' }
83
+ ],
84
+ [
85
+ { status: 1, startDate: -1 },
86
+ { name: 'searchByStatusAndStartDate' }
87
+ ],
88
+ [
89
+ { startDate: -1 },
90
+ { name: 'searchByStartDateDescending' }
91
+ ],
92
+ [
93
+ { endDate: 1, startDate: -1 },
94
+ {
95
+ name: 'searchByEndDateAndStartDate',
96
+ partialFilterExpression: {
97
+ endDate: { $exists: true }
98
+ }
99
+ }
100
+ ],
101
+ [
102
+ { expires: 1, startDate: -1 },
103
+ { name: 'searchByExpiresAndStartDate' }
104
+ ],
105
+ [
106
+ { tasksExportationStatus: 1, startDate: -1 },
107
+ { name: 'searchByTasksExportationStatusAndStartDate' }
108
+ ],
109
+ [
110
+ { tasksExportedAt: 1, startDate: -1 },
111
+ {
112
+ name: 'searchByTasksExportedAtAndStartDate',
113
+ partialFilterExpression: {
114
+ tasksExportedAt: { $exists: true }
115
+ }
116
+ }
117
+ ],
118
+ [
119
+ { 'result.order.confirmationNumber': 1, startDate: -1 },
120
+ {
121
+ name: 'searchByResultOrderConfirmationNumber',
122
+ partialFilterExpression: {
123
+ 'result.order.confirmationNumber': { $exists: true }
124
+ }
125
+ }
126
+ ],
127
+ [
128
+ { 'result.order.orderNumber': 1, startDate: -1 },
129
+ {
130
+ name: 'searchByResultOrderNumberAndStartDate',
131
+ partialFilterExpression: {
132
+ 'result.order.orderNumber': { $exists: true }
133
+ }
134
+ }
135
+ ],
136
+ [
137
+ { 'object.confirmationNumber': 1, startDate: -1 },
138
+ {
139
+ name: 'searchByObjectConfirmationNumber',
140
+ partialFilterExpression: {
141
+ 'object.confirmationNumber': { $exists: true }
142
+ }
143
+ }
144
+ ],
145
+ [
146
+ { 'object.orderNumber': 1, startDate: -1 },
147
+ {
148
+ name: 'searchByObjectOrderNumber',
149
+ partialFilterExpression: {
150
+ 'object.orderNumber': { $exists: true }
151
+ }
152
+ }
153
+ ],
154
+ [
155
+ { 'object.identifier': 1, startDate: -1 },
156
+ {
157
+ name: 'searchByObjectIdentifier',
158
+ partialFilterExpression: {
159
+ 'object.identifier': { $exists: true }
160
+ }
161
+ }
162
+ ],
163
+ [
164
+ { 'object.order.orderNumber': 1, startDate: -1 },
165
+ {
166
+ name: 'searchByObjectOrderNumberAndStartDate',
167
+ partialFilterExpression: {
168
+ 'object.order.orderNumber': { $exists: true }
169
+ }
170
+ }
171
+ ],
172
+ [
173
+ // 結果の注文番号はユニークなはず
174
+ {
175
+ typeOf: 1,
176
+ 'result.order.orderNumber': 1
177
+ },
178
+ {
179
+ name: 'searchPlaceOrderByOrderNumber',
180
+ unique: true,
181
+ partialFilterExpression: {
182
+ 'result.order.orderNumber': { $exists: true }
183
+ }
184
+ }
185
+ ],
186
+ [
187
+ {
188
+ typeOf: 1,
189
+ 'object.order.orderNumber': 1
190
+ },
191
+ {
192
+ name: 'searchReturnOrderByOrderNumber',
193
+ partialFilterExpression: {
194
+ 'object.order.orderNumber': { $exists: true }
195
+ }
196
+ }
197
+ ],
198
+ [
199
+ // ひとつの注文取引に対する確定返品取引はユニークなはず
200
+ { 'object.order.orderNumber': 1 },
201
+ {
202
+ unique: true,
203
+ partialFilterExpression: {
204
+ typeOf: factory.transactionType.ReturnOrder,
205
+ status: factory.transactionStatusType.Confirmed,
206
+ 'object.order.orderNumber': { $exists: true }
207
+ }
208
+ }
209
+ ],
210
+ [
211
+ { 'agent.typeOf': 1, startDate: -1 },
212
+ {
213
+ name: 'searchByAgentTypeOfAndStartDate',
214
+ partialFilterExpression: {
215
+ 'agent.typeOf': { $exists: true }
216
+ }
217
+ }
218
+ ],
219
+ [
220
+ { 'agent.id': 1, startDate: -1 },
221
+ {
222
+ name: 'searchByAgentIdAndStartDate',
223
+ partialFilterExpression: {
224
+ 'agent.id': { $exists: true }
225
+ }
226
+ }
227
+ ],
228
+ [
229
+ { 'agent.identifier': 1, startDate: -1 },
230
+ {
231
+ name: 'searchByAgentIdentifierAndStartDate',
232
+ partialFilterExpression: {
233
+ 'agent.identifier': { $exists: true }
234
+ }
235
+ }
236
+ ],
237
+ [
238
+ { 'agent.familyName': 1, startDate: -1 },
239
+ {
240
+ name: 'searchByAgentFamilyName',
241
+ partialFilterExpression: {
242
+ 'agent.familyName': { $exists: true }
243
+ }
244
+ }
245
+ ],
246
+ [
247
+ { 'agent.givenName': 1, startDate: -1 },
248
+ {
249
+ name: 'searchByAgentGivenName',
250
+ partialFilterExpression: {
251
+ 'agent.givenName': { $exists: true }
252
+ }
253
+ }
254
+ ],
255
+ [
256
+ { 'agent.email': 1, startDate: -1 },
257
+ {
258
+ name: 'searchByAgentEmail',
259
+ partialFilterExpression: {
260
+ 'agent.email': { $exists: true }
261
+ }
262
+ }
263
+ ],
264
+ [
265
+ { 'agent.telephone': 1, startDate: -1 },
266
+ {
267
+ name: 'searchByAgentTelephone',
268
+ partialFilterExpression: {
269
+ 'agent.telephone': { $exists: true }
270
+ }
271
+ }
272
+ ],
273
+ [
274
+ { 'seller.typeOf': 1, startDate: -1 },
275
+ {
276
+ name: 'searchBySellerTypeOfAndStartDate',
277
+ partialFilterExpression: {
278
+ 'seller.typeOf': { $exists: true }
279
+ }
280
+ }
281
+ ],
282
+ [
283
+ { 'seller.id': 1, startDate: -1 },
284
+ {
285
+ name: 'searchBySellerIdAndStartDate',
286
+ partialFilterExpression: {
287
+ 'seller.id': { $exists: true }
288
+ }
289
+ }
290
+ ],
291
+ [
292
+ { typeOf: 1, status: 1, tasksExportationStatus: 1 },
293
+ {
294
+ name: 'startExportTasks'
295
+ }
296
+ ],
297
+ [
298
+ { 'project.id': 1, typeOf: 1, status: 1, tasksExportationStatus: 1 },
299
+ {
300
+ name: 'startExportTasks-v2',
301
+ partialFilterExpression: {
302
+ 'project.id': { $exists: true }
303
+ }
304
+ }
305
+ ],
306
+ [
307
+ { tasksExportationStatus: 1, updatedAt: 1 },
308
+ {
309
+ name: 'reexportTasks'
310
+ }
311
+ ],
312
+ [
313
+ { 'project.id': 1, tasksExportationStatus: 1, updatedAt: 1 },
314
+ {
315
+ name: 'reexportTasks-v2',
316
+ partialFilterExpression: {
317
+ 'project.id': { $exists: true }
318
+ }
319
+ }
320
+ ],
321
+ [
322
+ { status: 1, expires: 1 },
323
+ {
324
+ name: 'makeExpired'
325
+ }
326
+ ],
327
+ [
328
+ { 'project.id': 1, status: 1, expires: 1 },
329
+ {
330
+ name: 'makeExpired-v2',
331
+ partialFilterExpression: {
332
+ 'project.id': { $exists: true }
333
+ }
334
+ }
335
+ ]
336
+ ];
337
+ exports.indexes = indexes;
@@ -1,66 +1,5 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose/types/inferschematype" />
25
- import { Schema } from 'mongoose';
1
+ import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
26
2
  declare const modelName = "Trip";
27
- /**
28
- * トリップスキーマ
29
- */
30
- declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
31
- collection: string;
32
- id: true;
33
- read: string;
34
- writeConcern: import("mongodb").WriteConcern;
35
- strict: false;
36
- strictQuery: false;
37
- useNestedStrict: boolean;
38
- timestamps: {
39
- createdAt: string;
40
- updatedAt: string;
41
- };
42
- toJSON: {
43
- getters: false;
44
- virtuals: false;
45
- minimize: false;
46
- versionKey: false;
47
- };
48
- toObject: {
49
- getters: false;
50
- virtuals: true;
51
- minimize: false;
52
- versionKey: false;
53
- };
54
- }, {
55
- typeOf: string;
56
- project?: any;
57
- }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
58
- typeOf: string;
59
- project?: any;
60
- }>> & Omit<import("mongoose").FlatRecord<{
61
- typeOf: string;
62
- project?: any;
63
- }> & {
64
- _id: import("mongoose").Types.ObjectId;
65
- }, never>>;
66
- export { modelName, schema };
3
+ declare function createSchema(): Schema;
4
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
5
+ export { modelName, indexes, createSchema };
@@ -1,28 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.schema = exports.modelName = void 0;
3
+ exports.createSchema = exports.indexes = exports.modelName = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const writeConcern_1 = require("../writeConcern");
6
6
  const settings_1 = require("../../../settings");
7
7
  const modelName = 'Trip';
8
8
  exports.modelName = modelName;
9
- /**
10
- * トリップスキーマ
11
- */
12
- const schema = new mongoose_1.Schema({
9
+ const schemaDefinition = {
13
10
  project: mongoose_1.SchemaTypes.Mixed,
14
11
  typeOf: {
15
12
  type: String,
16
13
  required: true
17
14
  }
18
- }, {
15
+ };
16
+ const schemaOptions = {
17
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
18
+ autoCreate: false,
19
19
  collection: 'trips',
20
20
  id: true,
21
21
  read: settings_1.MONGO_READ_PREFERENCE,
22
22
  writeConcern: writeConcern_1.writeConcern,
23
23
  strict: false,
24
24
  strictQuery: false,
25
- useNestedStrict: true,
26
25
  timestamps: {
27
26
  createdAt: 'createdAt',
28
27
  updatedAt: 'updatedAt'
@@ -39,5 +38,17 @@ const schema = new mongoose_1.Schema({
39
38
  minimize: false,
40
39
  versionKey: false
41
40
  }
42
- });
43
- exports.schema = schema;
41
+ };
42
+ /**
43
+ * トリップスキーマ
44
+ */
45
+ let schema;
46
+ function createSchema() {
47
+ if (schema === undefined) {
48
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
49
+ }
50
+ return schema;
51
+ }
52
+ exports.createSchema = createSchema;
53
+ const indexes = [];
54
+ exports.indexes = indexes;
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
24
  const createDebug = require("debug");
25
25
  const mongoose_1 = require("mongoose");
26
- const uniqid = require("uniqid");
27
26
  const factory = require("../factory");
28
27
  const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
29
28
  const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
@@ -35,9 +34,9 @@ const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
35
34
  */
36
35
  class MongoRepository {
37
36
  constructor(connection) {
38
- this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, aggregateOffer_1.schema);
39
- this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
40
- this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, offerCatalogItem_1.schema);
37
+ this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, (0, aggregateOffer_1.createSchema)());
38
+ this.offerCatalogModel = connection.model(offerCatalog_1.modelName, (0, offerCatalog_1.createSchema)());
39
+ this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, (0, offerCatalogItem_1.createSchema)());
41
40
  }
42
41
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
43
42
  static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
@@ -735,6 +734,7 @@ class MongoRepository {
735
734
  const { $unset } = params, paramsWithoutUnset = __rest(params, ["$unset"]);
736
735
  let savedUnitPriceOffer;
737
736
  if (params.id === '') {
737
+ const uniqid = yield Promise.resolve().then(() => require('uniqid'));
738
738
  const id = uniqid();
739
739
  savedUnitPriceOffer = Object.assign(Object.assign({}, paramsWithoutUnset), { id });
740
740
  const aggregateOffer = {
@@ -783,6 +783,7 @@ class MongoRepository {
783
783
  // tslint:disable-next-line:max-func-body-length
784
784
  saveManyByIdentifier(params) {
785
785
  return __awaiter(this, void 0, void 0, function* () {
786
+ const uniqid = yield Promise.resolve().then(() => require('uniqid'));
786
787
  const insertBulkWriteOps = [];
787
788
  const updateBulkWriteOps = [];
788
789
  if (Array.isArray(params)) {
@@ -22,7 +22,7 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import { Connection } from 'mongoose';
25
+ import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty'> & {
28
28
  numberOfItems?: number;
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const uniqid = require("uniqid");
25
24
  const factory = require("../factory");
26
25
  const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
27
26
  /**
@@ -29,7 +28,7 @@ const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
29
28
  */
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
- this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
31
+ this.offerCatalogModel = connection.model(offerCatalog_1.modelName, (0, offerCatalog_1.createSchema)());
33
32
  }
34
33
  // tslint:disable-next-line:max-func-body-length
35
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -133,6 +132,7 @@ class MongoRepository {
133
132
  return __awaiter(this, void 0, void 0, function* () {
134
133
  let doc;
135
134
  if (params.id === '') {
135
+ const uniqid = yield Promise.resolve().then(() => require('uniqid'));
136
136
  const id = uniqid();
137
137
  doc = yield this.offerCatalogModel.create(Object.assign(Object.assign({}, params), { _id: id }));
138
138
  }