@chevre/domain 26.0.0-alpha.23 → 26.0.0-alpha.25

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.
@@ -27,13 +27,6 @@ export declare class AcceptedOfferRepo extends AcceptedOfferInReserveRepo {
27
27
  acceptedOffers: [IAcceptedOffer];
28
28
  _id?: never;
29
29
  })[]>;
30
- aggreateOwnershipInfosByOrder(filter: {
31
- orderNumber: {
32
- $eq: string;
33
- };
34
- }): Promise<{
35
- identifier: string;
36
- }[]>;
37
30
  /**
38
31
  * 注文オファーを展開して検索する
39
32
  * 注文番号指定で1注文ドキュメントから参照する想定
@@ -105,33 +105,33 @@ class AcceptedOfferRepo extends acceptedOfferInReserve_1.AcceptedOfferInReserveR
105
105
  return orders;
106
106
  }
107
107
  }
108
- async aggreateOwnershipInfosByOrder(filter) {
109
- const aggregate = this.orderModel.aggregate([
110
- { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
111
- { $match: { typeOf: { $eq: factory_1.factory.order.OrderType.Order } } },
112
- {
113
- $unwind: {
114
- path: '$acceptedOffers',
115
- includeArrayIndex: 'acceptedOfferIndex'
116
- }
117
- },
118
- {
119
- $project: {
120
- _id: 0,
121
- // acceptedOfferIndex: '$acceptedOfferIndex',
122
- // itemOfferedTypeOf: '$acceptedOffers.itemOffered.typeOf',
123
- // customerId: '$customer.id',
124
- // orderNumber: '$orderNumber',
125
- identifier: {
126
- $concat: ['$customer.id', '-', '$acceptedOffers.itemOffered.typeOf', '-', '$orderNumber', '-', { $toString: '$acceptedOfferIndex' }]
127
- }
128
- }
129
- }
130
- ]);
131
- return aggregate
132
- .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
133
- .exec();
134
- }
108
+ // public async aggreateOwnershipInfosByOrder(
109
+ // filter: {
110
+ // orderNumber: { $eq: string };
111
+ // }
112
+ // ): Promise<{ identifier: string }[]> {
113
+ // const aggregate = this.orderModel.aggregate<{ identifier: string }>([
114
+ // { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
115
+ // { $match: { typeOf: { $eq: factory.order.OrderType.Order } } },
116
+ // {
117
+ // $unwind: {
118
+ // path: '$acceptedOffers',
119
+ // includeArrayIndex: 'acceptedOfferIndex'
120
+ // }
121
+ // },
122
+ // {
123
+ // $project: {
124
+ // _id: 0,
125
+ // identifier: {
126
+ // $concat: ['$customer.id', '-', '$acceptedOffers.itemOffered.typeOf', '-', '$orderNumber', '-', { $toString: '$acceptedOfferIndex' }]
127
+ // }
128
+ // }
129
+ // }
130
+ // ]);
131
+ // return aggregate
132
+ // .option({ maxTimeMS: MONGO_MAX_TIME_MS })
133
+ // .exec();
134
+ // }
135
135
  /**
136
136
  * 注文オファーを展開して検索する
137
137
  * 注文番号指定で1注文ドキュメントから参照する想定
@@ -69,21 +69,21 @@ class AuthorizationRepo {
69
69
  'object.typeOf': { $exists: true, $in: object.typeOfs }
70
70
  });
71
71
  }
72
- /* istanbul ignore else */
73
- if (object.typeOfGood !== undefined) {
74
- /* istanbul ignore else */
75
- if (Array.isArray(object.typeOfGood.ids)) {
76
- andConditions.push({
77
- 'object.typeOfGood.id': { $exists: true, $in: object.typeOfGood.ids }
78
- });
79
- }
80
- /* istanbul ignore else */
81
- if (Array.isArray(object.typeOfGood.typeOfs)) {
82
- andConditions.push({
83
- 'object.typeOfGood.typeOf': { $exists: true, $in: object.typeOfGood.typeOfs }
84
- });
85
- }
86
- }
72
+ // /* istanbul ignore else */
73
+ // if (object.typeOfGood !== undefined) {
74
+ // /* istanbul ignore else */
75
+ // if (Array.isArray(object.typeOfGood.ids)) {
76
+ // andConditions.push({
77
+ // 'object.typeOfGood.id': { $exists: true, $in: object.typeOfGood.ids }
78
+ // });
79
+ // }
80
+ // /* istanbul ignore else */
81
+ // if (Array.isArray(object.typeOfGood.typeOfs)) {
82
+ // andConditions.push({
83
+ // 'object.typeOfGood.typeOf': { $exists: true, $in: object.typeOfGood.typeOfs }
84
+ // });
85
+ // }
86
+ // }
87
87
  }
88
88
  if (params.validFrom instanceof Date) {
89
89
  andConditions.push({ validUntil: { $gte: params.validFrom } });
@@ -59,6 +59,13 @@ const schemaOptions = {
59
59
  }
60
60
  };
61
61
  const indexes = [
62
+ [
63
+ { startDate: 1 },
64
+ {
65
+ name: 'ttlByStartDate', // support ttl index(2026-08-09~)
66
+ expireAfterSeconds: 17280000 // 200 days
67
+ }
68
+ ],
62
69
  [
63
70
  { 'project.id': 1, startDate: -1 },
64
71
  {
@@ -56,6 +56,13 @@ const schemaOptions = {
56
56
  }
57
57
  };
58
58
  const indexes = [
59
+ [
60
+ { dateCreated: 1 },
61
+ {
62
+ name: 'ttlByDateCreated', // support ttl index(2026-08-09~)
63
+ expireAfterSeconds: 17280000 // 200 days
64
+ }
65
+ ],
59
66
  [
60
67
  { dateCreated: -1 },
61
68
  { name: 'searchByDateCreated' }
@@ -36,8 +36,15 @@ const schemaOptions = {
36
36
  const indexes = [
37
37
  [
38
38
  { aggregateStart: 1 },
39
- { name: 'searchByAggregateStart' }
39
+ {
40
+ name: 'ttlByAggregateStart', // support ttl index(2026-08-09~)
41
+ expireAfterSeconds: 15552000 // 180 days
42
+ }
40
43
  ],
44
+ // [
45
+ // { aggregateStart: 1 },
46
+ // { name: 'searchByAggregateStart' }
47
+ // ],
41
48
  [
42
49
  { typeOf: 1, aggregateStart: 1 },
43
50
  { name: 'searchByTypeOf' }
@@ -54,6 +54,16 @@ const schemaOptions = {
54
54
  }
55
55
  };
56
56
  const indexes = [
57
+ [
58
+ { endDate: 1 },
59
+ {
60
+ name: 'ttlByEndDate', // support ttl index(2026-08-09~)
61
+ expireAfterSeconds: 17280000, // 200 days
62
+ partialFilterExpression: {
63
+ endDate: { $exists: true }
64
+ }
65
+ }
66
+ ],
57
67
  [
58
68
  { transactionNumber: 1 },
59
69
  {
@@ -58,6 +58,13 @@ const schemaOptions = {
58
58
  }
59
59
  };
60
60
  const indexes = [
61
+ [
62
+ { validUntil: 1 },
63
+ {
64
+ name: 'ttlByValidUntil', // support ttl index(2026-08-09~)
65
+ expireAfterSeconds: 86400 // 1 days
66
+ }
67
+ ],
61
68
  [
62
69
  // コードはユニークなはず
63
70
  { code: 1 },
@@ -113,24 +120,24 @@ const indexes = [
113
120
  }
114
121
  }
115
122
  ],
116
- [
117
- { 'object.typeOfGood.typeOf': 1, validFrom: 1 },
118
- {
119
- name: 'searchByObjectTypeOfGoodTypeOf',
120
- partialFilterExpression: {
121
- 'object.typeOfGood.typeOf': { $exists: true }
122
- }
123
- }
124
- ],
125
- [
126
- { 'object.typeOfGood.id': 1, validFrom: 1 },
127
- {
128
- name: 'searchByObjectTypeOfGoodId',
129
- partialFilterExpression: {
130
- 'object.typeOfGood.id': { $exists: true }
131
- }
132
- }
133
- ],
123
+ // [
124
+ // { 'object.typeOfGood.typeOf': 1, validFrom: 1 },
125
+ // {
126
+ // name: 'searchByObjectTypeOfGoodTypeOf',
127
+ // partialFilterExpression: {
128
+ // 'object.typeOfGood.typeOf': { $exists: true }
129
+ // }
130
+ // }
131
+ // ],
132
+ // [
133
+ // { 'object.typeOfGood.id': 1, validFrom: 1 },
134
+ // {
135
+ // name: 'searchByObjectTypeOfGoodId',
136
+ // partialFilterExpression: {
137
+ // 'object.typeOfGood.id': { $exists: true }
138
+ // }
139
+ // }
140
+ // ],
134
141
  [
135
142
  { 'audience.id': 1, validFrom: 1 },
136
143
  {
@@ -68,8 +68,15 @@ const schemaOptions = {
68
68
  const indexes = [
69
69
  [
70
70
  { datePublished: 1 },
71
- { name: 'searchByDatePublished' }
71
+ {
72
+ name: 'ttlByDatePublished', // support ttl index(2026-08-09~)
73
+ expireAfterSeconds: 604800 // 7 days
74
+ }
72
75
  ],
76
+ // [
77
+ // { datePublished: 1 },
78
+ // { name: 'searchByDatePublished' }
79
+ // ],
73
80
  [
74
81
  { identifier: 1, datePublished: 1 },
75
82
  { name: 'searchByIdentifier' }
@@ -57,156 +57,11 @@ const indexes = [
57
57
  ],
58
58
  [
59
59
  { 'project.id': 1, ownedFrom: -1 },
60
- {
61
- name: 'searchByProjectId-v20220721'
62
- }
63
- ],
64
- [
65
- { typeOf: 1, ownedFrom: -1 },
66
- { name: 'searchByTypeOf-v2' }
67
- ],
68
- // [
69
- // { identifier: 1, ownedFrom: -1 },
70
- // {
71
- // name: 'searchByIdentifier-v2',
72
- // partialFilterExpression: {
73
- // identifier: { $exists: true }
74
- // }
75
- // }
76
- // ],
77
- [
78
- { identifier: 1, ownedFrom: -1 },
79
- { name: 'identifier' }
60
+ { name: 'searchByProjectId-v20220721' }
80
61
  ],
81
- [
82
- { 'acquiredFrom.id': 1, ownedFrom: -1 },
83
- {
84
- name: 'searchByAcquiredFromId-v2',
85
- partialFilterExpression: {
86
- 'acquiredFrom.id': { $exists: true }
87
- }
88
- }
89
- ],
90
- [
91
- { 'ownedBy.typeOf': 1, ownedFrom: -1 },
92
- {
93
- name: 'searchByOwnedByTypeOf',
94
- partialFilterExpression: {
95
- 'ownedBy.typeOf': { $exists: true }
96
- }
97
- }
98
- ],
99
- [
100
- { 'ownedBy.id': 1, ownedFrom: -1 },
101
- {
102
- name: 'searchByOwnedById',
103
- partialFilterExpression: {
104
- 'ownedBy.id': { $exists: true }
105
- }
106
- }
107
- ],
108
- // [
109
- // { 'ownedBy.memberOf.membershipNumber': 1, ownedFrom: -1 },
110
- // {
111
- // name: 'searchByOwnedByMemberOfMembershipNumber',
112
- // partialFilterExpression: {
113
- // 'ownedBy.memberOf.membershipNumber': { $exists: true }
114
- // }
115
- // }
116
- // ],
117
- // [
118
- // { ownedThrough: -1, ownedFrom: -1 },
119
- // {
120
- // name: 'searchByOwnedThrough-v2',
121
- // partialFilterExpression: {
122
- // ownedThrough: { $exists: true }
123
- // }
124
- // }
125
- // ],
126
62
  [
127
63
  { ownedThrough: 1, ownedFrom: -1 },
128
64
  { name: 'ownedThrough' }
129
- ],
130
- [
131
- { 'typeOfGood.typeOf': 1, ownedFrom: -1 },
132
- {
133
- name: 'searchByTypeOfGoodTypeOf-v2',
134
- partialFilterExpression: {
135
- 'typeOfGood.typeOf': { $exists: true }
136
- }
137
- }
138
- ],
139
- // [
140
- // { 'typeOfGood.reservedTicket.ticketToken': 1, ownedFrom: -1 },
141
- // {
142
- // name: 'searchByTypeOfGoofReservedTicketToken',
143
- // partialFilterExpression: {
144
- // 'typeOfGood.reservedTicket.ticketToken': { $exists: true }
145
- // }
146
- // }
147
- // ],
148
- [
149
- { 'typeOfGood.id': 1, ownedFrom: -1 },
150
- {
151
- name: 'searchByTypeOfGoodId',
152
- partialFilterExpression: {
153
- 'typeOfGood.id': { $exists: true }
154
- }
155
- }
156
- ],
157
- [
158
- { 'typeOfGood.identifier': 1, ownedFrom: -1 },
159
- {
160
- name: 'searchByTypeOfGoodIdentifier',
161
- partialFilterExpression: {
162
- 'typeOfGood.identifier': { $exists: true }
163
- }
164
- }
165
- ],
166
- // [
167
- // { 'typeOfGood.membershipFor.id': 1, ownedFrom: -1 },
168
- // {
169
- // name: 'searchByTypeOfGoodMembershipForId',
170
- // partialFilterExpression: {
171
- // 'typeOfGood.membershipFor.id': { $exists: true }
172
- // }
173
- // }
174
- // ],
175
- [
176
- { 'typeOfGood.issuedThrough.id': 1, ownedFrom: -1 },
177
- {
178
- name: 'searchByTypeOfGoodIssuedThroughId',
179
- partialFilterExpression: {
180
- 'typeOfGood.issuedThrough.id': { $exists: true }
181
- }
182
- }
183
- ],
184
- [
185
- { 'typeOfGood.issuedThrough.typeOf': 1, ownedFrom: -1 },
186
- {
187
- name: 'searchByTypeOfGoodIssuedThroughTypeOf',
188
- partialFilterExpression: {
189
- 'typeOfGood.issuedThrough.typeOf': { $exists: true }
190
- }
191
- }
192
- ],
193
- // [
194
- // { 'typeOfGood.accountNumber': 1, ownedFrom: -1 },
195
- // {
196
- // name: 'searchByTypeOfGoodAccountNumber',
197
- // partialFilterExpression: {
198
- // 'typeOfGood.accountNumber': { $exists: true }
199
- // }
200
- // }
201
- // ],
202
- [
203
- { 'typeOfGood.reservationNumber': 1, ownedFrom: -1 },
204
- {
205
- name: 'searchByTypeOfGoodReservationNumber',
206
- partialFilterExpression: {
207
- 'typeOfGood.reservationNumber': { $exists: true }
208
- }
209
- }
210
65
  ]
211
66
  ];
212
67
  exports.indexes = indexes;
@@ -41,8 +41,15 @@ const schemaOptions = {
41
41
  const indexes = [
42
42
  [
43
43
  { dateIssued: 1 },
44
- { name: 'searchByDateIssued' }
44
+ {
45
+ name: 'ttlByDateIssued', // support ttl index(2026-08-09~)
46
+ expireAfterSeconds: 604800 // 7 days
47
+ }
45
48
  ],
49
+ // [
50
+ // { dateIssued: 1 },
51
+ // { name: 'searchByDateIssued' }
52
+ // ],
46
53
  [
47
54
  { 'project.id': 1, dateIssued: 1 },
48
55
  { name: 'searchByProjectId' }
@@ -1,122 +1,20 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { Connection, FilterQuery } from 'mongoose';
2
2
  import { IDocType } from './mongoose/schemas/ownershipInfo';
3
3
  import { factory } from '../factory';
4
- export type IOwnershipInfoWithId = factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IGood> & {
4
+ type IOwnershipInfoWithId = factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IGood> & {
5
5
  id: string;
6
6
  };
7
+ type IFindParams = factory.ownershipInfo.ISearchConditions;
7
8
  /**
8
9
  * 所有権リポジトリ
9
10
  */
10
11
  export declare class OwnershipInfoRepo {
11
12
  private readonly ownershipInfoModel;
12
13
  constructor(connection: Connection);
13
- static CREATE_MONGO_CONDITIONS(params: factory.ownershipInfo.ISearchConditions): any[];
14
- /**
15
- * なければ作成する
16
- */
17
- createIfNotExistByIdentifier(ownershipInfo: Omit<IOwnershipInfoWithId, 'id'>): Promise<{
18
- id: string;
19
- }>;
20
- projectFieldsById(params: {
21
- id: string;
22
- }, inclusion?: (keyof IOwnershipInfoWithId)[]): Promise<IOwnershipInfoWithId>;
14
+ static CREATE_MONGO_CONDITIONS(params: Pick<IFindParams, 'ownedFromGte' | 'ownedFromLte' | 'project'>): FilterQuery<IDocType>[];
23
15
  /**
24
16
  * 所有権を検索する
25
17
  */
26
- projectFields(params: factory.ownershipInfo.ISearchConditions, inclusion?: (keyof IOwnershipInfoWithId)[]): Promise<IOwnershipInfoWithId[]>;
27
- /**
28
- * 識別子から所有期限を変更する
29
- * 存在しない場合undefinedを返す
30
- */
31
- findByIdentifierAndUpdateOwnedThrough(params: {
32
- project: {
33
- id: string;
34
- };
35
- identifier: string;
36
- ownedThrough: Date;
37
- }): Promise<Pick<IOwnershipInfoWithId, 'id' | 'identifier'> | undefined>;
38
- /**
39
- * 所有者の所有権を全て削除する
40
- */
41
- deleteByOwnedById(params: {
42
- project: {
43
- id: string;
44
- };
45
- ownedBy: {
46
- id: string;
47
- };
48
- }): Promise<{
49
- deletedCount?: number;
50
- }>;
51
- /**
52
- * 特定所有者の特定所有権を削除する
53
- */
54
- deleteByIdAndOwnedById(params: {
55
- project: {
56
- id: string;
57
- };
58
- id: string;
59
- ownedBy: {
60
- id: string;
61
- };
62
- }): Promise<{
63
- deletedCount?: number;
64
- }>;
65
- /**
66
- * 識別子から所有期限切れの所有権を削除する
67
- */
68
- deleteExpiredByIdentifiers(params: {
69
- project: {
70
- id: string;
71
- };
72
- identifiers: string[];
73
- ownedThrough: {
74
- $lte: Date;
75
- };
76
- }): Promise<void>;
77
- /**
78
- * 所有期限切れの所有権を削除する
79
- */
80
- deleteExpiredOwnershipInfos(params: {
81
- ownedThroughLte: Date;
82
- }): Promise<void>;
83
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IGood>, "id"> & {
84
- _id: string;
85
- } & Required<{
86
- _id: string;
87
- }> & {
88
- __v: number;
89
- }, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IGood>, "id"> & {
90
- _id: string;
91
- } & Required<{
92
- _id: string;
93
- }> & {
94
- __v: number;
95
- }) | null>;
96
- /**
97
- * 所有者を追加する
98
- */
99
- addOwnerIfNotExist(params: {
100
- /**
101
- * 所有権ID
102
- */
103
- id: string;
104
- ownedBy: factory.ownershipInfo.IOwner;
105
- }): Promise<void>;
106
- /**
107
- * 所有者を削除する
108
- */
109
- removeOwnerIfExist(params: {
110
- /**
111
- * 所有権ID
112
- */
113
- id: string;
114
- ownedBy: {
115
- id: string;
116
- };
117
- }): Promise<void>;
118
- unsetUnnecessaryFields(params: {
119
- filter: any;
120
- $unset: any;
121
- }): Promise<import("mongoose").UpdateWriteOpResult>;
18
+ findOwnershipInfos(params: IFindParams, inclusion?: (keyof IOwnershipInfoWithId)[]): Promise<IOwnershipInfoWithId[]>;
122
19
  }
20
+ export {};