@chevre/domain 22.14.0-alpha.0 → 22.14.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.
- package/example/src/chevre/note/upsertNotesByIdentifier.ts +58 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +2 -5
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/note.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/note.js +2 -1
- package/lib/chevre/repo/note.d.ts +34 -2
- package/lib/chevre/repo/note.js +103 -6
- package/lib/chevre/repo/task.js +2 -2
- package/lib/chevre/service/event.js +10 -2
- package/lib/chevre/service/order/deleteOrder.js +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +1 -1
- package/lib/chevre/service/task/deletePerson.js +11 -10
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +6 -1
- package/lib/chevre/service/transaction/deleteTransaction.js +9 -9
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -1
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +1 -1
- package/package.json +2 -2
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +0 -132
- package/example/src/chevre/optimizeDeleteTransactionTasks.ts +0 -119
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const creatingNote: Pick<
|
|
15
|
+
chevre.factory.creativeWork.noteDigitalDocument.INoteAboutProduct,
|
|
16
|
+
'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'
|
|
17
|
+
> = {
|
|
18
|
+
about: { id: '656038908b1cd5ce629f5992', typeOf: chevre.factory.product.ProductType.EventService },
|
|
19
|
+
creator: { id: 'xxx', typeOf: chevre.factory.personType.Person },
|
|
20
|
+
identifier: 'abcdefgh',
|
|
21
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
22
|
+
provider: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
23
|
+
text: 'sample note text...',
|
|
24
|
+
version: '1',
|
|
25
|
+
hasDigitalDocumentPermission: []
|
|
26
|
+
|
|
27
|
+
};
|
|
28
|
+
const createResult = await noteRepo.upsertNotesByIdentifier(
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
$set: creatingNote
|
|
32
|
+
// $unset: {}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
$set: creatingNote
|
|
36
|
+
// $unset: {}
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
{ update: false }
|
|
40
|
+
);
|
|
41
|
+
// tslint:disable-next-line:no-null-keyword
|
|
42
|
+
console.dir(createResult, { depth: null });
|
|
43
|
+
|
|
44
|
+
const updateResult = await noteRepo.upsertNotesByIdentifier(
|
|
45
|
+
[
|
|
46
|
+
{
|
|
47
|
+
$set: creatingNote
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
{ update: true }
|
|
51
|
+
);
|
|
52
|
+
// tslint:disable-next-line:no-null-keyword
|
|
53
|
+
console.dir(updateResult, { depth: null });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
main()
|
|
57
|
+
.then()
|
|
58
|
+
.catch(console.error);
|
|
@@ -9,11 +9,8 @@ async function main() {
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
const permissions = [
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'orders.update',
|
|
15
|
-
'reservations.attended',
|
|
16
|
-
'reservations.read'
|
|
12
|
+
'notes.*',
|
|
13
|
+
'notes.read'
|
|
17
14
|
];
|
|
18
15
|
for (const permission of permissions) {
|
|
19
16
|
const roles = await roleRepo.projectFields(
|
|
@@ -2,7 +2,7 @@ import { factory as surfrockFactory } from '@surfrock/sdk';
|
|
|
2
2
|
import { Connection, FilterQuery, UpdateQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
export type IAction4transaction<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction> = T extends factory.actionType.AcceptAction ? factory.action.accept.coaOffer.IAction | factory.action.accept.pay.IAction : T extends factory.actionType.AuthorizeAction ? (factory.action.authorize.offer.eventService.IAction | factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.paymentMethod.any.IAction) : never;
|
|
5
|
-
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction
|
|
5
|
+
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.AddAction ? factory.action.update.add.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction : T extends factory.actionType.UpdateAction ? factory.action.update.update.IAction : T extends factory.actionType.InformAction ? factory.action.interact.inform.IAction<factory.action.interact.inform.IAttributes<factory.action.interact.inform.IObject>> & {
|
|
6
6
|
error?: any;
|
|
7
7
|
purpose?: never;
|
|
8
8
|
} : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
type IDocType = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument
|
|
3
|
+
type IDocType = Pick<factory.creativeWork.noteDigitalDocument.INoteDigitalDocument, 'creator' | 'dateCreated' | 'dateModified' | 'editor' | 'hasDigitalDocumentPermission' | 'identifier' | 'project' | 'text' | 'typeOf' | 'version'> & {
|
|
4
|
+
about: factory.creativeWork.noteDigitalDocument.IAbout;
|
|
5
|
+
provider: factory.creativeWork.noteDigitalDocument.IProviderAsProject | factory.creativeWork.noteDigitalDocument.IProviderAsSeller;
|
|
6
|
+
};
|
|
4
7
|
type IModel = Model<IDocType>;
|
|
5
8
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
9
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
10
|
declare const modelName = "Note";
|
|
8
11
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
12
|
declare function createSchema(): ISchema;
|
|
10
|
-
export { createSchema, IModel, indexes, modelName };
|
|
13
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -18,7 +18,8 @@ const schemaDefinition = {
|
|
|
18
18
|
creator: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
19
19
|
editor: mongoose_1.SchemaTypes.Mixed,
|
|
20
20
|
version: { type: String, required: true },
|
|
21
|
-
typeOf: { type: String, required: true }
|
|
21
|
+
typeOf: { type: String, required: true },
|
|
22
|
+
hasDigitalDocumentPermission: { type: mongoose_1.SchemaTypes.Mixed, required: false } // 2025-09-17~
|
|
22
23
|
};
|
|
23
24
|
const schemaOptions = {
|
|
24
25
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
1
2
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
3
|
import * as factory from '../factory';
|
|
3
4
|
type INoteDigitalDocument = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument;
|
|
@@ -12,12 +13,43 @@ export declare class NoteRepo {
|
|
|
12
13
|
findNotes(params: factory.creativeWork.noteDigitalDocument.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(INoteDigitalDocument & {
|
|
13
14
|
id: string;
|
|
14
15
|
})[]>;
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* メモ識別子をキーにして冪等置換
|
|
18
|
+
*/
|
|
19
|
+
upsertNotesByIdentifier(params: {
|
|
20
|
+
$set: Pick<INoteDigitalDocument, 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'> & {
|
|
21
|
+
id?: never;
|
|
22
|
+
};
|
|
23
|
+
}[], options: {
|
|
24
|
+
/**
|
|
25
|
+
* falseの場合setOnInsertのみ
|
|
26
|
+
* trueの場合setのみ
|
|
27
|
+
*/
|
|
28
|
+
update: boolean;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
bulkWriteResult: BulkWriteResult;
|
|
31
|
+
modifiedNotes: {
|
|
32
|
+
id: string;
|
|
33
|
+
}[];
|
|
34
|
+
} | void>;
|
|
35
|
+
/**
|
|
36
|
+
* 既知のメモIDリストからメモを削除する
|
|
37
|
+
*/
|
|
38
|
+
deleteNotesByIds(params: {
|
|
39
|
+
project: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
ids: string[];
|
|
43
|
+
}): Promise<DeleteResult | void>;
|
|
44
|
+
/**
|
|
45
|
+
* 主題リソースから全メモを削除する
|
|
46
|
+
*/
|
|
47
|
+
deleteNotesByAbout(params: {
|
|
16
48
|
about: {
|
|
17
49
|
id: string;
|
|
18
50
|
typeOf: factory.creativeWork.noteDigitalDocument.IAbout['typeOf'];
|
|
19
51
|
};
|
|
20
|
-
}): Promise<
|
|
52
|
+
}): Promise<DeleteResult>;
|
|
21
53
|
unsetUnnecessaryFields(params: {
|
|
22
54
|
filter: any;
|
|
23
55
|
$unset: any;
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -24,7 +24,8 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
24
24
|
'creator',
|
|
25
25
|
'editor',
|
|
26
26
|
'version',
|
|
27
|
-
'typeOf'
|
|
27
|
+
'typeOf',
|
|
28
|
+
'hasDigitalDocumentPermission'
|
|
28
29
|
];
|
|
29
30
|
/**
|
|
30
31
|
* メモリポジトリ
|
|
@@ -34,7 +35,7 @@ class NoteRepo {
|
|
|
34
35
|
this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
|
|
35
36
|
}
|
|
36
37
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
37
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
38
39
|
const andConditions = [];
|
|
39
40
|
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
40
41
|
if (Array.isArray(idIn)) {
|
|
@@ -64,11 +65,15 @@ class NoteRepo {
|
|
|
64
65
|
if (Array.isArray(aboutOrderNumberIn)) {
|
|
65
66
|
andConditions.push({ 'about.orderNumber': { $exists: true, $in: aboutOrderNumberIn } });
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
+
const aboutTypeOfEq = (_q = (_p = params.about) === null || _p === void 0 ? void 0 : _p.typeOf) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
69
|
+
if (typeof aboutTypeOfEq === 'string') {
|
|
70
|
+
andConditions.push({ 'about.typeOf': { $eq: aboutTypeOfEq } });
|
|
71
|
+
}
|
|
72
|
+
const identifierEq = (_r = params.identifier) === null || _r === void 0 ? void 0 : _r.$eq;
|
|
68
73
|
if (typeof identifierEq === 'string') {
|
|
69
74
|
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
70
75
|
}
|
|
71
|
-
const identifierIn = (
|
|
76
|
+
const identifierIn = (_s = params.identifier) === null || _s === void 0 ? void 0 : _s.$in;
|
|
72
77
|
if (Array.isArray(identifierIn)) {
|
|
73
78
|
andConditions.push({ identifier: { $in: identifierIn } });
|
|
74
79
|
}
|
|
@@ -96,11 +101,103 @@ class NoteRepo {
|
|
|
96
101
|
.skip(params.limit * (page - 1));
|
|
97
102
|
}
|
|
98
103
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
99
|
-
.lean()
|
|
104
|
+
.lean()
|
|
100
105
|
.exec();
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
|
-
|
|
108
|
+
/**
|
|
109
|
+
* メモ識別子をキーにして冪等置換
|
|
110
|
+
*/
|
|
111
|
+
upsertNotesByIdentifier(params, options) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const now = new Date();
|
|
114
|
+
const { update } = options;
|
|
115
|
+
const bulkWriteOps = [];
|
|
116
|
+
const queryFilters = [];
|
|
117
|
+
if (Array.isArray(params)) {
|
|
118
|
+
params.forEach(({ $set }) => {
|
|
119
|
+
const { about, creator, identifier, project, provider, text, version, hasDigitalDocumentPermission } = $set;
|
|
120
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
121
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
122
|
+
}
|
|
123
|
+
if (typeof version !== 'string' || version.length === 0) {
|
|
124
|
+
throw new factory.errors.ArgumentNull('version');
|
|
125
|
+
}
|
|
126
|
+
if (typeof text !== 'string') {
|
|
127
|
+
throw new factory.errors.ArgumentNull('text');
|
|
128
|
+
}
|
|
129
|
+
// リソースのユニークネスを保証するfilter
|
|
130
|
+
const filter = {
|
|
131
|
+
'project.id': { $eq: project.id },
|
|
132
|
+
'about.id': { $eq: about.id },
|
|
133
|
+
identifier: { $eq: identifier },
|
|
134
|
+
version: { $eq: version }
|
|
135
|
+
};
|
|
136
|
+
queryFilters.push({
|
|
137
|
+
'project.id': { $eq: project.id },
|
|
138
|
+
'about.id': { $eq: about.id },
|
|
139
|
+
identifier: { $eq: identifier },
|
|
140
|
+
version: { $eq: version }
|
|
141
|
+
});
|
|
142
|
+
if (update === true) {
|
|
143
|
+
const setFields = Object.assign({ dateModified: now, editor: creator, text }, (Array.isArray(hasDigitalDocumentPermission)) ? { hasDigitalDocumentPermission } : undefined);
|
|
144
|
+
const updateFilter = {
|
|
145
|
+
$set: setFields
|
|
146
|
+
// ...($unset !== undefined) ? { $unset } : undefined
|
|
147
|
+
};
|
|
148
|
+
const updateOne = {
|
|
149
|
+
filter,
|
|
150
|
+
update: updateFilter,
|
|
151
|
+
upsert: false
|
|
152
|
+
};
|
|
153
|
+
bulkWriteOps.push({ updateOne });
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const setOnInsert = Object.assign({ about, creator, identifier, project, provider, version, dateCreated: now, typeOf: factory.creativeWorkType.NoteDigitalDocument, text }, (Array.isArray(hasDigitalDocumentPermission)) ? { hasDigitalDocumentPermission } : undefined);
|
|
157
|
+
const updateFilter = {
|
|
158
|
+
$setOnInsert: setOnInsert
|
|
159
|
+
};
|
|
160
|
+
const updateOne = {
|
|
161
|
+
filter,
|
|
162
|
+
update: updateFilter,
|
|
163
|
+
upsert: true
|
|
164
|
+
};
|
|
165
|
+
bulkWriteOps.push({ updateOne });
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (bulkWriteOps.length > 0) {
|
|
170
|
+
const bulkWriteResult = yield this.noteModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
171
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
172
|
+
const modifiedNotes = yield this.noteModel.find({ $or: queryFilters }, {
|
|
173
|
+
_id: 0,
|
|
174
|
+
id: { $toString: '$_id' }
|
|
175
|
+
})
|
|
176
|
+
.lean()
|
|
177
|
+
.exec();
|
|
178
|
+
return { bulkWriteResult, modifiedNotes };
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 既知のメモIDリストからメモを削除する
|
|
184
|
+
*/
|
|
185
|
+
deleteNotesByIds(params) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const { project, ids } = params;
|
|
188
|
+
if (Array.isArray(ids) && ids.length > 0) {
|
|
189
|
+
return this.noteModel.deleteMany({
|
|
190
|
+
'project.id': { $eq: project.id },
|
|
191
|
+
_id: { $in: ids }
|
|
192
|
+
})
|
|
193
|
+
.exec();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 主題リソースから全メモを削除する
|
|
199
|
+
*/
|
|
200
|
+
deleteNotesByAbout(params) {
|
|
104
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
202
|
return this.noteModel.deleteMany({
|
|
106
203
|
'about.id': { $eq: String(params.about.id) },
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -306,8 +306,8 @@ class TaskRepo {
|
|
|
306
306
|
// resolve uniqueness of identifier(2025-03-27~)
|
|
307
307
|
params, options) {
|
|
308
308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
if (params.data.object.specifyingMethod !== factory.
|
|
310
|
-
throw new factory.errors.NotImplemented(`only ${factory.
|
|
309
|
+
if (params.data.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
|
|
310
|
+
throw new factory.errors.NotImplemented(`only ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id} implemented`);
|
|
311
311
|
}
|
|
312
312
|
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
313
313
|
'project.id': { $eq: params.project.id },
|
|
@@ -63,7 +63,8 @@ function importFromCOA(params) {
|
|
|
63
63
|
object: Object.assign(Object.assign({}, params), { startDate: `${moment(targetImportFrom) // debug(2024-04-26~)
|
|
64
64
|
.toISOString()}/${moment(targetImportThrough)
|
|
65
65
|
.toISOString()}`, superEvent: { location: { branchCode: params.locationBranchCode } }, typeOf: factory.eventType.ScreeningEvent }),
|
|
66
|
-
instrument
|
|
66
|
+
instrument,
|
|
67
|
+
targetCollection: { typeOf: factory.eventType.ScreeningEvent }
|
|
67
68
|
};
|
|
68
69
|
const action = yield repos.action.start(actionAttributes);
|
|
69
70
|
let savedScreeningEventsCount = 0;
|
|
@@ -150,7 +151,8 @@ function processUpdateMovieTheater(params) {
|
|
|
150
151
|
theaterCode: params.locationBranchCode,
|
|
151
152
|
typeOf: 'WebAPI',
|
|
152
153
|
identifier: factory.service.webAPI.Identifier.COA
|
|
153
|
-
}
|
|
154
|
+
},
|
|
155
|
+
targetCollection: { typeOf: factory.placeType.MovieTheater }
|
|
154
156
|
};
|
|
155
157
|
const action = yield repos.action.start(actionAttributes);
|
|
156
158
|
let seller;
|
|
@@ -345,6 +347,12 @@ function createScreeningEvents(params) {
|
|
|
345
347
|
// tslint:disable-next-line:max-func-body-length
|
|
346
348
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
347
349
|
const project = params.project;
|
|
350
|
+
if (typeof params.instrument.begin !== 'string') {
|
|
351
|
+
throw new factory.errors.ArgumentNull('instrument.begin');
|
|
352
|
+
}
|
|
353
|
+
if (typeof params.instrument.end !== 'string') {
|
|
354
|
+
throw new factory.errors.ArgumentNull('instrument.end');
|
|
355
|
+
}
|
|
348
356
|
// COAからイベント取得;
|
|
349
357
|
const schedulesFromCOA = yield repos.masterService.schedule({
|
|
350
358
|
theaterCode: params.instrument.theaterCode,
|
|
@@ -44,7 +44,7 @@ function deleteOrder(params) {
|
|
|
44
44
|
// 経理レポート削除
|
|
45
45
|
yield repos.accountingReport.deleteByOrderNumber({ mainEntity: { orderNumber: order.orderNumber } });
|
|
46
46
|
// メモ削除(2024-02-15~)
|
|
47
|
-
yield repos.note.
|
|
47
|
+
yield repos.note.deleteNotesByAbout({
|
|
48
48
|
about: {
|
|
49
49
|
id: order.id,
|
|
50
50
|
typeOf: factory.order.OrderType.Order
|
|
@@ -34,7 +34,7 @@ function updateEvent4ttts(params) {
|
|
|
34
34
|
// replacee: reservation,
|
|
35
35
|
// replacer: params.attributes, // $unsetもありうるのでいったん保留
|
|
36
36
|
targetCollection: {
|
|
37
|
-
id: params.attributes.identifier,
|
|
37
|
+
// id: params.attributes.identifier,
|
|
38
38
|
typeOf: factory.eventType.ScreeningEvent
|
|
39
39
|
}
|
|
40
40
|
};
|
|
@@ -95,17 +95,18 @@ function deleteById(params, setting) {
|
|
|
95
95
|
// tslint:disable-next-line:max-func-body-length
|
|
96
96
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
97
97
|
var _a;
|
|
98
|
+
const deleteObject = {
|
|
99
|
+
id: params.id,
|
|
100
|
+
typeOf: factory.personType.Person,
|
|
101
|
+
migrate: params.migrate,
|
|
102
|
+
physically: params.physically
|
|
103
|
+
// discontinue(2025-03-29~)
|
|
104
|
+
// ...(typeof params.migratePersonRecipientUrl === 'string')
|
|
105
|
+
// ? { migratePersonRecipientUrl: params.migratePersonRecipientUrl } : undefined
|
|
106
|
+
};
|
|
98
107
|
const deleteMemberAction = {
|
|
99
108
|
agent: params.agent,
|
|
100
|
-
object:
|
|
101
|
-
id: params.id,
|
|
102
|
-
typeOf: factory.personType.Person,
|
|
103
|
-
migrate: params.migrate,
|
|
104
|
-
physically: params.physically
|
|
105
|
-
// discontinue(2025-03-29~)
|
|
106
|
-
// ...(typeof params.migratePersonRecipientUrl === 'string')
|
|
107
|
-
// ? { migratePersonRecipientUrl: params.migratePersonRecipientUrl } : undefined
|
|
108
|
-
},
|
|
109
|
+
object: deleteObject,
|
|
109
110
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
110
111
|
typeOf: factory.actionType.DeleteAction
|
|
111
112
|
};
|
|
@@ -386,7 +387,7 @@ function createDeleteTransactionTask(params) {
|
|
|
386
387
|
executionResults: [],
|
|
387
388
|
data: {
|
|
388
389
|
object: {
|
|
389
|
-
specifyingMethod: factory.
|
|
390
|
+
specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.AgentId,
|
|
390
391
|
agent: { id: params.id },
|
|
391
392
|
project: { id: params.project.id },
|
|
392
393
|
typeOf: transactionType
|
|
@@ -7,6 +7,7 @@ import type { CreativeWorkRepo } from '../../../repo/creativeWork';
|
|
|
7
7
|
import type { EventRepo } from '../../../repo/event';
|
|
8
8
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
9
9
|
import type { MemberRepo } from '../../../repo/member';
|
|
10
|
+
import type { NoteRepo } from '../../../repo/note';
|
|
10
11
|
import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
|
|
11
12
|
import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
12
13
|
import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
@@ -30,6 +31,7 @@ export declare function onResourceDeleted(params: factory.task.onResourceUpdated
|
|
|
30
31
|
hasPOS: HasPOSRepo;
|
|
31
32
|
member: MemberRepo;
|
|
32
33
|
movieTheater: MovieTheaterRepo;
|
|
34
|
+
note: NoteRepo;
|
|
33
35
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
34
36
|
offer: OfferRepo;
|
|
35
37
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -414,6 +414,7 @@ function deleteResourcesByProduct(params) {
|
|
|
414
414
|
try {
|
|
415
415
|
let deleteEventResult;
|
|
416
416
|
let updateOfferResult;
|
|
417
|
+
let deleteNoteResult;
|
|
417
418
|
// 興行を設定されたイベント削除
|
|
418
419
|
deleteEventResult = yield repos.event.deleteManyEventsByItemOfferedId({
|
|
419
420
|
project: { id: params.project.id },
|
|
@@ -424,7 +425,11 @@ function deleteResourcesByProduct(params) {
|
|
|
424
425
|
project: { id: params.project.id },
|
|
425
426
|
addOn: { itemOffered: { id: { $in: [productId] } } }
|
|
426
427
|
});
|
|
427
|
-
|
|
428
|
+
// メモを削除(2025-09-18~)
|
|
429
|
+
deleteNoteResult = yield repos.note.deleteNotesByAbout({
|
|
430
|
+
about: { id: productId, typeOf: params.typeOf }
|
|
431
|
+
});
|
|
432
|
+
deleteResult = { deleteEventResult, updateOfferResult, deleteNoteResult };
|
|
428
433
|
}
|
|
429
434
|
catch (error) {
|
|
430
435
|
try {
|
|
@@ -19,7 +19,7 @@ const deleteOrder_1 = require("../order/deleteOrder");
|
|
|
19
19
|
function deleteTransaction(params) {
|
|
20
20
|
// tslint:disable-next-line:max-func-body-length
|
|
21
21
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
if (params.object.specifyingMethod === factory.
|
|
22
|
+
if (params.object.specifyingMethod === factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.AgentId) {
|
|
23
23
|
// transaction.agent.id指定による取引削除に対応(2023-06-30~)
|
|
24
24
|
yield createDeleteTransactionTasksByAgentId(params)(repos);
|
|
25
25
|
}
|
|
@@ -31,8 +31,8 @@ function deleteTransaction(params) {
|
|
|
31
31
|
function createDeleteTransactionTasksByAgentId(params) {
|
|
32
32
|
// tslint:disable-next-line:max-func-body-length
|
|
33
33
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
if (params.object.specifyingMethod !== factory.
|
|
35
|
-
throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.
|
|
34
|
+
if (params.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.AgentId) {
|
|
35
|
+
throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.AgentId}`);
|
|
36
36
|
}
|
|
37
37
|
const agentIdSpecified = params.object.agent.id;
|
|
38
38
|
// agentIdによる全取引についてDeleteTransactionタスクを作成する
|
|
@@ -61,7 +61,7 @@ function createDeleteTransactionTasksByAgentId(params) {
|
|
|
61
61
|
numberOfTried: 0,
|
|
62
62
|
executionResults: [],
|
|
63
63
|
data: {
|
|
64
|
-
object: Object.assign({ specifyingMethod: factory.
|
|
64
|
+
object: Object.assign({ specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id, id: transaction.id, object: Object.assign(Object.assign({}, (typeof transaction.object.confirmationNumber === 'string')
|
|
65
65
|
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
66
66
|
: undefined), (typeof transaction.object.orderNumber === 'string')
|
|
67
67
|
? { orderNumber: transaction.object.orderNumber }
|
|
@@ -81,7 +81,7 @@ function createDeleteTransactionTasksByAgentId(params) {
|
|
|
81
81
|
numberOfTried: 0,
|
|
82
82
|
executionResults: [],
|
|
83
83
|
data: {
|
|
84
|
-
object: Object.assign({ specifyingMethod: factory.
|
|
84
|
+
object: Object.assign({ specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id, id: transaction.id, object: {
|
|
85
85
|
order: transaction.object.order
|
|
86
86
|
}, project: transaction.project, startDate: transaction.startDate, typeOf: transaction.typeOf }, (transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined)
|
|
87
87
|
}
|
|
@@ -99,7 +99,7 @@ function createDeleteTransactionTasksByAgentId(params) {
|
|
|
99
99
|
numberOfTried: 0,
|
|
100
100
|
executionResults: [],
|
|
101
101
|
data: {
|
|
102
|
-
object: Object.assign({ specifyingMethod: factory.
|
|
102
|
+
object: Object.assign({ specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id, id: transaction.id, object: Object.assign({}, (transaction.object.pendingTransaction !== undefined)
|
|
103
103
|
? { pendingTransaction: transaction.object.pendingTransaction }
|
|
104
104
|
: undefined), project: transaction.project, startDate: transaction.startDate, typeOf: transaction.typeOf }, (transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined)
|
|
105
105
|
}
|
|
@@ -120,8 +120,8 @@ function deleteTransactionById(params) {
|
|
|
120
120
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
121
121
|
var _a;
|
|
122
122
|
if (typeof params.object.specifyingMethod === 'string'
|
|
123
|
-
&& params.object.specifyingMethod !== factory.
|
|
124
|
-
throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.
|
|
123
|
+
&& params.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
|
|
124
|
+
throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id}`);
|
|
125
125
|
}
|
|
126
126
|
const deletingTransactionId = params.object.id;
|
|
127
127
|
if (typeof deletingTransactionId !== 'string' || deletingTransactionId.length === 0) {
|
|
@@ -364,7 +364,7 @@ function deleteMessagesByPlaceOrder(params) {
|
|
|
364
364
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
365
365
|
let deleteResult;
|
|
366
366
|
if (params.transaction.typeOf === factory.transactionType.PlaceOrder
|
|
367
|
-
&& params.transaction.specifyingMethod === factory.
|
|
367
|
+
&& params.transaction.specifyingMethod === factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
|
|
368
368
|
const orderNumber = params.transaction.object.orderNumber;
|
|
369
369
|
if (typeof orderNumber === 'string' && orderNumber.length > 0) {
|
|
370
370
|
const deleteReservationsResult = yield repos.message.deleteByMainEntityOrderNumber({
|
|
@@ -53,7 +53,7 @@ function createTasks(params, setting
|
|
|
53
53
|
numberOfTried: 0,
|
|
54
54
|
executionResults: [],
|
|
55
55
|
data: {
|
|
56
|
-
object: Object.assign({ specifyingMethod: factory.
|
|
56
|
+
object: Object.assign({ specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id, id: transaction.id, object: Object.assign({}, (transaction.object.pendingTransaction !== undefined)
|
|
57
57
|
? { pendingTransaction: transaction.object.pendingTransaction }
|
|
58
58
|
: undefined), project: transaction.project, startDate: transaction.startDate, typeOf: transaction.typeOf }, (transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined)
|
|
59
59
|
}
|
|
@@ -87,7 +87,7 @@ function createTasks(params, setting
|
|
|
87
87
|
numberOfTried: 0,
|
|
88
88
|
executionResults: [],
|
|
89
89
|
data: {
|
|
90
|
-
object: Object.assign({ specifyingMethod: factory.
|
|
90
|
+
object: Object.assign({ specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id, id: transaction.id, object: Object.assign(Object.assign({}, (typeof transaction.object.confirmationNumber === 'string')
|
|
91
91
|
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
92
92
|
: undefined), (typeof transaction.object.orderNumber === 'string')
|
|
93
93
|
? { orderNumber: transaction.object.orderNumber }
|
|
@@ -53,7 +53,7 @@ function createTasks(params, setting
|
|
|
53
53
|
numberOfTried: 0,
|
|
54
54
|
executionResults: [],
|
|
55
55
|
data: {
|
|
56
|
-
object: Object.assign({ specifyingMethod: factory.
|
|
56
|
+
object: Object.assign({ specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id, id: transaction.id, object: {
|
|
57
57
|
order: transaction.object.order
|
|
58
58
|
}, project: transaction.project, startDate: transaction.startDate, typeOf: transaction.typeOf }, (transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined)
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.399.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.399.0-alpha.11",
|
|
15
15
|
"@cinerino/sdk": "12.2.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "22.14.0-alpha.
|
|
118
|
+
"version": "22.14.0-alpha.10"
|
|
119
119
|
}
|
|
@@ -1,132 +0,0 @@
|
|
|
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
|
-
const STORAGE_PERIOD_IN_DAYS = 30;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
15
|
-
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = taskRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
name: { $eq: chevre.factory.taskName.DeleteTransaction },
|
|
20
|
-
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
21
|
-
// runsAt: {
|
|
22
|
-
// $gte: moment()
|
|
23
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
-
// .add(29, 'days')
|
|
25
|
-
// .toDate(),
|
|
26
|
-
// $lte: moment()
|
|
27
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
28
|
-
// .add(365, 'days')
|
|
29
|
-
// .toDate()
|
|
30
|
-
// },
|
|
31
|
-
// _id: { $eq: '6440d8cf9e4983c32ade65de' }
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
_id: 1,
|
|
35
|
-
project: 1,
|
|
36
|
-
data: 1,
|
|
37
|
-
status: 1,
|
|
38
|
-
name: 1,
|
|
39
|
-
runsAt: 1
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
console.log('tasks found');
|
|
43
|
-
|
|
44
|
-
let i = 0;
|
|
45
|
-
let updateCount = 0;
|
|
46
|
-
await cursor.eachAsync(async (doc) => {
|
|
47
|
-
i += 1;
|
|
48
|
-
const deleteTransactionTask: Pick<
|
|
49
|
-
chevre.factory.task.deleteTransaction.ITask,
|
|
50
|
-
'id' | 'project' | 'data' | 'status' | 'name' | 'runsAt'
|
|
51
|
-
> = doc.toObject();
|
|
52
|
-
|
|
53
|
-
let placeOrderTransactionId: string | undefined;
|
|
54
|
-
if (deleteTransactionTask.data.object.typeOf === chevre.factory.transactionType.PlaceOrder) {
|
|
55
|
-
if (
|
|
56
|
-
(typeof deleteTransactionTask.data.object.specifyingMethod !== 'string')
|
|
57
|
-
|| (deleteTransactionTask.data.object.specifyingMethod === chevre.factory.task.deleteTransaction.SpecifyingMethod.Id)
|
|
58
|
-
) {
|
|
59
|
-
placeOrderTransactionId = deleteTransactionTask.data.object.id;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let alreadyMigrated = true;
|
|
64
|
-
let runsAtExpected: moment.Moment | undefined;
|
|
65
|
-
if (typeof placeOrderTransactionId === 'string') {
|
|
66
|
-
console.log(
|
|
67
|
-
'checking transaction...',
|
|
68
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
69
|
-
placeOrderTransactionId
|
|
70
|
-
);
|
|
71
|
-
const placeOrderTransaction = (await transactionRepo.projectFields({
|
|
72
|
-
limit: 1,
|
|
73
|
-
page: 1,
|
|
74
|
-
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
75
|
-
ids: [placeOrderTransactionId],
|
|
76
|
-
inclusion: ['endDate', 'status']
|
|
77
|
-
})).shift();
|
|
78
|
-
if (placeOrderTransaction !== undefined) {
|
|
79
|
-
const { endDate, status } = placeOrderTransaction;
|
|
80
|
-
runsAtExpected = moment(endDate)
|
|
81
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
82
|
-
.add(STORAGE_PERIOD_IN_DAYS, 'days');
|
|
83
|
-
|
|
84
|
-
// if (status !== chevre.factory.transactionStatusType.Confirmed) {
|
|
85
|
-
const taskRunsTooLate = moment(deleteTransactionTask.runsAt)
|
|
86
|
-
.isAfter(runsAtExpected);
|
|
87
|
-
const diff = moment(deleteTransactionTask.runsAt)
|
|
88
|
-
.diff(moment(endDate));
|
|
89
|
-
console.log('taskRunsTooLate?:', taskRunsTooLate, placeOrderTransactionId, endDate, status, diff.toLocaleString());
|
|
90
|
-
if (taskRunsTooLate) {
|
|
91
|
-
alreadyMigrated = false;
|
|
92
|
-
}
|
|
93
|
-
// }
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (alreadyMigrated) {
|
|
98
|
-
console.log(
|
|
99
|
-
'already migrated.',
|
|
100
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
101
|
-
i, updateCount);
|
|
102
|
-
} else {
|
|
103
|
-
console.log(
|
|
104
|
-
'updating...',
|
|
105
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
106
|
-
i, updateCount, runsAtExpected);
|
|
107
|
-
if (runsAtExpected !== undefined) {
|
|
108
|
-
await taskRepo.taskModel.findByIdAndUpdate(
|
|
109
|
-
deleteTransactionTask.id,
|
|
110
|
-
{
|
|
111
|
-
$set: {
|
|
112
|
-
runsAt: runsAtExpected.toDate()
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
.exec();
|
|
117
|
-
}
|
|
118
|
-
updateCount += 1;
|
|
119
|
-
console.log(
|
|
120
|
-
'updated.',
|
|
121
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
122
|
-
i, updateCount, runsAtExpected);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
console.log(i, 'tasks checked');
|
|
127
|
-
console.log(updateCount, 'tasks updated');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
main()
|
|
131
|
-
.then()
|
|
132
|
-
.catch(console.error);
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
|
|
8
|
-
// tslint:disable-next-line:max-func-body-length
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const cursor = taskRepo.getCursor(
|
|
15
|
-
{
|
|
16
|
-
name: { $eq: chevre.factory.taskName.DeleteTransaction },
|
|
17
|
-
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
18
|
-
// runsAt: {
|
|
19
|
-
// $gte: moment()
|
|
20
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
21
|
-
// .add(29, 'days')
|
|
22
|
-
// .toDate(),
|
|
23
|
-
// $lte: moment()
|
|
24
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
25
|
-
// .add(365, 'days')
|
|
26
|
-
// .toDate()
|
|
27
|
-
// },
|
|
28
|
-
// _id: { $eq: '6441bcf04014af2c7d39f6aa' }
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
_id: 1,
|
|
32
|
-
project: 1,
|
|
33
|
-
data: 1,
|
|
34
|
-
status: 1,
|
|
35
|
-
name: 1,
|
|
36
|
-
runsAt: 1
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
console.log('tasks found');
|
|
40
|
-
|
|
41
|
-
let i = 0;
|
|
42
|
-
let updateCount = 0;
|
|
43
|
-
await cursor.eachAsync(async (doc) => {
|
|
44
|
-
i += 1;
|
|
45
|
-
const deleteTransactionTask: Pick<
|
|
46
|
-
chevre.factory.task.deleteTransaction.ITask,
|
|
47
|
-
'id' | 'project' | 'data' | 'status' | 'name' | 'runsAt'
|
|
48
|
-
> = doc.toObject();
|
|
49
|
-
|
|
50
|
-
let dataObject: chevre.factory.task.deleteTransaction.IObjectAsPlaceOrder | undefined;
|
|
51
|
-
if (deleteTransactionTask.data.object.typeOf === chevre.factory.transactionType.PlaceOrder) {
|
|
52
|
-
if (
|
|
53
|
-
(typeof deleteTransactionTask.data.object.specifyingMethod !== 'string')
|
|
54
|
-
|| (deleteTransactionTask.data.object.specifyingMethod === chevre.factory.task.deleteTransaction.SpecifyingMethod.Id)
|
|
55
|
-
) {
|
|
56
|
-
const existingDataObject = deleteTransactionTask.data.object;
|
|
57
|
-
if ((<any>existingDataObject).agent !== undefined) {
|
|
58
|
-
dataObject = {
|
|
59
|
-
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
60
|
-
id: existingDataObject.id,
|
|
61
|
-
object: {
|
|
62
|
-
...(typeof existingDataObject.object.confirmationNumber === 'string')
|
|
63
|
-
? { confirmationNumber: existingDataObject.object.confirmationNumber }
|
|
64
|
-
: undefined,
|
|
65
|
-
...(typeof existingDataObject.object.orderNumber === 'string')
|
|
66
|
-
? { orderNumber: existingDataObject.object.orderNumber }
|
|
67
|
-
: undefined
|
|
68
|
-
},
|
|
69
|
-
project: existingDataObject.project,
|
|
70
|
-
startDate: existingDataObject.startDate,
|
|
71
|
-
typeOf: existingDataObject.typeOf,
|
|
72
|
-
...(existingDataObject.endDate !== undefined) ? { endDate: existingDataObject.endDate } : undefined
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let alreadyMigrated = true;
|
|
79
|
-
if (typeof dataObject?.id === 'string') {
|
|
80
|
-
alreadyMigrated = false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (alreadyMigrated) {
|
|
84
|
-
console.log(
|
|
85
|
-
'already migrated.',
|
|
86
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
87
|
-
i, updateCount);
|
|
88
|
-
} else {
|
|
89
|
-
console.log(
|
|
90
|
-
'updating...',
|
|
91
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
92
|
-
i, updateCount, dataObject);
|
|
93
|
-
if (dataObject !== undefined) {
|
|
94
|
-
await taskRepo.taskModel.findByIdAndUpdate(
|
|
95
|
-
deleteTransactionTask.id,
|
|
96
|
-
{
|
|
97
|
-
$set: {
|
|
98
|
-
'data.object': dataObject
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
{ timestamps: false }
|
|
102
|
-
)
|
|
103
|
-
.exec();
|
|
104
|
-
}
|
|
105
|
-
updateCount += 1;
|
|
106
|
-
console.log(
|
|
107
|
-
'updated.',
|
|
108
|
-
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
109
|
-
i, updateCount);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
console.log(i, 'tasks checked');
|
|
114
|
-
console.log(updateCount, 'tasks updated');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
main()
|
|
118
|
-
.then()
|
|
119
|
-
.catch(console.error);
|