@chevre/domain 21.32.0-alpha.12 → 21.32.0-alpha.13
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/findCheckAction.ts +37 -0
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +36 -0
- package/lib/chevre/repo/action.d.ts +35 -2
- package/lib/chevre/repo/action.js +95 -5
- package/lib/chevre/service/payment/any.d.ts +6 -0
- package/lib/chevre/service/payment/any.js +24 -9
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const action = await (await chevre.service.payment.any.createService()).findCheckAction({
|
|
15
|
+
project: {
|
|
16
|
+
id: project.id
|
|
17
|
+
},
|
|
18
|
+
sameAs: {
|
|
19
|
+
id: '664db85f9801179aabb046e5'
|
|
20
|
+
},
|
|
21
|
+
purpose: {
|
|
22
|
+
id: '664db8219801179aabb04624'
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
minimize: true
|
|
26
|
+
}
|
|
27
|
+
})({
|
|
28
|
+
action: actionRepo,
|
|
29
|
+
task: taskRepo
|
|
30
|
+
});
|
|
31
|
+
// tslint:disable-next-line:no-null-keyword
|
|
32
|
+
console.dir(action.result?.purchaseNumberAuthResult, { depth: null });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then()
|
|
37
|
+
.catch(console.error);
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const mkknInfos = await actionRepo.searchMkknInfoByCheckMovieTicketResult({
|
|
14
|
+
limit: 10,
|
|
15
|
+
page: 1,
|
|
16
|
+
id: '664db85f9801179aabb046e8',
|
|
17
|
+
project: { id: project.id },
|
|
18
|
+
purpose: { id: '664db8219801179aabb04624' }
|
|
19
|
+
});
|
|
20
|
+
console.log('mkknInfos found', mkknInfos);
|
|
21
|
+
console.log(mkknInfos.length, 'infos found');
|
|
22
|
+
|
|
23
|
+
const ykknInfos = await actionRepo.searchYkknInfoByCheckMovieTicketResult({
|
|
24
|
+
limit: 10,
|
|
25
|
+
page: 1,
|
|
26
|
+
id: '664db85f9801179aabb046e8',
|
|
27
|
+
project: { id: project.id },
|
|
28
|
+
purpose: { id: '664db8219801179aabb04624' }
|
|
29
|
+
});
|
|
30
|
+
console.log('ykknInfos found', ykknInfos);
|
|
31
|
+
console.log(ykknInfos.length, 'infos found');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then()
|
|
36
|
+
.catch(console.error);
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import
|
|
25
|
+
import { factory as surfrockFactory } from '@surfrock/sdk';
|
|
26
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
26
27
|
import * as factory from '../factory';
|
|
27
28
|
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
28
29
|
export type IPayAction = factory.action.trade.pay.IAction;
|
|
@@ -120,7 +121,7 @@ export declare class MongoRepository {
|
|
|
120
121
|
findById<T extends factory.actionType>(params: {
|
|
121
122
|
typeOf: T;
|
|
122
123
|
id: string;
|
|
123
|
-
}): Promise<IAction<T>>;
|
|
124
|
+
}, inclusion?: KeyOfAction[], exclusion?: KeyOfAction[]): Promise<IAction<T>>;
|
|
124
125
|
findPayAction(params: {
|
|
125
126
|
project: {
|
|
126
127
|
id: string;
|
|
@@ -202,6 +203,38 @@ export declare class MongoRepository {
|
|
|
202
203
|
};
|
|
203
204
|
entranceGateIdentifier: string;
|
|
204
205
|
}): Promise<IUseActionCountByOffer[]>;
|
|
206
|
+
searchYkknInfoByCheckMovieTicketResult(filter: {
|
|
207
|
+
limit: number;
|
|
208
|
+
page: number;
|
|
209
|
+
/**
|
|
210
|
+
* 認証アクションID
|
|
211
|
+
*/
|
|
212
|
+
id: string;
|
|
213
|
+
project: {
|
|
214
|
+
id: string;
|
|
215
|
+
};
|
|
216
|
+
purpose: {
|
|
217
|
+
id: string;
|
|
218
|
+
};
|
|
219
|
+
}): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.IValidTicket & {
|
|
220
|
+
knyknrNo: string;
|
|
221
|
+
})[]>;
|
|
222
|
+
searchMkknInfoByCheckMovieTicketResult(filter: {
|
|
223
|
+
limit: number;
|
|
224
|
+
page: number;
|
|
225
|
+
/**
|
|
226
|
+
* 認証アクションID
|
|
227
|
+
*/
|
|
228
|
+
id: string;
|
|
229
|
+
project: {
|
|
230
|
+
id: string;
|
|
231
|
+
};
|
|
232
|
+
purpose: {
|
|
233
|
+
id: string;
|
|
234
|
+
};
|
|
235
|
+
}): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.INvalidTicket & {
|
|
236
|
+
knyknrNo: string;
|
|
237
|
+
})[]>;
|
|
205
238
|
/**
|
|
206
239
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
207
240
|
*/
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
|
+
const mongoose_1 = require("mongoose");
|
|
13
14
|
const factory = require("../factory");
|
|
14
15
|
const action_1 = require("./mongoose/schemas/action");
|
|
15
16
|
const settings_1 = require("../settings");
|
|
@@ -608,13 +609,30 @@ class MongoRepository {
|
|
|
608
609
|
.exec();
|
|
609
610
|
});
|
|
610
611
|
}
|
|
611
|
-
findById(params) {
|
|
612
|
+
findById(params, inclusion, exclusion) {
|
|
612
613
|
return __awaiter(this, void 0, void 0, function* () {
|
|
614
|
+
let projection = {};
|
|
615
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
616
|
+
inclusion.forEach((field) => {
|
|
617
|
+
projection[field] = 1;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
projection = {
|
|
622
|
+
__v: 0,
|
|
623
|
+
createdAt: 0,
|
|
624
|
+
updatedAt: 0
|
|
625
|
+
};
|
|
626
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
627
|
+
exclusion.forEach((field) => {
|
|
628
|
+
projection[field] = 0;
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}
|
|
613
632
|
const doc = yield this.actionModel.findOne({
|
|
614
|
-
typeOf: params.typeOf,
|
|
615
|
-
_id: params.id
|
|
616
|
-
})
|
|
617
|
-
.select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
633
|
+
typeOf: { $eq: params.typeOf },
|
|
634
|
+
_id: { $eq: params.id }
|
|
635
|
+
}, projection)
|
|
618
636
|
.exec();
|
|
619
637
|
if (doc === null) {
|
|
620
638
|
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
@@ -799,6 +817,78 @@ class MongoRepository {
|
|
|
799
817
|
.exec();
|
|
800
818
|
});
|
|
801
819
|
}
|
|
820
|
+
searchYkknInfoByCheckMovieTicketResult(filter) {
|
|
821
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
822
|
+
const filterQuery = {
|
|
823
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(filter.id) },
|
|
824
|
+
'project.id': { $eq: filter.project.id },
|
|
825
|
+
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
826
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
827
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
828
|
+
};
|
|
829
|
+
const projectStage = {
|
|
830
|
+
_id: 0,
|
|
831
|
+
knyknrNo: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.knyknrNo',
|
|
832
|
+
ykknshTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.ykknshTyp',
|
|
833
|
+
eishhshkTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.eishhshkTyp',
|
|
834
|
+
ykknKnshbtsmiNum: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.ykknKnshbtsmiNum',
|
|
835
|
+
knshknhmbiUnip: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.knshknhmbiUnip',
|
|
836
|
+
kijUnip: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo.kijUnip'
|
|
837
|
+
};
|
|
838
|
+
const aggregate = this.actionModel.aggregate([
|
|
839
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut' },
|
|
840
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo' },
|
|
841
|
+
{ $match: filterQuery },
|
|
842
|
+
{ $project: projectStage }
|
|
843
|
+
]);
|
|
844
|
+
if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
845
|
+
const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
846
|
+
aggregate.limit(filter.limit * page)
|
|
847
|
+
.skip(filter.limit * (page - 1));
|
|
848
|
+
}
|
|
849
|
+
return aggregate
|
|
850
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
851
|
+
.exec();
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
searchMkknInfoByCheckMovieTicketResult(filter) {
|
|
855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
856
|
+
const filterQuery = {
|
|
857
|
+
_id: { $eq: new mongoose_1.Types.ObjectId(filter.id) },
|
|
858
|
+
'project.id': { $eq: filter.project.id },
|
|
859
|
+
'purpose.id': { $exists: true, $eq: filter.purpose.id },
|
|
860
|
+
typeOf: { $eq: factory.actionType.CheckAction },
|
|
861
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
862
|
+
};
|
|
863
|
+
const projectStage = {
|
|
864
|
+
_id: 0,
|
|
865
|
+
knyknrNo: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.knyknrNo',
|
|
866
|
+
mkknshTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.mkknshTyp',
|
|
867
|
+
mkknKnshbtsmiNum: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.mkknKnshbtsmiNum',
|
|
868
|
+
mkjyTyp: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.mkjyTyp',
|
|
869
|
+
yykDt: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.yykDt',
|
|
870
|
+
shyJeiDt: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shyJeiDt',
|
|
871
|
+
shyStCd: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shyStCd',
|
|
872
|
+
shyScrnCd: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shyScrnCd',
|
|
873
|
+
shySkhnCd: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shySkhnCd',
|
|
874
|
+
shySkhnNm: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo.shySkhnNm'
|
|
875
|
+
};
|
|
876
|
+
const aggregate = this.actionModel.aggregate([
|
|
877
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut' },
|
|
878
|
+
{ $unwind: '$result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo' },
|
|
879
|
+
{ $match: filterQuery },
|
|
880
|
+
{ $project: projectStage }
|
|
881
|
+
]);
|
|
882
|
+
if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
883
|
+
const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
884
|
+
aggregate.limit(filter.limit * page)
|
|
885
|
+
.skip(filter.limit * (page - 1));
|
|
886
|
+
}
|
|
887
|
+
return aggregate
|
|
888
|
+
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
889
|
+
.exec();
|
|
890
|
+
});
|
|
891
|
+
}
|
|
802
892
|
/**
|
|
803
893
|
* 開始日時を一定期間過ぎたアクションを削除する
|
|
804
894
|
*/
|
|
@@ -562,20 +562,35 @@ function findCheckAction(params) {
|
|
|
562
562
|
if (((_b = authorizeAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
563
563
|
throw new factory.errors.NotFound('Action');
|
|
564
564
|
}
|
|
565
|
-
const authorizeActionWithResult =
|
|
565
|
+
const authorizeActionWithResult = yield repos.action.findById({ id: authorizeAction.id, typeOf: factory.actionType.CheckAction }, [], [
|
|
566
|
+
'agent',
|
|
567
|
+
'purpose',
|
|
568
|
+
'object',
|
|
569
|
+
'startDate',
|
|
570
|
+
'endDate',
|
|
571
|
+
'actionStatus',
|
|
572
|
+
'typeOf',
|
|
573
|
+
'project',
|
|
574
|
+
'sameAs',
|
|
575
|
+
'_id',
|
|
576
|
+
...(params.options.minimize === true)
|
|
577
|
+
? [
|
|
578
|
+
'result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo',
|
|
579
|
+
'result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo'
|
|
580
|
+
]
|
|
581
|
+
: []
|
|
582
|
+
]);
|
|
583
|
+
let purchaseNumberAuthResult;
|
|
584
|
+
if ((authorizeActionWithResult === null || authorizeActionWithResult === void 0 ? void 0 : authorizeActionWithResult.result) !== undefined) {
|
|
585
|
+
purchaseNumberAuthResult = authorizeActionWithResult.result.purchaseNumberAuthResult;
|
|
586
|
+
}
|
|
566
587
|
action = Object.assign(Object.assign({ id: authorizeAction.id, actionStatus: authorizeAction.actionStatus }, (authorizeAction.error !== undefined)
|
|
567
588
|
? {
|
|
568
589
|
error: (Array.isArray(authorizeAction.error))
|
|
569
590
|
? authorizeAction.error[0]
|
|
570
591
|
: authorizeAction.error
|
|
571
592
|
}
|
|
572
|
-
: undefined), (
|
|
573
|
-
? {
|
|
574
|
-
result: {
|
|
575
|
-
purchaseNumberAuthResult: authorizeActionWithResult.result.purchaseNumberAuthResult
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
: undefined);
|
|
593
|
+
: undefined), (purchaseNumberAuthResult !== undefined) ? { result: { purchaseNumberAuthResult } } : undefined);
|
|
579
594
|
}
|
|
580
595
|
}
|
|
581
596
|
return action;
|
|
@@ -622,7 +637,7 @@ function findAcceptAction(params) {
|
|
|
622
637
|
if (((_b = acceptAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
623
638
|
throw new factory.errors.NotFound('Action');
|
|
624
639
|
}
|
|
625
|
-
const acceptActionWithResult =
|
|
640
|
+
const acceptActionWithResult = yield repos.action.findById({ id: acceptAction.id, typeOf: factory.actionType.AcceptAction }, ['result'], []);
|
|
626
641
|
action = Object.assign(Object.assign({ id: acceptAction.id, actionStatus: acceptAction.actionStatus }, (acceptAction.error !== undefined)
|
|
627
642
|
? {
|
|
628
643
|
error: (Array.isArray(acceptAction.error))
|
package/package.json
CHANGED