@chevre/domain 22.14.0-alpha.1 → 22.14.0-alpha.11
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/action.d.ts +1 -1
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +65 -47
- package/lib/chevre/repo/note.d.ts +15 -3
- package/lib/chevre/repo/note.js +26 -4
- 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 +3 -2
- 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
- package/example/src/chevre/upsertMoviesByIdentifier.ts +0 -58
|
@@ -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>>;
|
|
@@ -30,9 +30,7 @@ export declare class CreativeWorkRepo {
|
|
|
30
30
|
$unset?: {
|
|
31
31
|
[key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
|
|
32
32
|
};
|
|
33
|
-
}[]
|
|
34
|
-
replace?: boolean;
|
|
35
|
-
}): Promise<{
|
|
33
|
+
}[]): Promise<{
|
|
36
34
|
bulkWriteResult: BulkWriteResult;
|
|
37
35
|
} | void>;
|
|
38
36
|
/**
|
|
@@ -159,7 +159,11 @@ class CreativeWorkRepo {
|
|
|
159
159
|
* コードをキーにして冪等作成
|
|
160
160
|
*/
|
|
161
161
|
// tslint:disable-next-line:max-func-body-length
|
|
162
|
-
upsertMoviesByIdentifier(params
|
|
162
|
+
upsertMoviesByIdentifier(params
|
|
163
|
+
// options?: {
|
|
164
|
+
// replace?: boolean;
|
|
165
|
+
// }
|
|
166
|
+
) {
|
|
163
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
168
|
const bulkWriteOps = [];
|
|
165
169
|
if (Array.isArray(params)) {
|
|
@@ -167,56 +171,70 @@ class CreativeWorkRepo {
|
|
|
167
171
|
params.forEach(({ $set, $unset }) => {
|
|
168
172
|
// リソースのユニークネスを保証するfilter
|
|
169
173
|
const filter = {
|
|
170
|
-
typeOf: $set.typeOf,
|
|
174
|
+
typeOf: { $eq: $set.typeOf },
|
|
171
175
|
'project.id': { $eq: $set.project.id },
|
|
172
176
|
identifier: { $eq: $set.identifier }
|
|
173
177
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// const replaceOne: ReplaceOneModel<factory.creativeWork.movie.ICreativeWork> = {
|
|
178
|
-
// filter,
|
|
179
|
-
// replacement,
|
|
180
|
-
// upsert: true
|
|
181
|
-
// };
|
|
182
|
-
// bulkWriteOps.push({ replaceOne });
|
|
183
|
-
const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
|
|
184
|
-
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
185
|
-
throw new factory.errors.ArgumentNull('identifier');
|
|
186
|
-
}
|
|
187
|
-
const setOnInsert = {
|
|
188
|
-
typeOf,
|
|
189
|
-
project,
|
|
190
|
-
identifier
|
|
191
|
-
};
|
|
192
|
-
const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
193
|
-
const updateOne = {
|
|
194
|
-
filter,
|
|
195
|
-
update: updateFilter,
|
|
196
|
-
upsert: true
|
|
197
|
-
};
|
|
198
|
-
bulkWriteOps.push({ updateOne });
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
const { typeOf, project, identifier, duration, name, additionalProperty, contentRating, headline, distributor, thumbnailUrl, datePublished } = $set, setOnInsertFields = __rest($set, ["typeOf", "project", "identifier", "duration", "name", "additionalProperty", "contentRating", "headline", "distributor", "thumbnailUrl", "datePublished"]);
|
|
202
|
-
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
203
|
-
throw new factory.errors.ArgumentNull('identifier');
|
|
204
|
-
}
|
|
205
|
-
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { typeOf,
|
|
206
|
-
project,
|
|
207
|
-
identifier });
|
|
208
|
-
const updateFilter = {
|
|
209
|
-
$setOnInsert: setOnInsert,
|
|
210
|
-
// 変更可能な属性のみ上書き
|
|
211
|
-
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (name !== undefined) ? { name } : undefined), (contentRating !== undefined) ? { contentRating } : undefined), (duration !== undefined) ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined), (datePublished !== undefined) ? { datePublished } : undefined), (distributor !== undefined) ? { distributor } : undefined), (typeof thumbnailUrl === 'string') ? { thumbnailUrl } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : [])
|
|
212
|
-
};
|
|
213
|
-
const updateOne = {
|
|
214
|
-
filter,
|
|
215
|
-
update: updateFilter,
|
|
216
|
-
upsert: true
|
|
217
|
-
};
|
|
218
|
-
bulkWriteOps.push({ updateOne });
|
|
178
|
+
const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
|
|
179
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
180
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
219
181
|
}
|
|
182
|
+
const setOnInsert = {
|
|
183
|
+
typeOf,
|
|
184
|
+
project,
|
|
185
|
+
identifier
|
|
186
|
+
};
|
|
187
|
+
const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
188
|
+
const updateOne = {
|
|
189
|
+
filter,
|
|
190
|
+
update: updateFilter,
|
|
191
|
+
upsert: true
|
|
192
|
+
};
|
|
193
|
+
bulkWriteOps.push({ updateOne });
|
|
194
|
+
// if (options?.replace === true) {
|
|
195
|
+
// } else {
|
|
196
|
+
// const {
|
|
197
|
+
// typeOf, project, identifier,
|
|
198
|
+
// duration,
|
|
199
|
+
// name,
|
|
200
|
+
// additionalProperty,
|
|
201
|
+
// contentRating,
|
|
202
|
+
// headline,
|
|
203
|
+
// distributor,
|
|
204
|
+
// thumbnailUrl,
|
|
205
|
+
// datePublished,
|
|
206
|
+
// ...setOnInsertFields
|
|
207
|
+
// } = $set;
|
|
208
|
+
// if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
209
|
+
// throw new factory.errors.ArgumentNull('identifier');
|
|
210
|
+
// }
|
|
211
|
+
// const setOnInsert: MatchKeysAndValues<factory.creativeWork.movie.ICreativeWork> = {
|
|
212
|
+
// ...setOnInsertFields,
|
|
213
|
+
// typeOf,
|
|
214
|
+
// project,
|
|
215
|
+
// identifier
|
|
216
|
+
// };
|
|
217
|
+
// const updateFilter: UpdateFilter<factory.creativeWork.movie.ICreativeWork> = {
|
|
218
|
+
// $setOnInsert: setOnInsert,
|
|
219
|
+
// // 変更可能な属性のみ上書き
|
|
220
|
+
// $set: {
|
|
221
|
+
// ...(name !== undefined) ? { name } : undefined,
|
|
222
|
+
// ...(contentRating !== undefined) ? { contentRating } : undefined,
|
|
223
|
+
// ...(duration !== undefined) ? { duration } : undefined,
|
|
224
|
+
// ...(headline !== undefined) ? { headline } : undefined,
|
|
225
|
+
// ...(datePublished !== undefined) ? { datePublished } : undefined,
|
|
226
|
+
// ...(distributor !== undefined) ? { distributor } : undefined,
|
|
227
|
+
// ...(typeof thumbnailUrl === 'string') ? { thumbnailUrl } : undefined,
|
|
228
|
+
// ...(Array.isArray(additionalProperty)) ? { additionalProperty } : []
|
|
229
|
+
// }
|
|
230
|
+
// };
|
|
231
|
+
// const updateOne: UpdateOneModel<factory.creativeWork.movie.ICreativeWork> = {
|
|
232
|
+
// filter,
|
|
233
|
+
// update: updateFilter,
|
|
234
|
+
// upsert: true
|
|
235
|
+
// };
|
|
236
|
+
// bulkWriteOps.push({ updateOne });
|
|
237
|
+
// }
|
|
220
238
|
});
|
|
221
239
|
}
|
|
222
240
|
if (bulkWriteOps.length > 0) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BulkWriteResult } from 'mongodb';
|
|
1
|
+
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
2
2
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
type INoteDigitalDocument = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument;
|
|
@@ -32,12 +32,24 @@ export declare class NoteRepo {
|
|
|
32
32
|
id: string;
|
|
33
33
|
}[];
|
|
34
34
|
} | void>;
|
|
35
|
-
|
|
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: {
|
|
36
48
|
about: {
|
|
37
49
|
id: string;
|
|
38
50
|
typeOf: factory.creativeWork.noteDigitalDocument.IAbout['typeOf'];
|
|
39
51
|
};
|
|
40
|
-
}): Promise<
|
|
52
|
+
}): Promise<DeleteResult>;
|
|
41
53
|
unsetUnnecessaryFields(params: {
|
|
42
54
|
filter: any;
|
|
43
55
|
$unset: any;
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -35,7 +35,7 @@ class NoteRepo {
|
|
|
35
35
|
this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
|
|
36
36
|
}
|
|
37
37
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
38
|
-
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;
|
|
39
39
|
const andConditions = [];
|
|
40
40
|
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
41
41
|
if (Array.isArray(idIn)) {
|
|
@@ -65,11 +65,15 @@ class NoteRepo {
|
|
|
65
65
|
if (Array.isArray(aboutOrderNumberIn)) {
|
|
66
66
|
andConditions.push({ 'about.orderNumber': { $exists: true, $in: aboutOrderNumberIn } });
|
|
67
67
|
}
|
|
68
|
-
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;
|
|
69
73
|
if (typeof identifierEq === 'string') {
|
|
70
74
|
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
71
75
|
}
|
|
72
|
-
const identifierIn = (
|
|
76
|
+
const identifierIn = (_s = params.identifier) === null || _s === void 0 ? void 0 : _s.$in;
|
|
73
77
|
if (Array.isArray(identifierIn)) {
|
|
74
78
|
andConditions.push({ identifier: { $in: identifierIn } });
|
|
75
79
|
}
|
|
@@ -175,7 +179,25 @@ class NoteRepo {
|
|
|
175
179
|
}
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
|
-
|
|
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) {
|
|
179
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
202
|
return this.noteModel.deleteMany({
|
|
181
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,9 +34,10 @@ 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
|
+
instrument: { typeOf: 'Task' }
|
|
40
41
|
};
|
|
41
42
|
const action = yield repos.action.start(actionAttributes);
|
|
42
43
|
let savedEvent;
|
|
@@ -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.12",
|
|
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.11"
|
|
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);
|
|
@@ -1,58 +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
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const result = await creativeWorkRepo.upsertMoviesByIdentifier(
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
$set: {
|
|
18
|
-
id: '',
|
|
19
|
-
identifier: '20231215',
|
|
20
|
-
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
21
|
-
duration: 'PT2H',
|
|
22
|
-
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
|
|
23
|
-
offers: {
|
|
24
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
25
|
-
availabilityEnds: moment('2118-11-04T15:00:00.000Z')
|
|
26
|
-
.toDate(),
|
|
27
|
-
availabilityStarts: moment('2018-11-25T15:00:00.000Z')
|
|
28
|
-
.toDate()
|
|
29
|
-
},
|
|
30
|
-
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
31
|
-
additionalProperty: [
|
|
32
|
-
{
|
|
33
|
-
name: 'posterImage',
|
|
34
|
-
value: 'https://iwiz-movies.c.yimg.jp/c/movies/pict/p/p/90/cb/174755_02.jpg'
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
// headline: 'サブタイトルサブタイトル',
|
|
38
|
-
datePublished: moment('2018-11-04T15:00:00.000Z')
|
|
39
|
-
.toDate(),
|
|
40
|
-
distributor: {
|
|
41
|
-
id: '5e35398a8067a30012dd6717',
|
|
42
|
-
codeValue: '001',
|
|
43
|
-
...{
|
|
44
|
-
distributorType: '001'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
$unset: { headline: 1 }
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
{ replace: true }
|
|
52
|
-
);
|
|
53
|
-
console.log('result:', result);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
main()
|
|
57
|
-
.then(console.log)
|
|
58
|
-
.catch(console.error);
|