@chevre/domain 26.0.0-alpha.23 → 26.0.0-alpha.24
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.
- package/lib/chevre/repo/authorization.js +15 -15
- package/lib/chevre/repo/mongoose/schemas/action.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +8 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/authorization.js +25 -18
- package/lib/chevre/repo/mongoose/schemas/message.js +8 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -146
- package/lib/chevre/repo/mongoose/schemas/ticket.js +8 -1
- package/lib/chevre/repo/ownershipInfo.d.ts +6 -74
- package/lib/chevre/repo/ownershipInfo.js +77 -307
- package/lib/chevre/repo/task.d.ts +25 -4
- package/lib/chevre/repo/task.js +1 -0
- package/package.json +2 -2
|
@@ -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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
],
|
|
125
|
-
[
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
{
|
|
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
|
-
{
|
|
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,29 +1,27 @@
|
|
|
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
|
-
|
|
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:
|
|
14
|
+
static CREATE_MONGO_CONDITIONS(params: Pick<IFindParams, 'ownedFromGte' | 'ownedFromLte' | 'project'>): FilterQuery<IDocType>[];
|
|
14
15
|
/**
|
|
15
16
|
* なければ作成する
|
|
16
17
|
*/
|
|
17
18
|
createIfNotExistByIdentifier(ownershipInfo: Omit<IOwnershipInfoWithId, 'id'>): Promise<{
|
|
18
19
|
id: string;
|
|
19
20
|
}>;
|
|
20
|
-
projectFieldsById(params: {
|
|
21
|
-
id: string;
|
|
22
|
-
}, inclusion?: (keyof IOwnershipInfoWithId)[]): Promise<IOwnershipInfoWithId>;
|
|
23
21
|
/**
|
|
24
22
|
* 所有権を検索する
|
|
25
23
|
*/
|
|
26
|
-
projectFields(params:
|
|
24
|
+
projectFields(params: IFindParams, inclusion?: (keyof IOwnershipInfoWithId)[]): Promise<IOwnershipInfoWithId[]>;
|
|
27
25
|
/**
|
|
28
26
|
* 識別子から所有期限を変更する
|
|
29
27
|
* 存在しない場合undefinedを返す
|
|
@@ -35,51 +33,6 @@ export declare class OwnershipInfoRepo {
|
|
|
35
33
|
identifier: string;
|
|
36
34
|
ownedThrough: Date;
|
|
37
35
|
}): 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
36
|
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
37
|
_id: string;
|
|
85
38
|
} & Required<{
|
|
@@ -93,30 +46,9 @@ export declare class OwnershipInfoRepo {
|
|
|
93
46
|
}> & {
|
|
94
47
|
__v: number;
|
|
95
48
|
}) | 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
49
|
unsetUnnecessaryFields(params: {
|
|
119
50
|
filter: any;
|
|
120
51
|
$unset: any;
|
|
121
52
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
122
53
|
}
|
|
54
|
+
export {};
|
|
@@ -15,169 +15,10 @@ class OwnershipInfoRepo {
|
|
|
15
15
|
this.ownershipInfoModel = connection.model(ownershipInfo_1.modelName, (0, ownershipInfo_1.createSchema)());
|
|
16
16
|
}
|
|
17
17
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
18
|
-
const andConditions = [];
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
23
|
-
andConditions.push({
|
|
24
|
-
'project.id': {
|
|
25
|
-
$eq: params.project.id.$eq
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const typeOfGoodIdentifierEq = params.typeOfGood?.identifier?.$eq;
|
|
32
|
-
if (typeof typeOfGoodIdentifierEq === 'string') {
|
|
33
|
-
andConditions.push({
|
|
34
|
-
'typeOfGood.identifier': {
|
|
35
|
-
$exists: true,
|
|
36
|
-
$eq: typeOfGoodIdentifierEq
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
const typeOfGoodIssuedThroughIdEq = params.typeOfGood?.issuedThrough?.id?.$eq;
|
|
41
|
-
if (typeof typeOfGoodIssuedThroughIdEq === 'string') {
|
|
42
|
-
andConditions.push({
|
|
43
|
-
'typeOfGood.issuedThrough.id': {
|
|
44
|
-
$exists: true,
|
|
45
|
-
$eq: typeOfGoodIssuedThroughIdEq
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const typeOfGoodIssuedThroughTypeOfEq = params.typeOfGood?.issuedThrough?.typeOf?.$eq;
|
|
50
|
-
if (typeof typeOfGoodIssuedThroughTypeOfEq === 'string') {
|
|
51
|
-
andConditions.push({
|
|
52
|
-
'typeOfGood.issuedThrough.typeOf': {
|
|
53
|
-
$exists: true,
|
|
54
|
-
$eq: typeOfGoodIssuedThroughTypeOfEq
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const typeOfGoodTypeOf = params.typeOfGood?.typeOf;
|
|
59
|
-
if (typeof typeOfGoodTypeOf === 'string') {
|
|
60
|
-
andConditions.push({
|
|
61
|
-
'typeOfGood.typeOf': {
|
|
62
|
-
$exists: true,
|
|
63
|
-
$eq: typeOfGoodTypeOf
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const typeOfGoodTypeOfEq = typeOfGoodTypeOf?.$eq;
|
|
69
|
-
if (typeof typeOfGoodTypeOfEq === 'string') {
|
|
70
|
-
andConditions.push({
|
|
71
|
-
'typeOfGood.typeOf': {
|
|
72
|
-
$exists: true,
|
|
73
|
-
$eq: typeOfGoodTypeOfEq
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
const typeOfGoodTypeOfIn = typeOfGoodTypeOf?.$in;
|
|
78
|
-
if (Array.isArray(typeOfGoodTypeOfIn)) {
|
|
79
|
-
andConditions.push({
|
|
80
|
-
'typeOfGood.typeOf': {
|
|
81
|
-
$exists: true,
|
|
82
|
-
$in: typeOfGoodTypeOfIn
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// 互換性維持対応
|
|
88
|
-
// if (params.typeOfGood === undefined || params.typeOfGood === null) {
|
|
89
|
-
// params.typeOfGood = {};
|
|
90
|
-
// }
|
|
91
|
-
// if (typeof (<any>params.typeOfGood).id === 'string') {
|
|
92
|
-
// params.typeOfGood.id = { $eq: (<any>params.typeOfGood).id };
|
|
93
|
-
// }
|
|
94
|
-
// if (Array.isArray((<any>params.typeOfGood).ids)) {
|
|
95
|
-
// params.typeOfGood.id = { $in: (<any>params.typeOfGood).ids };
|
|
96
|
-
// }
|
|
97
|
-
const typeOfGoodIdEq = params.typeOfGood?.id?.$eq;
|
|
98
|
-
if (typeof typeOfGoodIdEq === 'string') {
|
|
99
|
-
andConditions.push({
|
|
100
|
-
'typeOfGood.id': {
|
|
101
|
-
$exists: true,
|
|
102
|
-
$eq: typeOfGoodIdEq
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
const typeOfGoodIdIn = params.typeOfGood?.id?.$in;
|
|
107
|
-
if (Array.isArray(typeOfGoodIdIn)) {
|
|
108
|
-
andConditions.push({
|
|
109
|
-
'typeOfGood.id': {
|
|
110
|
-
$exists: true,
|
|
111
|
-
$in: typeOfGoodIdIn
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
/* istanbul ignore else */
|
|
116
|
-
if (Array.isArray(params.ids)) {
|
|
117
|
-
andConditions.push({
|
|
118
|
-
_id: { $in: params.ids }
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/* istanbul ignore else */
|
|
122
|
-
if (Array.isArray(params.identifiers)) {
|
|
123
|
-
andConditions.push({
|
|
124
|
-
identifier: {
|
|
125
|
-
$exists: true,
|
|
126
|
-
$in: params.identifiers
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
const ownedByTypeOfEq = params.ownedBy?.typeOf?.$eq;
|
|
131
|
-
if (typeof ownedByTypeOfEq === 'string') {
|
|
132
|
-
andConditions.push({
|
|
133
|
-
'ownedBy.typeOf': {
|
|
134
|
-
$exists: true,
|
|
135
|
-
$eq: ownedByTypeOfEq
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
/* istanbul ignore else */
|
|
140
|
-
const ownedById = params.ownedBy?.id;
|
|
141
|
-
if (typeof ownedById === 'string') {
|
|
142
|
-
andConditions.push({
|
|
143
|
-
'ownedBy.id': {
|
|
144
|
-
$exists: true,
|
|
145
|
-
$eq: ownedById
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
const ownedByIdIn = ownedById?.$in;
|
|
151
|
-
if (Array.isArray(ownedByIdIn)) {
|
|
152
|
-
andConditions.push({
|
|
153
|
-
'ownedBy.id': {
|
|
154
|
-
$exists: true,
|
|
155
|
-
$in: ownedByIdIn
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// discontinue(2024-12-26~)
|
|
161
|
-
// const ownedByMembershipNumberIn = params.ownedBy?.memberOf?.membershipNumber?.$in;
|
|
162
|
-
// if (Array.isArray(ownedByMembershipNumberIn)) {
|
|
163
|
-
// andConditions.push({
|
|
164
|
-
// 'ownedBy.memberOf.membershipNumber': {
|
|
165
|
-
// $exists: true,
|
|
166
|
-
// $in: ownedByMembershipNumberIn
|
|
167
|
-
// }
|
|
168
|
-
// });
|
|
169
|
-
// }
|
|
170
|
-
/* istanbul ignore else */
|
|
171
|
-
if (params.ownedFrom instanceof Date) {
|
|
172
|
-
andConditions.push({
|
|
173
|
-
ownedThrough: { $gte: params.ownedFrom }
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
/* istanbul ignore else */
|
|
177
|
-
if (params.ownedThrough instanceof Date) {
|
|
178
|
-
andConditions.push({
|
|
179
|
-
ownedFrom: { $lte: params.ownedThrough }
|
|
180
|
-
});
|
|
18
|
+
const andConditions = [];
|
|
19
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
20
|
+
if (typeof projectIdEq === 'string') {
|
|
21
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
181
22
|
}
|
|
182
23
|
const ownedFromGte = params.ownedFromGte;
|
|
183
24
|
if (ownedFromGte instanceof Date) {
|
|
@@ -191,15 +32,6 @@ class OwnershipInfoRepo {
|
|
|
191
32
|
ownedFrom: { $lte: ownedFromLte }
|
|
192
33
|
});
|
|
193
34
|
}
|
|
194
|
-
const acquiredFromIdIn = params.acquiredFrom?.id?.$in;
|
|
195
|
-
if (Array.isArray(acquiredFromIdIn)) {
|
|
196
|
-
andConditions.push({
|
|
197
|
-
'acquiredFrom.id': {
|
|
198
|
-
$exists: true,
|
|
199
|
-
$in: acquiredFromIdIn
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
35
|
return andConditions;
|
|
204
36
|
}
|
|
205
37
|
/**
|
|
@@ -221,9 +53,6 @@ class OwnershipInfoRepo {
|
|
|
221
53
|
projection: {
|
|
222
54
|
_id: 0,
|
|
223
55
|
id: { $toString: '$_id' }
|
|
224
|
-
// __v: 0,
|
|
225
|
-
// createdAt: 0,
|
|
226
|
-
// updatedAt: 0
|
|
227
56
|
}
|
|
228
57
|
})
|
|
229
58
|
.lean()
|
|
@@ -243,9 +72,6 @@ class OwnershipInfoRepo {
|
|
|
243
72
|
doc = await this.ownershipInfoModel.findOne({ identifier: { $eq: ownershipInfo.identifier } }, {
|
|
244
73
|
_id: 0,
|
|
245
74
|
id: { $toString: '$_id' }
|
|
246
|
-
// __v: 0,
|
|
247
|
-
// createdAt: 0,
|
|
248
|
-
// updatedAt: 0
|
|
249
75
|
})
|
|
250
76
|
.lean()
|
|
251
77
|
.exec();
|
|
@@ -255,37 +81,6 @@ class OwnershipInfoRepo {
|
|
|
255
81
|
}
|
|
256
82
|
return { id: doc.id };
|
|
257
83
|
}
|
|
258
|
-
async projectFieldsById(params, inclusion) {
|
|
259
|
-
let projection = {
|
|
260
|
-
_id: 0,
|
|
261
|
-
id: { $toString: '$_id' },
|
|
262
|
-
project: 1,
|
|
263
|
-
typeOf: 1,
|
|
264
|
-
identifier: 1,
|
|
265
|
-
ownedBy: 1,
|
|
266
|
-
acquiredFrom: 1,
|
|
267
|
-
ownedFrom: 1,
|
|
268
|
-
ownedThrough: 1,
|
|
269
|
-
typeOfGood: 1
|
|
270
|
-
};
|
|
271
|
-
const positiveProjectionFields = (Array.isArray(inclusion))
|
|
272
|
-
? inclusion.filter((key) => key !== 'id' && String(key) !== '_id')
|
|
273
|
-
: undefined;
|
|
274
|
-
if (Array.isArray(positiveProjectionFields)) {
|
|
275
|
-
projection = {
|
|
276
|
-
_id: 0,
|
|
277
|
-
id: { $toString: '$_id' },
|
|
278
|
-
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
const doc = await this.ownershipInfoModel.findOne({ _id: { $eq: params.id } }, projection)
|
|
282
|
-
.lean() // lean(2024-08-15~)
|
|
283
|
-
.exec();
|
|
284
|
-
if (doc === null) {
|
|
285
|
-
throw new factory_1.factory.errors.NotFound(this.ownershipInfoModel.modelName);
|
|
286
|
-
}
|
|
287
|
-
return doc;
|
|
288
|
-
}
|
|
289
84
|
/**
|
|
290
85
|
* 所有権を検索する
|
|
291
86
|
*/
|
|
@@ -355,109 +150,84 @@ class OwnershipInfoRepo {
|
|
|
355
150
|
}
|
|
356
151
|
});
|
|
357
152
|
}
|
|
358
|
-
/**
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
async
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
async
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
153
|
+
// /**
|
|
154
|
+
// * 所有期限切れの所有権を削除する
|
|
155
|
+
// */
|
|
156
|
+
// public async deleteExpiredOwnershipInfos(params: {
|
|
157
|
+
// ownedThroughLte: Date;
|
|
158
|
+
// }) {
|
|
159
|
+
// await this.ownershipInfoModel.deleteMany({
|
|
160
|
+
// // 所有期限切れのもの(ownedThroughは必ず存在する)
|
|
161
|
+
// ownedThrough: { $lte: params.ownedThroughLte }
|
|
162
|
+
// })
|
|
163
|
+
// .exec();
|
|
164
|
+
// }
|
|
165
|
+
// /**
|
|
166
|
+
// * 所有者を追加する
|
|
167
|
+
// */
|
|
168
|
+
// public async addOwnerIfNotExist(params: {
|
|
169
|
+
// /**
|
|
170
|
+
// * 所有権ID
|
|
171
|
+
// */
|
|
172
|
+
// id: string;
|
|
173
|
+
// ownedBy: factory.ownershipInfo.IOwner;
|
|
174
|
+
// }): Promise<void> {
|
|
175
|
+
// if (typeof params.ownedBy.id !== 'string' || params.ownedBy.id.length === 0) {
|
|
176
|
+
// throw new factory.errors.ArgumentNull('ownedBy.id');
|
|
177
|
+
// }
|
|
178
|
+
// let newOwner: factory.ownershipInfo.IOwner | undefined;
|
|
179
|
+
// if (params.ownedBy.typeOf === factory.personType.Person) {
|
|
180
|
+
// newOwner = {
|
|
181
|
+
// id: params.ownedBy.id,
|
|
182
|
+
// typeOf: params.ownedBy.typeOf
|
|
183
|
+
// };
|
|
184
|
+
// }
|
|
185
|
+
// if (newOwner !== undefined) {
|
|
186
|
+
// const doc = await this.ownershipInfoModel.findOneAndUpdate(
|
|
187
|
+
// { _id: { $eq: params.id } },
|
|
188
|
+
// { $addToSet: { ownedBy: newOwner } },
|
|
189
|
+
// {
|
|
190
|
+
// new: true,
|
|
191
|
+
// projection: { _id: 1 }
|
|
192
|
+
// }
|
|
193
|
+
// )
|
|
194
|
+
// .exec();
|
|
195
|
+
// if (doc === null) {
|
|
196
|
+
// throw new factory.errors.NotFound(this.ownershipInfoModel.modelName);
|
|
197
|
+
// }
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
200
|
+
// /**
|
|
201
|
+
// * 所有者を削除する
|
|
202
|
+
// */
|
|
203
|
+
// public async removeOwnerIfExist(params: {
|
|
204
|
+
// /**
|
|
205
|
+
// * 所有権ID
|
|
206
|
+
// */
|
|
207
|
+
// id: string;
|
|
208
|
+
// ownedBy: { id: string };
|
|
209
|
+
// }): Promise<void> {
|
|
210
|
+
// if (typeof params.ownedBy.id !== 'string' || params.ownedBy.id.length === 0) {
|
|
211
|
+
// throw new factory.errors.ArgumentNull('ownedBy.id');
|
|
212
|
+
// }
|
|
213
|
+
// const doc = await this.ownershipInfoModel.findOneAndUpdate(
|
|
214
|
+
// { _id: { $eq: params.id } },
|
|
215
|
+
// { $pull: { ownedBy: { id: params.ownedBy.id } } },
|
|
216
|
+
// {
|
|
217
|
+
// new: true,
|
|
218
|
+
// projection: { _id: 1 }
|
|
219
|
+
// }
|
|
220
|
+
// )
|
|
221
|
+
// .exec();
|
|
222
|
+
// if (doc === null) {
|
|
223
|
+
// throw new factory.errors.NotFound(this.ownershipInfoModel.modelName);
|
|
224
|
+
// }
|
|
225
|
+
// }
|
|
415
226
|
getCursor(conditions, projection) {
|
|
416
227
|
return this.ownershipInfoModel.find(conditions, projection)
|
|
417
228
|
.sort({ ownedFrom: factory_1.factory.sortType.Ascending })
|
|
418
229
|
.cursor();
|
|
419
230
|
}
|
|
420
|
-
/**
|
|
421
|
-
* 所有者を追加する
|
|
422
|
-
*/
|
|
423
|
-
async addOwnerIfNotExist(params) {
|
|
424
|
-
if (typeof params.ownedBy.id !== 'string' || params.ownedBy.id.length === 0) {
|
|
425
|
-
throw new factory_1.factory.errors.ArgumentNull('ownedBy.id');
|
|
426
|
-
}
|
|
427
|
-
let newOwner;
|
|
428
|
-
if (params.ownedBy.typeOf === factory_1.factory.personType.Person) {
|
|
429
|
-
newOwner = {
|
|
430
|
-
id: params.ownedBy.id,
|
|
431
|
-
typeOf: params.ownedBy.typeOf
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
if (newOwner !== undefined) {
|
|
435
|
-
const doc = await this.ownershipInfoModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $addToSet: { ownedBy: newOwner } }, {
|
|
436
|
-
new: true,
|
|
437
|
-
projection: { _id: 1 }
|
|
438
|
-
})
|
|
439
|
-
.exec();
|
|
440
|
-
if (doc === null) {
|
|
441
|
-
throw new factory_1.factory.errors.NotFound(this.ownershipInfoModel.modelName);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* 所有者を削除する
|
|
447
|
-
*/
|
|
448
|
-
async removeOwnerIfExist(params) {
|
|
449
|
-
if (typeof params.ownedBy.id !== 'string' || params.ownedBy.id.length === 0) {
|
|
450
|
-
throw new factory_1.factory.errors.ArgumentNull('ownedBy.id');
|
|
451
|
-
}
|
|
452
|
-
const doc = await this.ownershipInfoModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $pull: { ownedBy: { id: params.ownedBy.id } } }, {
|
|
453
|
-
new: true,
|
|
454
|
-
projection: { _id: 1 }
|
|
455
|
-
})
|
|
456
|
-
.exec();
|
|
457
|
-
if (doc === null) {
|
|
458
|
-
throw new factory_1.factory.errors.NotFound(this.ownershipInfoModel.modelName);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
231
|
async unsetUnnecessaryFields(params) {
|
|
462
232
|
return this.ownershipInfoModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
463
233
|
.exec();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
|
-
import { IDocType } from './mongoose/schemas/task';
|
|
4
3
|
/**
|
|
5
4
|
* リトライ可能なタスク作成属性
|
|
6
5
|
*/
|
|
@@ -39,9 +38,31 @@ export declare class TaskRepo {
|
|
|
39
38
|
reservationFor: {
|
|
40
39
|
id: string;
|
|
41
40
|
};
|
|
42
|
-
}): Promise<(import("mongoose").
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
}): Promise<(import("mongoose").FlattenMaps<{
|
|
42
|
+
name: factory.taskName;
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
project: {
|
|
45
|
+
id: string;
|
|
46
|
+
typeOf: factory.organizationType.Project;
|
|
47
|
+
};
|
|
48
|
+
identifier?: string | undefined;
|
|
49
|
+
data: import("@chevre/factory/lib/chevre/task").IData;
|
|
50
|
+
status: factory.taskStatus;
|
|
51
|
+
runsAt: Date;
|
|
52
|
+
dateAborted?: Date | undefined;
|
|
53
|
+
executionResults: {
|
|
54
|
+
executedAt: Date;
|
|
55
|
+
endDate: Date;
|
|
56
|
+
error: string | import("@chevre/factory/lib/chevre/task").IExecutionErrorAsObject;
|
|
57
|
+
}[];
|
|
58
|
+
executor?: {
|
|
59
|
+
name: string;
|
|
60
|
+
} | undefined;
|
|
61
|
+
lastTriedAt?: Date | undefined;
|
|
62
|
+
remainingNumberOfTries: number;
|
|
63
|
+
numberOfTried: number;
|
|
64
|
+
expires?: never | undefined;
|
|
65
|
+
}> & {
|
|
45
66
|
_id: import("mongoose").Types.ObjectId;
|
|
46
67
|
} & {
|
|
47
68
|
__v: number;
|
package/lib/chevre/repo/task.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "10.3.0-alpha.
|
|
14
|
+
"@chevre/factory": "10.3.0-alpha.2",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"postversion": "git push origin --tags",
|
|
89
89
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
90
|
},
|
|
91
|
-
"version": "26.0.0-alpha.
|
|
91
|
+
"version": "26.0.0-alpha.24"
|
|
92
92
|
}
|