@chevre/domain 21.30.0-alpha.0 → 21.30.0-alpha.10

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 (85) hide show
  1. package/example/src/chevre/cleanTransactions.ts +39 -0
  2. package/example/src/chevre/optimizeActions.ts +67 -0
  3. package/example/src/chevre/searchActions.ts +2 -1
  4. package/example/src/chevre/searchActionsBySameAs.ts +26 -0
  5. package/example/src/chevre/searchTasks.ts +43 -0
  6. package/lib/chevre/repo/action.d.ts +17 -1
  7. package/lib/chevre/repo/action.js +31 -36
  8. package/lib/chevre/repo/mongoose/schemas/action.js +11 -2
  9. package/lib/chevre/repo/mongoose/schemas/task.d.ts +1 -1
  10. package/lib/chevre/repo/mongoose/schemas/task.js +88 -73
  11. package/lib/chevre/repo/task.d.ts +14 -6
  12. package/lib/chevre/repo/task.js +64 -25
  13. package/lib/chevre/repo/transaction.d.ts +10 -0
  14. package/lib/chevre/repo/transaction.js +17 -0
  15. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  16. package/lib/chevre/service/offer/event/authorize.js +2 -3
  17. package/lib/chevre/service/offer/event/factory.d.ts +0 -1
  18. package/lib/chevre/service/offer/event/factory.js +1 -1
  19. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -1
  20. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -5
  21. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +0 -1
  22. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  23. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +0 -1
  24. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +1 -1
  25. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  26. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
  27. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  28. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  29. package/lib/chevre/service/payment/any.d.ts +6 -0
  30. package/lib/chevre/service/payment/any.js +9 -18
  31. package/lib/chevre/service/payment/creditCard.d.ts +5 -1
  32. package/lib/chevre/service/payment/creditCard.js +10 -3
  33. package/lib/chevre/service/payment/movieTicket.d.ts +5 -1
  34. package/lib/chevre/service/payment/movieTicket.js +9 -2
  35. package/lib/chevre/service/payment.d.ts +5 -1
  36. package/lib/chevre/service/task/aggregateOffers.d.ts +2 -3
  37. package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +2 -3
  38. package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +2 -3
  39. package/lib/chevre/service/task/authorizePayment.d.ts +6 -0
  40. package/lib/chevre/service/task/authorizePayment.js +80 -0
  41. package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +2 -3
  42. package/lib/chevre/service/task/cancelPendingReservation.d.ts +2 -3
  43. package/lib/chevre/service/task/cancelReservation.d.ts +2 -3
  44. package/lib/chevre/service/task/checkResource.d.ts +2 -3
  45. package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +2 -2
  46. package/lib/chevre/service/task/confirmPayTransaction.d.ts +2 -2
  47. package/lib/chevre/service/task/confirmRegisterService.d.ts +2 -2
  48. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +2 -2
  49. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +2 -2
  50. package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
  51. package/lib/chevre/service/task/createEvent.d.ts +2 -3
  52. package/lib/chevre/service/task/deleteTransaction.d.ts +2 -2
  53. package/lib/chevre/service/task/givePointAward.d.ts +2 -2
  54. package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +2 -3
  55. package/lib/chevre/service/task/importEventsFromCOA.d.ts +2 -3
  56. package/lib/chevre/service/task/importOffersFromCOA.d.ts +2 -3
  57. package/lib/chevre/service/task/moneyTransfer.d.ts +2 -3
  58. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +2 -2
  59. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +2 -3
  60. package/lib/chevre/service/task/onEventChanged.d.ts +2 -3
  61. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +2 -2
  62. package/lib/chevre/service/task/onResourceUpdated.d.ts +2 -3
  63. package/lib/chevre/service/task/pay.d.ts +2 -2
  64. package/lib/chevre/service/task/placeOrder.d.ts +2 -2
  65. package/lib/chevre/service/task/refund.d.ts +2 -2
  66. package/lib/chevre/service/task/refund.js +9 -1
  67. package/lib/chevre/service/task/registerService.d.ts +2 -3
  68. package/lib/chevre/service/task/reserve.d.ts +2 -3
  69. package/lib/chevre/service/task/returnMoneyTransfer.d.ts +2 -2
  70. package/lib/chevre/service/task/returnOrder.d.ts +2 -2
  71. package/lib/chevre/service/task/returnPayTransaction.d.ts +2 -2
  72. package/lib/chevre/service/task/returnPointAward.d.ts +2 -2
  73. package/lib/chevre/service/task/returnReserveTransaction.d.ts +2 -2
  74. package/lib/chevre/service/task/sendEmailMessage.d.ts +2 -2
  75. package/lib/chevre/service/task/sendOrder.d.ts +2 -2
  76. package/lib/chevre/service/task/triggerWebhook.d.ts +2 -2
  77. package/lib/chevre/service/task/useReservation.d.ts +2 -3
  78. package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +2 -2
  79. package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
  80. package/lib/chevre/service/task/voidPayment.d.ts +2 -2
  81. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +2 -2
  82. package/lib/chevre/service/task/voidReserveTransaction.d.ts +2 -2
  83. package/lib/chevre/service/task.d.ts +15 -15
  84. package/lib/chevre/service/task.js +28 -14
  85. package/package.json +2 -2
@@ -0,0 +1,39 @@
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
+ const STORAGE_PERIOD_IN_DAYS = 365;
10
+
11
+ // tslint:disable-next-line:max-func-body-length
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
16
+
17
+ // tslint:disable-next-line:no-increment-decrement no-magic-numbers
18
+ for (let index = 0; index < 1800; index++) {
19
+ const updateResult = await transactionRepo.deleteEndDatePassedCertainPeriod({
20
+ typeOf: chevre.factory.transactionType.MoneyTransfer,
21
+ endDate: {
22
+ $gte: moment()
23
+ .add(-(index + STORAGE_PERIOD_IN_DAYS + 1), 'days')
24
+ .toDate(),
25
+ $lt: moment()
26
+ .add(-(index + STORAGE_PERIOD_IN_DAYS), 'days')
27
+ .toDate()
28
+ }
29
+ });
30
+ console.log(
31
+ 'unset processed.', updateResult, -(index + STORAGE_PERIOD_IN_DAYS), 'days',
32
+ moment.duration(index + STORAGE_PERIOD_IN_DAYS, 'days')
33
+ .humanize());
34
+ }
35
+ }
36
+
37
+ main()
38
+ .then()
39
+ .catch(console.error);
@@ -0,0 +1,67 @@
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 actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
14
+
15
+ // tslint:disable-next-line:no-increment-decrement no-magic-numbers
16
+ for (let index = 0; index < 24 * 548; index++) {
17
+ const updateResult = await actionRepo.unsetUnnecessaryFields({
18
+ filter: {
19
+ typeOf: { $eq: chevre.factory.actionType.OrderAction },
20
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.order.OrderType.Order },
21
+ // 'purpose.typeOf': { $exists: true, $eq: chevre.factory.order.OrderType.Order },
22
+ startDate: {
23
+ $gte: moment()
24
+ .add(-(index + 1), 'hours')
25
+ .toDate(),
26
+ $lte: moment()
27
+ .add(-index, 'hours')
28
+ .toDate()
29
+ }
30
+ // _id: { $eq: '61da235d94a80f000af85f6b' }
31
+ },
32
+ $unset: {
33
+ // 'purpose.project': 1,
34
+ // 'purpose.seller': 1,
35
+ // 'purpose.customer': 1
36
+ 'object.project': 1,
37
+ 'object.seller': 1,
38
+ 'object.customer': 1,
39
+ 'object.paymentMethods': 1,
40
+ 'object.discounts': 1,
41
+ 'object.acceptedOffers': 1,
42
+ 'object.url': 1,
43
+ 'object.orderStatus': 1,
44
+ 'object.identifier': 1,
45
+ 'object.isGift': 1,
46
+ 'object.broker': 1,
47
+ 'object.dateReturned': 1,
48
+ 'object.name': 1,
49
+ 'object.orderedItem': 1,
50
+ 'object.returner': 1
51
+ }
52
+ });
53
+ console.log(
54
+ 'unset processed.', updateResult,
55
+ -index, 'hours',
56
+ moment.duration(index, 'hours')
57
+ .asDays(),
58
+ 'days'
59
+ );
60
+ }
61
+ }
62
+
63
+ main()
64
+ .then(() => {
65
+ console.log('success!');
66
+ })
67
+ .catch(console.error);
@@ -24,7 +24,8 @@ async function main() {
24
24
  // serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
25
25
  // }
26
26
  // }
27
- instrument: { transactionNumber: { $eq: 'x' } }
27
+ // instrument: { transactionNumber: { $eq: 'x' } },
28
+ sameAs: { id: { $eq: '66275034ae5d4c3e8997808c' } }
28
29
  },
29
30
  ['_id'],
30
31
  []
@@ -0,0 +1,26 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
11
+
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
+ const actions = await actionRepo.searchBySameAs({
17
+ sameAs: { id: { $eq: '662456a40e9f9ad3b50f1481' } }
18
+ });
19
+ console.log('actions:', actions);
20
+ }
21
+
22
+ main()
23
+ .then(() => {
24
+ console.log('success!');
25
+ })
26
+ .catch(console.error);
@@ -0,0 +1,43 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
11
+
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const indexes = await mongoose.connection.db.collection('tasks')
16
+ .indexes();
17
+ // console.log(indexes);
18
+ console.log(indexes.length, 'indexes found');
19
+
20
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
21
+ const tasks = await taskRepo.search(
22
+ {
23
+ limit: 1,
24
+ page: 1
25
+ // typeOf: { $eq: chevre.factory.actionType.CheckAction },
26
+ // project: { id: { $eq: project.id } },
27
+ // object: {
28
+ // movieTickets: {
29
+ // identifier: { $eq: '0947524082' },
30
+ // serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
31
+ // }
32
+ // }
33
+ // instrument: { transactionNumber: { $eq: 'x' } },
34
+ }
35
+ );
36
+ console.log('tasks:', tasks);
37
+ }
38
+
39
+ main()
40
+ .then(() => {
41
+ console.log('success!');
42
+ })
43
+ .catch(console.error);
@@ -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 type { Connection } from 'mongoose';
25
+ import type { Connection, FilterQuery } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
28
28
  export type IPayAction = factory.action.trade.pay.IAction;
@@ -163,6 +163,18 @@ export declare class MongoRepository {
163
163
  orderNumber: string;
164
164
  sort?: factory.action.ISortOrder;
165
165
  }): Promise<IAction<factory.actionType>[]>;
166
+ searchBySameAs(params: {
167
+ sameAs: {
168
+ id: {
169
+ $eq: string;
170
+ };
171
+ };
172
+ purpose?: {
173
+ id: {
174
+ $eq: string;
175
+ };
176
+ };
177
+ }): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error'>[]>;
166
178
  deleteByProject(params: {
167
179
  project: {
168
180
  id: string;
@@ -290,6 +302,10 @@ export declare class MongoRepository {
290
302
  startThrough: Date;
291
303
  }): Promise<IAggregateAction>;
292
304
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
305
+ unsetUnnecessaryFields(params: {
306
+ filter: FilterQuery<factory.action.IAction<factory.action.IAttributes<factory.actionType, any, any>>>;
307
+ $unset: any;
308
+ }): Promise<import("mongodb").UpdateResult>;
293
309
  /**
294
310
  * 互換性維持対応専用
295
311
  */
@@ -22,7 +22,7 @@ class MongoRepository {
22
22
  }
23
23
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
24
24
  static CREATE_MONGO_CONDITIONS(params) {
25
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73;
25
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75;
26
26
  const andConditions = [];
27
27
  const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
28
28
  if (Array.isArray(idIn)) {
@@ -33,8 +33,6 @@ class MongoRepository {
33
33
  andConditions.push({ _id: { $nin: idNin } });
34
34
  }
35
35
  const projectIdEq = (_d = (_c = params.project) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
36
- // tslint:disable-next-line:no-single-line-block-comment
37
- /* istanbul ignore else */
38
36
  if (typeof projectIdEq === 'string') {
39
37
  andConditions.push({
40
38
  'project.id': {
@@ -42,8 +40,6 @@ class MongoRepository {
42
40
  }
43
41
  });
44
42
  }
45
- // tslint:disable-next-line:no-single-line-block-comment
46
- /* istanbul ignore else */
47
43
  const agentTypeOfIn = (_f = (_e = params.agent) === null || _e === void 0 ? void 0 : _e.typeOf) === null || _f === void 0 ? void 0 : _f.$in;
48
44
  if (Array.isArray(agentTypeOfIn)) {
49
45
  andConditions.push({
@@ -71,8 +67,6 @@ class MongoRepository {
71
67
  andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
72
68
  }
73
69
  const locationIdEq = (_p = (_o = params.location) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$eq;
74
- // tslint:disable-next-line:no-single-line-block-comment
75
- /* istanbul ignore else */
76
70
  if (typeof locationIdEq === 'string') {
77
71
  andConditions.push({
78
72
  'location.id': {
@@ -82,8 +76,6 @@ class MongoRepository {
82
76
  });
83
77
  }
84
78
  const locationIdentifierEq = (_r = (_q = params.location) === null || _q === void 0 ? void 0 : _q.identifier) === null || _r === void 0 ? void 0 : _r.$eq;
85
- // tslint:disable-next-line:no-single-line-block-comment
86
- /* istanbul ignore else */
87
79
  if (typeof locationIdentifierEq === 'string') {
88
80
  andConditions.push({
89
81
  'location.identifier': {
@@ -110,8 +102,6 @@ class MongoRepository {
110
102
  }
111
103
  });
112
104
  }
113
- // tslint:disable-next-line:no-single-line-block-comment
114
- /* istanbul ignore else */
115
105
  const objectPaymentMethodIdEq = (_1 = (_0 = params.object) === null || _0 === void 0 ? void 0 : _0.paymentMethodId) === null || _1 === void 0 ? void 0 : _1.$eq;
116
106
  if (typeof objectPaymentMethodIdEq === 'string') {
117
107
  andConditions.push({
@@ -131,8 +121,6 @@ class MongoRepository {
131
121
  });
132
122
  }
133
123
  const objectReservationForIdEq = (_7 = (_6 = (_5 = params.object) === null || _5 === void 0 ? void 0 : _5.reservationFor) === null || _6 === void 0 ? void 0 : _6.id) === null || _7 === void 0 ? void 0 : _7.$eq;
134
- // tslint:disable-next-line:no-single-line-block-comment
135
- /* istanbul ignore else */
136
124
  if (typeof objectReservationForIdEq === 'string') {
137
125
  andConditions.push({
138
126
  'object.reservationFor.id': {
@@ -160,8 +148,6 @@ class MongoRepository {
160
148
  });
161
149
  }
162
150
  const objectPaymentMethodAccountIdEq = (_14 = (_13 = (_12 = params.object) === null || _12 === void 0 ? void 0 : _12.paymentMethod) === null || _13 === void 0 ? void 0 : _13.accountId) === null || _14 === void 0 ? void 0 : _14.$eq;
163
- // tslint:disable-next-line:no-single-line-block-comment
164
- /* istanbul ignore else */
165
151
  if (typeof objectPaymentMethodAccountIdEq === 'string') {
166
152
  andConditions.push({
167
153
  'object.paymentMethod.accountId': {
@@ -171,8 +157,6 @@ class MongoRepository {
171
157
  });
172
158
  }
173
159
  const objectPaymentMethodPaymentMethodIdEq = (_17 = (_16 = (_15 = params.object) === null || _15 === void 0 ? void 0 : _15.paymentMethod) === null || _16 === void 0 ? void 0 : _16.paymentMethodId) === null || _17 === void 0 ? void 0 : _17.$eq;
174
- // tslint:disable-next-line:no-single-line-block-comment
175
- /* istanbul ignore else */
176
160
  if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
177
161
  andConditions.push({
178
162
  'object.paymentMethod.paymentMethodId': {
@@ -191,8 +175,6 @@ class MongoRepository {
191
175
  });
192
176
  }
193
177
  const objectPaymentMethodTypeOfEq = (_23 = (_22 = (_21 = params.object) === null || _21 === void 0 ? void 0 : _21.paymentMethod) === null || _22 === void 0 ? void 0 : _22.typeOf) === null || _23 === void 0 ? void 0 : _23.$eq;
194
- // tslint:disable-next-line:no-single-line-block-comment
195
- /* istanbul ignore else */
196
178
  if (typeof objectPaymentMethodTypeOfEq === 'string') {
197
179
  andConditions.push({
198
180
  'object.paymentMethod.typeOf': {
@@ -202,8 +184,6 @@ class MongoRepository {
202
184
  });
203
185
  }
204
186
  const objectTypeOfEq = (_25 = (_24 = params.object) === null || _24 === void 0 ? void 0 : _24.typeOf) === null || _25 === void 0 ? void 0 : _25.$eq;
205
- // tslint:disable-next-line:no-single-line-block-comment
206
- /* istanbul ignore else */
207
187
  if (typeof objectTypeOfEq === 'string') {
208
188
  andConditions.push({
209
189
  'object.typeOf': {
@@ -222,8 +202,6 @@ class MongoRepository {
222
202
  });
223
203
  }
224
204
  const objectIdEq = (_29 = (_28 = params.object) === null || _28 === void 0 ? void 0 : _28.id) === null || _29 === void 0 ? void 0 : _29.$eq;
225
- // tslint:disable-next-line:no-single-line-block-comment
226
- /* istanbul ignore else */
227
205
  if (typeof objectIdEq === 'string') {
228
206
  andConditions.push({
229
207
  'object.id': {
@@ -272,8 +250,6 @@ class MongoRepository {
272
250
  if (typeof objectTransactionNumberEq === 'string') {
273
251
  andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
274
252
  }
275
- // tslint:disable-next-line:no-single-line-block-comment
276
- /* istanbul ignore else */
277
253
  if (typeof params.typeOf === 'string') {
278
254
  andConditions.push({
279
255
  typeOf: params.typeOf
@@ -281,8 +257,6 @@ class MongoRepository {
281
257
  }
282
258
  else {
283
259
  const typeOfEq = (_46 = params.typeOf) === null || _46 === void 0 ? void 0 : _46.$eq;
284
- // tslint:disable-next-line:no-single-line-block-comment
285
- /* istanbul ignore else */
286
260
  if (typeof typeOfEq === 'string') {
287
261
  andConditions.push({
288
262
  typeOf: { $eq: typeOfEq }
@@ -290,30 +264,22 @@ class MongoRepository {
290
264
  }
291
265
  }
292
266
  const actionStatusIn = (_47 = params.actionStatus) === null || _47 === void 0 ? void 0 : _47.$in;
293
- // tslint:disable-next-line:no-single-line-block-comment
294
- /* istanbul ignore else */
295
267
  if (Array.isArray(actionStatusIn)) {
296
268
  andConditions.push({
297
269
  actionStatus: { $in: actionStatusIn }
298
270
  });
299
271
  }
300
- // tslint:disable-next-line:no-single-line-block-comment
301
- /* istanbul ignore else */
302
272
  if (Array.isArray(params.actionStatusTypes)) {
303
273
  andConditions.push({
304
274
  actionStatus: { $in: params.actionStatusTypes }
305
275
  });
306
276
  }
307
- // tslint:disable-next-line:no-single-line-block-comment
308
- /* istanbul ignore else */
309
277
  const startDateGte = params.startFrom;
310
278
  if (startDateGte instanceof Date) {
311
279
  andConditions.push({
312
280
  startDate: { $gte: startDateGte }
313
281
  });
314
282
  }
315
- // tslint:disable-next-line:no-single-line-block-comment
316
- /* istanbul ignore else */
317
283
  const startDateLte = params.startThrough;
318
284
  if (startDateLte instanceof Date) {
319
285
  andConditions.push({
@@ -437,6 +403,11 @@ class MongoRepository {
437
403
  }
438
404
  });
439
405
  }
406
+ // sameAs(2024-04-23~)
407
+ const sameAsIdEq = (_75 = (_74 = params.sameAs) === null || _74 === void 0 ? void 0 : _74.id) === null || _75 === void 0 ? void 0 : _75.$eq;
408
+ if (typeof sameAsIdEq === 'string') {
409
+ andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
410
+ }
440
411
  return andConditions;
441
412
  }
442
413
  /**
@@ -536,11 +507,17 @@ class MongoRepository {
536
507
  const doc = yield this.actionModel.findOneAndUpdate({
537
508
  _id: { $eq: params.id },
538
509
  typeOf: { $eq: params.typeOf }
539
- }, { actionStatus: factory.actionStatusType.CanceledActionStatus }, { new: false, projection: { _id: 1 } })
510
+ }, { $set: { actionStatus: factory.actionStatusType.CanceledActionStatus } }, { new: false, projection: { _id: 1 } })
540
511
  .exec();
541
512
  if (doc === null) {
542
513
  throw new factory.errors.NotFound(this.actionModel.modelName);
543
514
  }
515
+ // endDateが存在しなければセット(2024-04-22~)
516
+ yield this.actionModel.updateOne({
517
+ _id: { $eq: params.id },
518
+ endDate: { $exists: false }
519
+ }, { $set: { endDate: new Date() } })
520
+ .exec();
544
521
  });
545
522
  }
546
523
  /**
@@ -701,6 +678,18 @@ class MongoRepository {
701
678
  .then((docs) => docs.map((doc) => doc.toObject()));
702
679
  });
703
680
  }
681
+ searchBySameAs(params) {
682
+ var _a;
683
+ return __awaiter(this, void 0, void 0, function* () {
684
+ const query = this.actionModel.find(Object.assign({ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
685
+ ? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
686
+ : undefined))
687
+ .select({ _id: 1, actionStatus: 1, error: 1 })
688
+ .limit(1);
689
+ return query.exec()
690
+ .then((docs) => docs.map((doc) => doc.toObject()));
691
+ });
692
+ }
704
693
  deleteByProject(params) {
705
694
  return __awaiter(this, void 0, void 0, function* () {
706
695
  yield this.actionModel.deleteMany({
@@ -1024,6 +1013,12 @@ class MongoRepository {
1024
1013
  .sort({ startDate: factory.sortType.Descending })
1025
1014
  .cursor();
1026
1015
  }
1016
+ unsetUnnecessaryFields(params) {
1017
+ return __awaiter(this, void 0, void 0, function* () {
1018
+ return this.actionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
1019
+ .exec();
1020
+ });
1021
+ }
1027
1022
  /**
1028
1023
  * 互換性維持対応専用
1029
1024
  */
@@ -26,7 +26,8 @@ const schemaDefinition = {
26
26
  instrument: mongoose_1.SchemaTypes.Mixed,
27
27
  location: mongoose_1.SchemaTypes.Mixed,
28
28
  replacer: mongoose_1.SchemaTypes.Mixed,
29
- targetCollection: mongoose_1.SchemaTypes.Mixed // add targetCollection(2024-03-19~)
29
+ targetCollection: mongoose_1.SchemaTypes.Mixed,
30
+ sameAs: mongoose_1.SchemaTypes.Mixed // タスク関連付けのために追加(2024-04-20~)
30
31
  };
31
32
  const schemaOptions = {
32
33
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -35,7 +36,6 @@ const schemaOptions = {
35
36
  id: true,
36
37
  read: 'primary',
37
38
  writeConcern: writeConcern_1.writeConcern,
38
- // true化(2022-11-12~)
39
39
  strict: true,
40
40
  strictQuery: false,
41
41
  timestamps: {
@@ -405,6 +405,15 @@ const indexes = [
405
405
  'object.transactionNumber': { $exists: true }
406
406
  }
407
407
  }
408
+ ],
409
+ [
410
+ { 'sameAs.id': 1, startDate: -1 },
411
+ {
412
+ name: 'searchBySameAsId',
413
+ partialFilterExpression: {
414
+ 'sameAs.id': { $exists: true }
415
+ }
416
+ }
408
417
  ]
409
418
  ];
410
419
  exports.indexes = indexes;
@@ -1,5 +1,5 @@
1
1
  import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
2
2
  declare const modelName = "Task";
3
- declare function createSchema(): Schema;
4
3
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
4
+ declare function createSchema(): Schema;
5
5
  export { modelName, indexes, createSchema };