@chevre/domain 25.0.0-alpha.21 → 25.0.0-alpha.22
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.
|
@@ -46,9 +46,6 @@ export declare class MessageRepo {
|
|
|
46
46
|
projectFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(IEmailMessage & {
|
|
47
47
|
id: string;
|
|
48
48
|
})[]>;
|
|
49
|
-
/**
|
|
50
|
-
* コードをキーにしてなければ作成する(複数対応)
|
|
51
|
-
*/
|
|
52
49
|
/**
|
|
53
50
|
* コードをキーにしてひとつ更新(なければ作成する)
|
|
54
51
|
*/
|
|
@@ -62,6 +59,13 @@ export declare class MessageRepo {
|
|
|
62
59
|
id: string;
|
|
63
60
|
};
|
|
64
61
|
}): Promise<IFindByIdentifierResult>;
|
|
62
|
+
/**
|
|
63
|
+
* 発行日時を基準に複数削除
|
|
64
|
+
* 2026-06-28~
|
|
65
|
+
*/
|
|
66
|
+
deleteDatePublishedPassedCertainPeriod(params: {
|
|
67
|
+
$lt: Date;
|
|
68
|
+
}): Promise<void>;
|
|
65
69
|
deleteByMainEntityOrderNumber(params: {
|
|
66
70
|
project: {
|
|
67
71
|
id: string;
|
|
@@ -80,65 +80,6 @@ class MessageRepo {
|
|
|
80
80
|
.lean() // 2024-09-19~
|
|
81
81
|
.exec();
|
|
82
82
|
}
|
|
83
|
-
// 重複エラーをハンドルするためにupsertOneByIdentifierへ移行(2025-05-11~)
|
|
84
|
-
/**
|
|
85
|
-
* コードをキーにしてなければ作成する(複数対応)
|
|
86
|
-
*/
|
|
87
|
-
// public async upsertByIdentifier(
|
|
88
|
-
// params: Pick<
|
|
89
|
-
// IEmailMessage,
|
|
90
|
-
// 'about' | 'identifier' | 'mainEntity' | 'name' | 'project' | 'sender' | 'text' | 'toRecipient' | 'provider'
|
|
91
|
-
// >[]
|
|
92
|
-
// ): Promise<BulkWriteResult | void> {
|
|
93
|
-
// const now = new Date();
|
|
94
|
-
// const bulkWriteOps: AnyBulkWriteOperation<IEmailMessage>[] = [];
|
|
95
|
-
// if (Array.isArray(params)) {
|
|
96
|
-
// params.forEach((creatingNoteParams) => {
|
|
97
|
-
// const { about, identifier, project, text, mainEntity, name, sender, toRecipient, provider } = creatingNoteParams;
|
|
98
|
-
// if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
99
|
-
// throw new factory.errors.ArgumentNull('identifier');
|
|
100
|
-
// }
|
|
101
|
-
// if (typeof text !== 'string') {
|
|
102
|
-
// throw new factory.errors.ArgumentNull('text');
|
|
103
|
-
// }
|
|
104
|
-
// // リソースのユニークネスを保証するfilter
|
|
105
|
-
// const filter: RootFilterQuery<IEmailMessage> = {
|
|
106
|
-
// // typeOf: { $eq: factory.creativeWorkType.EmailMessage },
|
|
107
|
-
// 'project.id': { $eq: project.id },
|
|
108
|
-
// identifier: { $eq: identifier }
|
|
109
|
-
// };
|
|
110
|
-
// const setOnInsert: MatchKeysAndValues<IEmailMessage> = {
|
|
111
|
-
// identifier,
|
|
112
|
-
// project,
|
|
113
|
-
// datePublished: now,
|
|
114
|
-
// typeOf: factory.creativeWorkType.EmailMessage
|
|
115
|
-
// };
|
|
116
|
-
// // 変更可能な属性のみ上書き
|
|
117
|
-
// const setFields: MatchKeysAndValues<IEmailMessage> = {
|
|
118
|
-
// provider,
|
|
119
|
-
// mainEntity,
|
|
120
|
-
// about,
|
|
121
|
-
// sender,
|
|
122
|
-
// text,
|
|
123
|
-
// toRecipient,
|
|
124
|
-
// ...(typeof name === 'string') ? { name } : undefined
|
|
125
|
-
// };
|
|
126
|
-
// const updateFilter: UpdateFilter<IEmailMessage> = {
|
|
127
|
-
// $setOnInsert: setOnInsert,
|
|
128
|
-
// $set: setFields
|
|
129
|
-
// };
|
|
130
|
-
// const updateOne: UpdateOneModel<IEmailMessage> = {
|
|
131
|
-
// filter,
|
|
132
|
-
// update: updateFilter,
|
|
133
|
-
// upsert: true
|
|
134
|
-
// };
|
|
135
|
-
// bulkWriteOps.push({ updateOne });
|
|
136
|
-
// });
|
|
137
|
-
// }
|
|
138
|
-
// if (bulkWriteOps.length > 0) {
|
|
139
|
-
// return this.messageModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
83
|
/**
|
|
143
84
|
* コードをキーにしてひとつ更新(なければ作成する)
|
|
144
85
|
*/
|
|
@@ -219,6 +160,19 @@ class MessageRepo {
|
|
|
219
160
|
}
|
|
220
161
|
return doc;
|
|
221
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* 発行日時を基準に複数削除
|
|
165
|
+
* 2026-06-28~
|
|
166
|
+
*/
|
|
167
|
+
async deleteDatePublishedPassedCertainPeriod(params) {
|
|
168
|
+
const { $lt } = params;
|
|
169
|
+
if ($lt instanceof Date) {
|
|
170
|
+
await this.messageModel.deleteMany({
|
|
171
|
+
datePublished: { $lt }
|
|
172
|
+
})
|
|
173
|
+
.exec();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
222
176
|
async deleteByMainEntityOrderNumber(params) {
|
|
223
177
|
return this.messageModel.deleteMany({
|
|
224
178
|
'project.id': { $eq: params.project.id },
|
|
@@ -16,7 +16,7 @@ export type IEmailMessage = factory.creativeWork.message.email.ICreativeWork & {
|
|
|
16
16
|
typeOf: factory.organizationType.Corporation;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
type IDocType =
|
|
19
|
+
type IDocType = Pick<IEmailMessage, 'about' | 'identifier' | 'name' | 'project' | 'sender' | 'text' | 'toRecipient' | 'typeOf' | 'datePublished' | 'mainEntity' | 'provider'>;
|
|
20
20
|
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
21
21
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
22
22
|
type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
|
|
@@ -22,8 +22,6 @@ const schemaDefinition = {
|
|
|
22
22
|
startDate: Date,
|
|
23
23
|
endDate: Date,
|
|
24
24
|
tasksExportAction: mongoose_1.SchemaTypes.Mixed,
|
|
25
|
-
// tasksExportedAt: Date, // discontinue(2024-06-19~)
|
|
26
|
-
// tasksExportationStatus: String, // discontinue(2024-06-19~)
|
|
27
25
|
potentialActions: mongoose_1.SchemaTypes.Mixed,
|
|
28
26
|
instrument: mongoose_1.SchemaTypes.Mixed
|
|
29
27
|
};
|
|
@@ -81,24 +79,6 @@ const indexes = [
|
|
|
81
79
|
{ expires: 1, startDate: -1 },
|
|
82
80
|
{ name: 'searchByExpiresAndStartDate' }
|
|
83
81
|
],
|
|
84
|
-
[
|
|
85
|
-
{ 'result.order.confirmationNumber': 1, startDate: -1 },
|
|
86
|
-
{
|
|
87
|
-
name: 'searchByResultOrderConfirmationNumber',
|
|
88
|
-
partialFilterExpression: {
|
|
89
|
-
'result.order.confirmationNumber': { $exists: true }
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
[
|
|
94
|
-
{ 'result.order.orderNumber': 1, startDate: -1 },
|
|
95
|
-
{
|
|
96
|
-
name: 'searchByResultOrderNumberAndStartDate',
|
|
97
|
-
partialFilterExpression: {
|
|
98
|
-
'result.order.orderNumber': { $exists: true }
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
82
|
[
|
|
103
83
|
{ 'object.confirmationNumber': 1, startDate: -1 },
|
|
104
84
|
{
|
|
@@ -126,36 +106,6 @@ const indexes = [
|
|
|
126
106
|
}
|
|
127
107
|
}
|
|
128
108
|
],
|
|
129
|
-
[
|
|
130
|
-
// 結果の注文番号はユニークなはず
|
|
131
|
-
{
|
|
132
|
-
typeOf: 1,
|
|
133
|
-
'result.order.orderNumber': 1
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'searchPlaceOrderByOrderNumber',
|
|
137
|
-
unique: true,
|
|
138
|
-
partialFilterExpression: {
|
|
139
|
-
'result.order.orderNumber': { $exists: true }
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
[
|
|
144
|
-
// 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
|
|
145
|
-
{
|
|
146
|
-
typeOf: 1,
|
|
147
|
-
'object.orderNumber': 1
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: 'uniquePlacingOrderNumber20260221',
|
|
151
|
-
unique: true,
|
|
152
|
-
partialFilterExpression: {
|
|
153
|
-
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
154
|
-
'object.orderNumber': { $exists: true },
|
|
155
|
-
startDate: { $gte: new Date('2026-02-21T11:00:00Z') }
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
109
|
[
|
|
160
110
|
// 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
|
|
161
111
|
{
|
|
@@ -261,6 +211,57 @@ const indexes = [
|
|
|
261
211
|
}
|
|
262
212
|
}
|
|
263
213
|
]
|
|
214
|
+
// result.order廃止につきインデックス廃止(2026-06-28~)
|
|
215
|
+
// [
|
|
216
|
+
// { 'result.order.confirmationNumber': 1, startDate: -1 },
|
|
217
|
+
// {
|
|
218
|
+
// name: 'searchByResultOrderConfirmationNumber',
|
|
219
|
+
// partialFilterExpression: {
|
|
220
|
+
// 'result.order.confirmationNumber': { $exists: true }
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
223
|
+
// ],
|
|
224
|
+
// [
|
|
225
|
+
// { 'result.order.orderNumber': 1, startDate: -1 },
|
|
226
|
+
// {
|
|
227
|
+
// name: 'searchByResultOrderNumberAndStartDate',
|
|
228
|
+
// partialFilterExpression: {
|
|
229
|
+
// 'result.order.orderNumber': { $exists: true }
|
|
230
|
+
// }
|
|
231
|
+
// }
|
|
232
|
+
// ],
|
|
233
|
+
// result.order廃止につきインデックス廃止(2026-06-28~)
|
|
234
|
+
// [
|
|
235
|
+
// // 結果の注文番号はユニークなはず
|
|
236
|
+
// {
|
|
237
|
+
// typeOf: 1,
|
|
238
|
+
// 'result.order.orderNumber': 1
|
|
239
|
+
// },
|
|
240
|
+
// {
|
|
241
|
+
// name: 'searchPlaceOrderByOrderNumber',
|
|
242
|
+
// unique: true,
|
|
243
|
+
// partialFilterExpression: {
|
|
244
|
+
// 'result.order.orderNumber': { $exists: true }
|
|
245
|
+
// }
|
|
246
|
+
// }
|
|
247
|
+
// ],
|
|
248
|
+
// uniquePlacingOrderNumberと重複しているので廃止(2026-06-28~)
|
|
249
|
+
// [
|
|
250
|
+
// // 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
|
|
251
|
+
// {
|
|
252
|
+
// typeOf: 1,
|
|
253
|
+
// 'object.orderNumber': 1
|
|
254
|
+
// },
|
|
255
|
+
// {
|
|
256
|
+
// name: 'uniquePlacingOrderNumber20260221',
|
|
257
|
+
// unique: true,
|
|
258
|
+
// partialFilterExpression: {
|
|
259
|
+
// typeOf: factory.transactionType.PlaceOrder,
|
|
260
|
+
// 'object.orderNumber': { $exists: true },
|
|
261
|
+
// startDate: { $gte: new Date('2026-02-21T11:00:00Z') }
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
264
|
+
// ],
|
|
264
265
|
];
|
|
265
266
|
exports.indexes = indexes;
|
|
266
267
|
/**
|
package/package.json
CHANGED