@chevre/domain 22.1.0-alpha.1 → 22.1.0-alpha.2
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/searchOrders.ts +1 -2
- package/example/src/chevre/updateEventPartiallyById.ts +22 -0
- package/lib/chevre/repo/event.d.ts +7 -3
- package/lib/chevre/repo/event.js +36 -25
- package/lib/chevre/repo/order.d.ts +0 -6
- package/lib/chevre/repo/order.js +9 -2
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/confirm.js +1 -1
- package/lib/chevre/service/event.js +6 -6
- package/lib/chevre/service/order/deleteOrder.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +1 -1
- package/lib/chevre/service/payment.js +2 -2
- package/lib/chevre/service/reserve/searchByOrder.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +2 -4
- package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -2
- package/lib/chevre/service/transaction/returnOrder.js +1 -2
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import { chevre } from '../../../lib/index';
|
|
4
|
+
|
|
5
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const result = await eventRepo.updatePartiallyById<chevre.factory.eventType.ScreeningEvent>({
|
|
13
|
+
project: { id: PROJECT_ID },
|
|
14
|
+
id: 'blxd1grxw',
|
|
15
|
+
attributes: { typeOf: chevre.factory.eventType.ScreeningEvent, eventStatus: chevre.factory.eventStatusType.EventScheduled }
|
|
16
|
+
});
|
|
17
|
+
console.log(result);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main()
|
|
21
|
+
.then(console.log)
|
|
22
|
+
.catch(console.error);
|
|
@@ -134,7 +134,7 @@ export declare class EventRepo {
|
|
|
134
134
|
};
|
|
135
135
|
id: string;
|
|
136
136
|
attributes: IAttributes4patchUpdate<T>;
|
|
137
|
-
}): Promise<
|
|
137
|
+
}): Promise<void>;
|
|
138
138
|
/**
|
|
139
139
|
* イベントを保管する
|
|
140
140
|
*/
|
|
@@ -146,7 +146,9 @@ export declare class EventRepo {
|
|
|
146
146
|
*/
|
|
147
147
|
$unset?: IUnset<T>;
|
|
148
148
|
upsert?: boolean;
|
|
149
|
-
}): Promise<
|
|
149
|
+
}): Promise<{
|
|
150
|
+
id: string;
|
|
151
|
+
}>;
|
|
150
152
|
saveMany<T extends factory.eventType>(params: {
|
|
151
153
|
id: string;
|
|
152
154
|
attributes: factory.event.IAttributes<T>;
|
|
@@ -156,7 +158,9 @@ export declare class EventRepo {
|
|
|
156
158
|
save4ttts(params: {
|
|
157
159
|
oldEventId: string;
|
|
158
160
|
attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
|
|
159
|
-
}): Promise<
|
|
161
|
+
}): Promise<{
|
|
162
|
+
id: string;
|
|
163
|
+
}>;
|
|
160
164
|
/**
|
|
161
165
|
* イベントを検索する
|
|
162
166
|
*/
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -683,20 +683,24 @@ class EventRepo {
|
|
|
683
683
|
*/
|
|
684
684
|
updatePartiallyById(params) {
|
|
685
685
|
return __awaiter(this, void 0, void 0, function* () {
|
|
686
|
-
let doc;
|
|
686
|
+
// let doc: Document | null;
|
|
687
687
|
const _a = params.attributes, { typeOf } = _a, updateFields = __rest(_a, ["typeOf"]);
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
if (typeof typeOf !== 'string' || typeOf.length === 0) {
|
|
689
|
+
throw new factory.errors.ArgumentNull('attributes.typeOf');
|
|
690
|
+
}
|
|
691
|
+
const doc = yield this.eventModel.findOneAndUpdate({
|
|
692
|
+
_id: { $eq: params.id },
|
|
690
693
|
'project.id': { $eq: params.project.id },
|
|
691
|
-
typeOf:
|
|
694
|
+
typeOf: { $eq: typeOf }
|
|
692
695
|
}, {
|
|
693
696
|
$set: updateFields
|
|
694
|
-
}, { upsert: false, new:
|
|
697
|
+
}, { upsert: false, new: false, projection: { _id: 1 } })
|
|
698
|
+
.lean()
|
|
695
699
|
.exec();
|
|
696
700
|
if (doc === null) {
|
|
697
701
|
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
698
702
|
}
|
|
699
|
-
return doc.toObject();
|
|
703
|
+
// return doc.toObject(); // void化(2024-07-31~)
|
|
700
704
|
});
|
|
701
705
|
}
|
|
702
706
|
/**
|
|
@@ -704,24 +708,31 @@ class EventRepo {
|
|
|
704
708
|
*/
|
|
705
709
|
save(params) {
|
|
706
710
|
return __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
let savedEventId;
|
|
707
712
|
let doc;
|
|
713
|
+
const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
714
|
+
if (typeof typeOf !== 'string' || typeOf.length === 0) {
|
|
715
|
+
throw new factory.errors.ArgumentNull('attributes.typeOf');
|
|
716
|
+
}
|
|
708
717
|
try {
|
|
709
718
|
if (params.id === undefined) {
|
|
710
719
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
711
720
|
const id = uniqid();
|
|
712
721
|
doc = yield this.eventModel.create(Object.assign(Object.assign({}, params.attributes), { _id: id }));
|
|
722
|
+
savedEventId = id;
|
|
713
723
|
}
|
|
714
724
|
else {
|
|
715
725
|
const upsert = params.upsert === true;
|
|
716
|
-
// 上書き禁止属性を除外(2022-08-24~)
|
|
717
|
-
const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
718
726
|
doc = yield this.eventModel.findOneAndUpdate({
|
|
719
|
-
_id: params.id,
|
|
720
|
-
typeOf:
|
|
721
|
-
}, Object.assign({
|
|
722
|
-
|
|
723
|
-
|
|
727
|
+
_id: { $eq: params.id },
|
|
728
|
+
typeOf: { $eq: typeOf }
|
|
729
|
+
}, Object.assign({
|
|
730
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
731
|
+
$setOnInsert: Object.assign({ typeOf,
|
|
732
|
+
project }, (identifier !== undefined) ? { identifier } : undefined), $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), { upsert, new: true, projection: { _id: 1 } })
|
|
733
|
+
.lean()
|
|
724
734
|
.exec();
|
|
735
|
+
savedEventId = params.id;
|
|
725
736
|
}
|
|
726
737
|
}
|
|
727
738
|
catch (error) {
|
|
@@ -735,7 +746,8 @@ class EventRepo {
|
|
|
735
746
|
if (doc === null) {
|
|
736
747
|
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
737
748
|
}
|
|
738
|
-
return
|
|
749
|
+
return { id: savedEventId }; // optimize(2024-07-31~)
|
|
750
|
+
// return doc.toObject();
|
|
739
751
|
});
|
|
740
752
|
}
|
|
741
753
|
saveMany(params) {
|
|
@@ -787,13 +799,13 @@ class EventRepo {
|
|
|
787
799
|
}
|
|
788
800
|
save4ttts(params) {
|
|
789
801
|
return __awaiter(this, void 0, void 0, function* () {
|
|
790
|
-
let doc;
|
|
802
|
+
// let doc: Document | null;
|
|
791
803
|
const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
792
804
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
793
805
|
const id = uniqid();
|
|
794
|
-
doc = yield this.eventModel.findOneAndUpdate({
|
|
795
|
-
'project.id': { $eq:
|
|
796
|
-
typeOf:
|
|
806
|
+
const doc = yield this.eventModel.findOneAndUpdate({
|
|
807
|
+
'project.id': { $eq: project.id },
|
|
808
|
+
typeOf: { $eq: typeOf },
|
|
797
809
|
// 追加特性をキーに更新
|
|
798
810
|
additionalProperty: {
|
|
799
811
|
$exists: true,
|
|
@@ -802,18 +814,17 @@ class EventRepo {
|
|
|
802
814
|
},
|
|
803
815
|
// upsertの場合、createがありうるので属性を除外しない
|
|
804
816
|
{
|
|
805
|
-
$setOnInsert: Object.assign(
|
|
806
|
-
|
|
807
|
-
? { identifier: params.attributes.identifier } : undefined),
|
|
817
|
+
$setOnInsert: Object.assign({ _id: id, typeOf,
|
|
818
|
+
project }, (identifier !== undefined) ? { identifier } : undefined),
|
|
808
819
|
$set: updateFields
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
}, { upsert: true, new: true })
|
|
820
|
+
}, { upsert: true, new: true, projection: { _id: 1 } })
|
|
821
|
+
.lean()
|
|
812
822
|
.exec();
|
|
813
823
|
if (doc === null) {
|
|
814
824
|
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
815
825
|
}
|
|
816
|
-
return doc.
|
|
826
|
+
return { id: doc._id }; // optimize(2024-07-31~)
|
|
827
|
+
// return <factory.event.IEvent<factory.eventType.ScreeningEvent>>doc.toObject();
|
|
817
828
|
});
|
|
818
829
|
}
|
|
819
830
|
/**
|
|
@@ -155,12 +155,6 @@ export declare class OrderRepo {
|
|
|
155
155
|
inclusion: {
|
|
156
156
|
[key in IKeyOfProjection]?: 1;
|
|
157
157
|
};
|
|
158
|
-
/**
|
|
159
|
-
* @deprecated use inclusion
|
|
160
|
-
*/
|
|
161
|
-
exclusion: {
|
|
162
|
-
[key in IKeyOfProjection]?: 0;
|
|
163
|
-
};
|
|
164
158
|
}): Promise<(IOrderWithoutAcceptedOffers & {
|
|
165
159
|
id: string;
|
|
166
160
|
})[]>;
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -996,7 +996,7 @@ class OrderRepo {
|
|
|
996
996
|
options) {
|
|
997
997
|
var _a;
|
|
998
998
|
return __awaiter(this, void 0, void 0, function* () {
|
|
999
|
-
const { inclusion
|
|
999
|
+
const { inclusion } = options;
|
|
1000
1000
|
const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
1001
1001
|
let useInclusionProjection = false;
|
|
1002
1002
|
let projectStage = {};
|
|
@@ -1022,7 +1022,14 @@ class OrderRepo {
|
|
|
1022
1022
|
});
|
|
1023
1023
|
}
|
|
1024
1024
|
else {
|
|
1025
|
-
|
|
1025
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
1026
|
+
// projectStage = {
|
|
1027
|
+
// __v: 0,
|
|
1028
|
+
// createdAt: 0,
|
|
1029
|
+
// updatedAt: 0,
|
|
1030
|
+
// acceptedOffers: 0, // defaultで隠蔽(2023-12-06~)
|
|
1031
|
+
// ...exclusion
|
|
1032
|
+
// };
|
|
1026
1033
|
}
|
|
1027
1034
|
const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
|
|
1028
1035
|
// .select(projectStage);
|
|
@@ -469,7 +469,7 @@ function confirm(params) {
|
|
|
469
469
|
project: { id: { $eq: transaction.project.id } },
|
|
470
470
|
confirmationNumbers: [confirmationNumber],
|
|
471
471
|
orderNumbers: [orderNumber]
|
|
472
|
-
}, { inclusion: { orderNumber: 1 }
|
|
472
|
+
}, { inclusion: { orderNumber: 1 } });
|
|
473
473
|
if (existingOrders.length === 0) {
|
|
474
474
|
throw new factory.errors.NotFound(factory.order.OrderType.Order);
|
|
475
475
|
}
|
|
@@ -81,7 +81,7 @@ function fixOrderAsPurpose(params, transaction) {
|
|
|
81
81
|
project: { id: { $eq: transaction.project.id } },
|
|
82
82
|
confirmationNumbers: [payPurposeConfirmationNumber],
|
|
83
83
|
orderNumbers: [payPurposeOrderNumber]
|
|
84
|
-
}, { inclusion: { customer: 1, orderNumber: 1, typeOf: 1 }
|
|
84
|
+
}, { inclusion: { customer: 1, orderNumber: 1, typeOf: 1 } });
|
|
85
85
|
order = orders.shift();
|
|
86
86
|
if (order === undefined) {
|
|
87
87
|
throw new factory.errors.NotFound('Order as purpose');
|
|
@@ -787,9 +787,9 @@ function updateEvent4ttts(params) {
|
|
|
787
787
|
}
|
|
788
788
|
});
|
|
789
789
|
const action = yield repos.action.start(actionAttributes);
|
|
790
|
-
let
|
|
790
|
+
let savedEvent;
|
|
791
791
|
try {
|
|
792
|
-
|
|
792
|
+
savedEvent = yield repos.event.save4ttts({
|
|
793
793
|
oldEventId: params.oldEventId,
|
|
794
794
|
attributes: params.attributes
|
|
795
795
|
});
|
|
@@ -804,11 +804,11 @@ function updateEvent4ttts(params) {
|
|
|
804
804
|
throw error;
|
|
805
805
|
}
|
|
806
806
|
// アクション完了
|
|
807
|
-
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id:
|
|
807
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
|
|
808
808
|
yield (0, onEventChanged_1.onEventChanged)({
|
|
809
|
-
id: [
|
|
810
|
-
project: { id:
|
|
811
|
-
typeOf:
|
|
809
|
+
id: [savedEvent.id],
|
|
810
|
+
project: { id: params.project.id },
|
|
811
|
+
typeOf: factory.eventType.ScreeningEvent,
|
|
812
812
|
isNew: false,
|
|
813
813
|
useInform: true
|
|
814
814
|
})({
|
|
@@ -20,7 +20,7 @@ function deleteOrder(params) {
|
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
const orders = yield repos.order.search({
|
|
22
22
|
orderNumbers: [params.object.orderNumber]
|
|
23
|
-
}, { inclusion: { orderDate: 1, project: 1, customer: 1, orderNumber: 1, seller: 1 }
|
|
23
|
+
}, { inclusion: { orderDate: 1, project: 1, customer: 1, orderNumber: 1, seller: 1 } });
|
|
24
24
|
const order = orders.shift();
|
|
25
25
|
if (order === undefined) {
|
|
26
26
|
// すでに削除済
|
|
@@ -281,7 +281,7 @@ function cancelOrderIfExist(params) {
|
|
|
281
281
|
paymentMethodIds: [params.paymentMethodId]
|
|
282
282
|
},
|
|
283
283
|
project: { id: { $eq: params.project.id } }
|
|
284
|
-
}, { inclusion: { confirmationNumber: 1, orderNumber: 1 }
|
|
284
|
+
}, { inclusion: { confirmationNumber: 1, orderNumber: 1 } });
|
|
285
285
|
const orderByPaymentMethodId = ordersByPaymentMethodId.shift();
|
|
286
286
|
if (orderByPaymentMethodId !== undefined) {
|
|
287
287
|
const placeOrderTransaction = yield (0, findPlaceOrderTransaction_1.findPlaceOrderTransaction)({
|
|
@@ -27,7 +27,7 @@ function fixOrderAsPurpose(params, transaction) {
|
|
|
27
27
|
project: { id: { $eq: transaction.project.id } },
|
|
28
28
|
confirmationNumbers: [payPurposeConfirmationNumber],
|
|
29
29
|
orderNumbers: [payPurposeOrderNumber]
|
|
30
|
-
}, { inclusion: { typeOf: 1, confirmationNumber: 1, orderNumber: 1 }
|
|
30
|
+
}, { inclusion: { typeOf: 1, confirmationNumber: 1, orderNumber: 1 } });
|
|
31
31
|
const orderWithoutAcceptedOffers = ordersWithoutAcceptedOffers.shift();
|
|
32
32
|
if (orderWithoutAcceptedOffers === undefined) {
|
|
33
33
|
throw new factory.errors.NotFound('Order as purpose');
|
|
@@ -65,7 +65,7 @@ function payTask2payActionAttributes(params) {
|
|
|
65
65
|
limit: 1,
|
|
66
66
|
page: 1,
|
|
67
67
|
orderNumbers: [params.purpose.object.orderNumber]
|
|
68
|
-
}, { inclusion: { seller: 1, project: 1 }
|
|
68
|
+
}, { inclusion: { seller: 1, project: 1 } })).shift();
|
|
69
69
|
if (order === undefined) {
|
|
70
70
|
throw new factory.errors.NotFound(factory.order.OrderType.Order);
|
|
71
71
|
}
|
|
@@ -44,7 +44,7 @@ function searchByOrder(params) {
|
|
|
44
44
|
limit: 1,
|
|
45
45
|
page: 1,
|
|
46
46
|
orderNumbers: [params.orderNumber]
|
|
47
|
-
}, { inclusion: { customer: 1 }
|
|
47
|
+
}, { inclusion: { customer: 1 } })).shift();
|
|
48
48
|
if (order === undefined) {
|
|
49
49
|
throw new factory.errors.NotFound(factory.order.OrderType.Order);
|
|
50
50
|
}
|
|
@@ -122,7 +122,7 @@ function fixOrderAsPurpose(params) {
|
|
|
122
122
|
page: 1,
|
|
123
123
|
project: { id: { $eq: params.project.id } },
|
|
124
124
|
orderNumbers: [purposeOrderNumber]
|
|
125
|
-
}, { inclusion: { customer: 1, orderNumber: 1, typeOf: 1 }
|
|
125
|
+
}, { inclusion: { customer: 1, orderNumber: 1, typeOf: 1 } });
|
|
126
126
|
order = orders.shift();
|
|
127
127
|
if (order === undefined) {
|
|
128
128
|
throw new factory.errors.NotFound('Order as purpose');
|
|
@@ -70,7 +70,7 @@ function fixOrderAndTransaction(params) {
|
|
|
70
70
|
limit: 1,
|
|
71
71
|
page: 1,
|
|
72
72
|
paymentMethods: { paymentMethodIds: [paymentMethodId] }
|
|
73
|
-
}, { inclusion: { orderNumber: 1 }
|
|
73
|
+
}, { inclusion: { orderNumber: 1 } })).shift();
|
|
74
74
|
if (orderByPaymentMethodId === undefined) {
|
|
75
75
|
throw new factory.errors.NotFound(factory.order.OrderType.Order);
|
|
76
76
|
}
|
|
@@ -407,8 +407,7 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
|
407
407
|
orderNumbers: [String(fromLocation.orderNumber)],
|
|
408
408
|
confirmationNumbers: [String(fromLocation.confirmationNumber)]
|
|
409
409
|
}, {
|
|
410
|
-
inclusion: { identifier: 1, orderStatus: 1 }
|
|
411
|
-
exclusion: {}
|
|
410
|
+
inclusion: { identifier: 1, orderStatus: 1 }
|
|
412
411
|
});
|
|
413
412
|
const order = orders.shift();
|
|
414
413
|
if (order === undefined) {
|
|
@@ -464,8 +463,7 @@ function validateToLocation(project, toLocationBeforeStart, issuedThrough) {
|
|
|
464
463
|
}, {
|
|
465
464
|
inclusion: {
|
|
466
465
|
identifier: 1
|
|
467
|
-
}
|
|
468
|
-
exclusion: {}
|
|
466
|
+
}
|
|
469
467
|
});
|
|
470
468
|
const order = orders.shift();
|
|
471
469
|
if (order === undefined) {
|
|
@@ -131,8 +131,7 @@ function fixOrders(params) {
|
|
|
131
131
|
inclusion: {
|
|
132
132
|
confirmationNumber: 1, dateReturned: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
|
|
133
133
|
paymentMethods: 1, price: 1, project: 1, seller: 1, typeOf: 1
|
|
134
|
-
}
|
|
135
|
-
exclusion: {}
|
|
134
|
+
}
|
|
136
135
|
}
|
|
137
136
|
// {
|
|
138
137
|
// // acceptedOffers: 0, // カスタム返品ポリシーに必要
|
|
@@ -111,8 +111,7 @@ function confirm(params) {
|
|
|
111
111
|
inclusion: {
|
|
112
112
|
confirmationNumber: 1, customer: 1, identifier: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
|
|
113
113
|
orderedItem: 1, paymentMethods: 1, price: 1, priceCurrency: 1, project: 1, seller: 1, typeOf: 1
|
|
114
|
-
}
|
|
115
|
-
exclusion: {}
|
|
114
|
+
}
|
|
116
115
|
});
|
|
117
116
|
// デフォルトEメールメッセージを検索
|
|
118
117
|
let emailMessageOnOrderReturned;
|
package/package.json
CHANGED