@chevre/domain 22.14.0-alpha.17 → 22.14.0-alpha.3
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/{addEventBySchedule.ts → createEventBySchedule.ts} +2 -2
- package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
- package/example/src/chevre/findReservationByCode.ts +1 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +132 -0
- package/example/src/chevre/optimizeDeleteTransactionTasks.ts +119 -0
- package/example/src/chevre/upsertMoviesByIdentifier.ts +58 -0
- package/lib/chevre/repo/accountingReport.d.ts +4 -4
- package/lib/chevre/repo/accountingReport.js +1 -1
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/creativeWork.d.ts +3 -1
- package/lib/chevre/repo/creativeWork.js +47 -65
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +15 -2
- package/lib/chevre/repo/mongoose/schemas/offer/event.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/{productOffer.js → offer/event.js} +53 -9
- package/lib/chevre/repo/offer/event.d.ts +38 -0
- package/lib/chevre/repo/offer/event.js +142 -0
- package/lib/chevre/repo/productOffer.d.ts +65 -60
- package/lib/chevre/repo/productOffer.js +163 -121
- package/lib/chevre/repo/task.js +2 -2
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +53 -68
- package/lib/chevre/service/event.js +2 -10
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
- package/lib/chevre/service/offer/product.d.ts +3 -0
- package/lib/chevre/service/offer/product.js +38 -29
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
- package/lib/chevre/service/reserve/useReservation.js +3 -2
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +2 -0
- package/lib/chevre/service/task/checkResource.d.ts +2 -2
- package/lib/chevre/service/task/checkResource.js +6 -8
- package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
- package/lib/chevre/service/task/createAccountingReport.js +15 -15
- package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -3
- package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
- package/lib/chevre/service/task/deletePerson.js +10 -11
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +5 -7
- package/lib/chevre/service/task/onResourceUpdated.js +2 -1
- package/lib/chevre/service/task/useReservation.js +2 -1
- package/lib/chevre/service/taskHandler.js +0 -2
- 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/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +1 -0
- package/package.json +2 -2
- package/lib/chevre/repo/mongoose/schemas/productOffer.d.ts +0 -36
|
@@ -15,8 +15,8 @@ async function main() {
|
|
|
15
15
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
16
16
|
eventSchedule: { id: '672bf38b5d6d3f5642d658fc' }
|
|
17
17
|
},
|
|
18
|
-
targetCollection: {
|
|
19
|
-
typeOf: chevre.factory.actionType.
|
|
18
|
+
// targetCollection: {},
|
|
19
|
+
typeOf: chevre.factory.actionType.CreateAction
|
|
20
20
|
})(
|
|
21
21
|
{
|
|
22
22
|
connection: mongoose.connection,
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
const IDENTIFIER = 'xxx';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
// const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
|
+
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
let docs = await eventOfferRepo.projectFields(
|
|
16
|
+
{
|
|
17
|
+
project: { id: { $eq: project.id } },
|
|
18
|
+
identifier: { $eq: IDENTIFIER }
|
|
19
|
+
},
|
|
20
|
+
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
21
|
+
);
|
|
22
|
+
console.log('docs:', docs);
|
|
23
|
+
console.log(docs.length, 'docs found');
|
|
24
|
+
|
|
25
|
+
if (docs.length > 0) {
|
|
26
|
+
await eventOfferRepo.deleteById({
|
|
27
|
+
project: { id: docs[0].project.id },
|
|
28
|
+
id: docs[0].id
|
|
29
|
+
});
|
|
30
|
+
console.log('deleted', docs[0].id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await eventOfferRepo.save({
|
|
34
|
+
attributes: {
|
|
35
|
+
identifier: IDENTIFIER,
|
|
36
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
37
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
38
|
+
itemOffered: {
|
|
39
|
+
id: 'xxxxx',
|
|
40
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
41
|
+
},
|
|
42
|
+
seller: {
|
|
43
|
+
id: 'xxxxx',
|
|
44
|
+
typeOf: chevre.factory.organizationType.Organization
|
|
45
|
+
},
|
|
46
|
+
availableAtOrFrom: { id: 'xxx' },
|
|
47
|
+
validFrom: new Date(),
|
|
48
|
+
validThrough: new Date(),
|
|
49
|
+
validForMemberTier: { identifier: 'xxx', typeOf: 'MemberProgramTier' }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
console.log('created.');
|
|
53
|
+
|
|
54
|
+
docs = await await eventOfferRepo.projectFields(
|
|
55
|
+
{
|
|
56
|
+
project: { id: { $eq: project.id } },
|
|
57
|
+
identifier: { $eq: IDENTIFIER }
|
|
58
|
+
},
|
|
59
|
+
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
60
|
+
);
|
|
61
|
+
console.log('docs:', docs);
|
|
62
|
+
console.log(docs.length, 'docs found');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main()
|
|
66
|
+
.then()
|
|
67
|
+
.catch(console.error);
|
|
@@ -22,6 +22,7 @@ async function main() {
|
|
|
22
22
|
|
|
23
23
|
await (await chevre.service.reserve.createService()).verifyToken4reservation({
|
|
24
24
|
project: { id: project.id },
|
|
25
|
+
agent: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
25
26
|
reservationId: RESERVATION_ID,
|
|
26
27
|
ticket: {
|
|
27
28
|
ticketToken: CODE
|
|
@@ -0,0 +1,132 @@
|
|
|
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);
|
|
@@ -0,0 +1,119 @@
|
|
|
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);
|
|
@@ -0,0 +1,58 @@
|
|
|
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);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Connection, PipelineStage } from 'mongoose';
|
|
2
|
+
import { IAccountingReport, IChildReport, IOrder4report } from './mongoose/schemas/accountingReport';
|
|
2
3
|
import * as factory from '../factory';
|
|
3
|
-
import { IDocType } from './mongoose/schemas/accountingReport';
|
|
4
4
|
type IMatchStage = PipelineStage.Match;
|
|
5
|
+
export { IAccountingReport, IChildReport, IOrder4report };
|
|
5
6
|
/**
|
|
6
7
|
* 経理レポートリポジトリ
|
|
7
8
|
*/
|
|
@@ -13,7 +14,7 @@ export declare class AccountingReportRepo {
|
|
|
13
14
|
id?: string;
|
|
14
15
|
};
|
|
15
16
|
}): IMatchStage[];
|
|
16
|
-
syncMainEntity(params:
|
|
17
|
+
syncMainEntity(params: IAccountingReport): Promise<void>;
|
|
17
18
|
/**
|
|
18
19
|
* 注文番号で削除する
|
|
19
20
|
*/
|
|
@@ -33,7 +34,7 @@ export declare class AccountingReportRepo {
|
|
|
33
34
|
mainEntity: {
|
|
34
35
|
orderNumber: string;
|
|
35
36
|
};
|
|
36
|
-
hasPart:
|
|
37
|
+
hasPart: IChildReport;
|
|
37
38
|
}): Promise<void>;
|
|
38
39
|
search(params: factory.report.accountingReport.ISearchConditions & {
|
|
39
40
|
seller?: {
|
|
@@ -45,4 +46,3 @@ export declare class AccountingReportRepo {
|
|
|
45
46
|
$unset: any;
|
|
46
47
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
47
48
|
}
|
|
48
|
-
export {};
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.AccountingReportRepo = void 0;
|
|
13
|
+
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
13
14
|
const errorHandler_1 = require("../errorHandler");
|
|
14
15
|
const factory = require("../factory");
|
|
15
|
-
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
16
16
|
const DEFAULT_SEARCH_LIMIT = 100;
|
|
17
17
|
/**
|
|
18
18
|
* 経理レポートリポジトリ
|
|
@@ -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.
|
|
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<factory.action.update.replace.IAttributes<any, any>> : 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,7 +30,9 @@ export declare class CreativeWorkRepo {
|
|
|
30
30
|
$unset?: {
|
|
31
31
|
[key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
|
|
32
32
|
};
|
|
33
|
-
}[]
|
|
33
|
+
}[], options?: {
|
|
34
|
+
replace?: boolean;
|
|
35
|
+
}): Promise<{
|
|
34
36
|
bulkWriteResult: BulkWriteResult;
|
|
35
37
|
} | void>;
|
|
36
38
|
/**
|
|
@@ -159,11 +159,7 @@ class CreativeWorkRepo {
|
|
|
159
159
|
* コードをキーにして冪等作成
|
|
160
160
|
*/
|
|
161
161
|
// tslint:disable-next-line:max-func-body-length
|
|
162
|
-
upsertMoviesByIdentifier(params
|
|
163
|
-
// options?: {
|
|
164
|
-
// replace?: boolean;
|
|
165
|
-
// }
|
|
166
|
-
) {
|
|
162
|
+
upsertMoviesByIdentifier(params, options) {
|
|
167
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
164
|
const bulkWriteOps = [];
|
|
169
165
|
if (Array.isArray(params)) {
|
|
@@ -171,70 +167,56 @@ class CreativeWorkRepo {
|
|
|
171
167
|
params.forEach(({ $set, $unset }) => {
|
|
172
168
|
// リソースのユニークネスを保証するfilter
|
|
173
169
|
const filter = {
|
|
174
|
-
typeOf:
|
|
170
|
+
typeOf: $set.typeOf,
|
|
175
171
|
'project.id': { $eq: $set.project.id },
|
|
176
172
|
identifier: { $eq: $set.identifier }
|
|
177
173
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
if ((options === null || options === void 0 ? void 0 : options.replace) === true) {
|
|
175
|
+
// updateOneで再実装
|
|
176
|
+
// const replacement: WithoutId<factory.creativeWork.movie.ICreativeWork> = replaceFields;
|
|
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 });
|
|
181
219
|
}
|
|
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
|
-
// }
|
|
238
220
|
});
|
|
239
221
|
}
|
|
240
222
|
if (bulkWriteOps.length > 0) {
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
type
|
|
3
|
+
export type IOrder4report = factory.report.accountingReport.IOrderAsMainEntity;
|
|
4
|
+
export interface IChildReport {
|
|
5
|
+
typeOf: 'Report';
|
|
6
|
+
mainEntity: factory.report.accountingReport.IAction;
|
|
7
|
+
}
|
|
8
|
+
export interface IAccountingReport {
|
|
9
|
+
project: {
|
|
10
|
+
id: string;
|
|
11
|
+
typeOf: factory.organizationType.Project;
|
|
12
|
+
};
|
|
13
|
+
typeOf: 'Report';
|
|
14
|
+
hasPart: IChildReport[];
|
|
15
|
+
mainEntity: IOrder4report;
|
|
16
|
+
}
|
|
4
17
|
type IDocType = IAccountingReport;
|
|
5
18
|
type IModel = Model<IDocType>;
|
|
6
19
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
@@ -8,4 +21,4 @@ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocT
|
|
|
8
21
|
declare const modelName = "AccountingReport";
|
|
9
22
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
10
23
|
declare function createSchema(): ISchema;
|
|
11
|
-
export { createSchema,
|
|
24
|
+
export { createSchema, IModel, indexes, modelName };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../../factory';
|
|
3
|
+
type IDocType = factory.eventOffer.IEventOfferForMemberTier;
|
|
4
|
+
type IModel = Model<IDocType>;
|
|
5
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
|
+
declare const modelName = "Offer.Event";
|
|
8
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|