@chevre/domain 24.0.0-alpha.83 → 24.0.0-alpha.84
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/product.js +0 -3
- package/lib/chevre/repo/transaction.d.ts +4 -4
- package/lib/chevre/repository.d.ts +0 -25
- package/lib/chevre/repository.js +2 -57
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +1 -19
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -31
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +1 -5
- package/lib/chevre/service/task/deletePerson.js +0 -2
- package/lib/chevre/service/task/onResourceDeleted.js +0 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +4 -4
- package/lib/chevre/service.d.ts +0 -12
- package/lib/chevre/service.js +1 -35
- package/package.json +2 -2
- package/lib/chevre/factory/availableProductTypes.d.ts +0 -1
- package/lib/chevre/factory/availableProductTypes.js +0 -8
- package/lib/chevre/repo/account.d.ts +0 -129
- package/lib/chevre/repo/account.js +0 -391
- package/lib/chevre/repo/accountTransaction.d.ts +0 -65
- package/lib/chevre/repo/accountTransaction.js +0 -277
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/account.js +0 -118
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +0 -149
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +0 -144
- package/lib/chevre/repo/permit.d.ts +0 -42
- package/lib/chevre/repo/permit.js +0 -77
- package/lib/chevre/repo/serviceOutput.d.ts +0 -36
- package/lib/chevre/repo/serviceOutput.js +0 -167
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -18
- package/lib/chevre/repo/serviceOutputIdentifier.js +0 -74
- package/lib/chevre/service/account.d.ts +0 -59
- package/lib/chevre/service/account.js +0 -108
- package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -14
- package/lib/chevre/service/accountTransaction/deposit.js +0 -57
- package/lib/chevre/service/accountTransaction/factory.d.ts +0 -10
- package/lib/chevre/service/accountTransaction/factory.js +0 -101
- package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -14
- package/lib/chevre/service/accountTransaction/transfer.js +0 -87
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -14
- package/lib/chevre/service/accountTransaction/withdraw.js +0 -68
- package/lib/chevre/service/accountTransaction.d.ts +0 -20
- package/lib/chevre/service/accountTransaction.js +0 -81
- package/lib/chevre/service/permit.d.ts +0 -45
- package/lib/chevre/service/permit.js +0 -158
- package/lib/chevre/service/product.d.ts +0 -9
- package/lib/chevre/service/product.js +0 -77
- package/lib/chevre/service/task/registerService.d.ts +0 -6
- package/lib/chevre/service/task/registerService.js +0 -22
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.modelName = exports.indexes = void 0;
|
|
4
|
-
exports.createSchema = createSchema;
|
|
5
|
-
const mongoose_1 = require("mongoose");
|
|
6
|
-
const writeConcern_1 = require("../writeConcern");
|
|
7
|
-
const settings_1 = require("../../../settings");
|
|
8
|
-
const modelName = 'ServiceOutput';
|
|
9
|
-
exports.modelName = modelName;
|
|
10
|
-
const schemaDefinition = {
|
|
11
|
-
project: mongoose_1.SchemaTypes.Mixed,
|
|
12
|
-
typeOf: {
|
|
13
|
-
type: String,
|
|
14
|
-
required: true
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const schemaOptions = {
|
|
18
|
-
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
19
|
-
autoCreate: false,
|
|
20
|
-
collection: 'serviceOutputs',
|
|
21
|
-
id: true,
|
|
22
|
-
read: 'primary',
|
|
23
|
-
writeConcern: writeConcern_1.writeConcern,
|
|
24
|
-
strict: false,
|
|
25
|
-
strictQuery: false,
|
|
26
|
-
timestamps: false, // 2024-08-07~
|
|
27
|
-
versionKey: false, // 2024-08-07~
|
|
28
|
-
toJSON: {
|
|
29
|
-
getters: false,
|
|
30
|
-
virtuals: false,
|
|
31
|
-
minimize: false,
|
|
32
|
-
versionKey: false
|
|
33
|
-
},
|
|
34
|
-
toObject: {
|
|
35
|
-
getters: false,
|
|
36
|
-
virtuals: true,
|
|
37
|
-
minimize: false,
|
|
38
|
-
versionKey: false
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* 許可証スキーマ
|
|
43
|
-
*/
|
|
44
|
-
let schema;
|
|
45
|
-
function createSchema() {
|
|
46
|
-
if (schema === undefined) {
|
|
47
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
48
|
-
}
|
|
49
|
-
return schema;
|
|
50
|
-
}
|
|
51
|
-
const indexes = [
|
|
52
|
-
// [ // discontinue(2024-08-07~)
|
|
53
|
-
// { createdAt: 1 },
|
|
54
|
-
// { name: 'searchByCreatedAt' }
|
|
55
|
-
// ],
|
|
56
|
-
// [
|
|
57
|
-
// { updatedAt: 1 },
|
|
58
|
-
// { name: 'searchByUpdatedAt' }
|
|
59
|
-
// ],
|
|
60
|
-
[
|
|
61
|
-
{
|
|
62
|
-
typeOf: 1,
|
|
63
|
-
identifier: 1
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'uniqueIdentifier',
|
|
67
|
-
unique: true,
|
|
68
|
-
partialFilterExpression: {
|
|
69
|
-
identifier: { $exists: true }
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
[
|
|
74
|
-
{ dateIssued: -1 },
|
|
75
|
-
{ name: 'searchByDateIssued' }
|
|
76
|
-
],
|
|
77
|
-
[
|
|
78
|
-
{ 'project.id': 1, dateIssued: -1 },
|
|
79
|
-
{
|
|
80
|
-
name: 'searchByProjectId-v20220721'
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
{ typeOf: 1, dateIssued: -1 },
|
|
85
|
-
{
|
|
86
|
-
name: 'searchByTypeOf'
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
[
|
|
90
|
-
{ identifier: 1, dateIssued: -1 },
|
|
91
|
-
{
|
|
92
|
-
name: 'searchByIdentifier',
|
|
93
|
-
partialFilterExpression: {
|
|
94
|
-
identifier: { $exists: true }
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
[
|
|
99
|
-
{ accessCode: 1, dateIssued: -1 },
|
|
100
|
-
{
|
|
101
|
-
name: 'searchByAccessCode',
|
|
102
|
-
partialFilterExpression: {
|
|
103
|
-
accessCode: { $exists: true }
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
[
|
|
108
|
-
{ 'issuedBy.id': 1, dateIssued: -1 },
|
|
109
|
-
{
|
|
110
|
-
name: 'searchByIssuedById',
|
|
111
|
-
partialFilterExpression: {
|
|
112
|
-
'issuedBy.id': { $exists: true }
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
[
|
|
117
|
-
{ 'issuedThrough.typeOf': 1, dateIssued: -1 },
|
|
118
|
-
{
|
|
119
|
-
name: 'searchByIssuedThroughTypeOf',
|
|
120
|
-
partialFilterExpression: {
|
|
121
|
-
'issuedThrough.typeOf': { $exists: true }
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
[
|
|
126
|
-
{ 'issuedThrough.id': 1, dateIssued: -1 },
|
|
127
|
-
{
|
|
128
|
-
name: 'searchByIssuedThroughId',
|
|
129
|
-
partialFilterExpression: {
|
|
130
|
-
'issuedThrough.id': { $exists: true }
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
],
|
|
134
|
-
[
|
|
135
|
-
{ 'issuedThrough.serviceType.codeValue': 1, productID: 1 },
|
|
136
|
-
{
|
|
137
|
-
name: 'searchByIssuedThroughServiceTypeCodeValue',
|
|
138
|
-
partialFilterExpression: {
|
|
139
|
-
'issuedThrough.serviceType.codeValue': { $exists: true }
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
];
|
|
144
|
-
exports.indexes = indexes;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
2
|
-
import { factory } from '../factory';
|
|
3
|
-
/**
|
|
4
|
-
* 許可証リポジトリ
|
|
5
|
-
*/
|
|
6
|
-
export declare class PermitRepo {
|
|
7
|
-
private readonly serviceOutputModel;
|
|
8
|
-
constructor(connection: Connection);
|
|
9
|
-
findByIdentifier(params: {
|
|
10
|
-
project: {
|
|
11
|
-
id: {
|
|
12
|
-
$eq: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
identifier: {
|
|
16
|
-
$eq: string;
|
|
17
|
-
};
|
|
18
|
-
issuedThrough: {
|
|
19
|
-
typeOf: {
|
|
20
|
-
$eq: factory.product.ProductType;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
}, projection?: any): Promise<factory.product.IServiceOutput>;
|
|
24
|
-
findByIdentifierAndAccessCode(params: {
|
|
25
|
-
project: {
|
|
26
|
-
id: {
|
|
27
|
-
$eq: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
accessCode: {
|
|
31
|
-
$eq: string;
|
|
32
|
-
};
|
|
33
|
-
identifier: {
|
|
34
|
-
$eq: string;
|
|
35
|
-
};
|
|
36
|
-
issuedThrough: {
|
|
37
|
-
typeOf: {
|
|
38
|
-
$eq: factory.product.ProductType;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
}, projection?: any): Promise<factory.product.IServiceOutput>;
|
|
42
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PermitRepo = void 0;
|
|
4
|
-
const serviceOutput_1 = require("./mongoose/schemas/serviceOutput");
|
|
5
|
-
const factory_1 = require("../factory");
|
|
6
|
-
/**
|
|
7
|
-
* 許可証リポジトリ
|
|
8
|
-
*/
|
|
9
|
-
class PermitRepo {
|
|
10
|
-
serviceOutputModel;
|
|
11
|
-
constructor(connection) {
|
|
12
|
-
this.serviceOutputModel = connection.model(serviceOutput_1.modelName, (0, serviceOutput_1.createSchema)());
|
|
13
|
-
}
|
|
14
|
-
async findByIdentifier(params, projection) {
|
|
15
|
-
const query = this.serviceOutputModel.findOne({
|
|
16
|
-
'project.id': {
|
|
17
|
-
$eq: params.project.id.$eq
|
|
18
|
-
},
|
|
19
|
-
identifier: {
|
|
20
|
-
$exists: true,
|
|
21
|
-
$eq: params.identifier.$eq
|
|
22
|
-
},
|
|
23
|
-
...(typeof params.issuedThrough?.typeOf?.$eq === 'string')
|
|
24
|
-
? {
|
|
25
|
-
'issuedThrough.typeOf': {
|
|
26
|
-
$exists: true,
|
|
27
|
-
$eq: params.issuedThrough.typeOf.$eq
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
: undefined
|
|
31
|
-
}, {
|
|
32
|
-
__v: 0,
|
|
33
|
-
createdAt: 0,
|
|
34
|
-
updatedAt: 0,
|
|
35
|
-
...projection
|
|
36
|
-
});
|
|
37
|
-
const doc = await query.exec();
|
|
38
|
-
if (doc === null) {
|
|
39
|
-
throw new factory_1.factory.errors.NotFound(this.serviceOutputModel.modelName);
|
|
40
|
-
}
|
|
41
|
-
return doc.toObject();
|
|
42
|
-
}
|
|
43
|
-
async findByIdentifierAndAccessCode(params, projection) {
|
|
44
|
-
const query = this.serviceOutputModel.findOne({
|
|
45
|
-
'project.id': {
|
|
46
|
-
$eq: params.project.id.$eq
|
|
47
|
-
},
|
|
48
|
-
accessCode: {
|
|
49
|
-
$exists: true,
|
|
50
|
-
$eq: params.accessCode.$eq
|
|
51
|
-
},
|
|
52
|
-
identifier: {
|
|
53
|
-
$exists: true,
|
|
54
|
-
$eq: params.identifier.$eq
|
|
55
|
-
},
|
|
56
|
-
...(typeof params.issuedThrough?.typeOf?.$eq === 'string')
|
|
57
|
-
? {
|
|
58
|
-
'issuedThrough.typeOf': {
|
|
59
|
-
$exists: true,
|
|
60
|
-
$eq: params.issuedThrough.typeOf.$eq
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
: undefined
|
|
64
|
-
}, {
|
|
65
|
-
__v: 0,
|
|
66
|
-
createdAt: 0,
|
|
67
|
-
updatedAt: 0,
|
|
68
|
-
...projection
|
|
69
|
-
});
|
|
70
|
-
const doc = await query.exec();
|
|
71
|
-
if (doc === null) {
|
|
72
|
-
throw new factory_1.factory.errors.NotFound(this.serviceOutputModel.modelName);
|
|
73
|
-
}
|
|
74
|
-
return doc.toObject();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.PermitRepo = PermitRepo;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
2
|
-
import { factory } from '../factory';
|
|
3
|
-
/**
|
|
4
|
-
* サービスアウトプットリポジトリ
|
|
5
|
-
*/
|
|
6
|
-
export declare class ServiceOutputRepo {
|
|
7
|
-
private readonly serviceOutputModel;
|
|
8
|
-
constructor(connection: Connection);
|
|
9
|
-
static CREATE_MONGO_CONDITIONS(params: factory.product.IServiceOutputSearchConditions): any[];
|
|
10
|
-
/**
|
|
11
|
-
* 許可証検索
|
|
12
|
-
*/
|
|
13
|
-
search(params: factory.product.IServiceOutputSearchConditions, projection?: any): Promise<factory.permit.IPermit[]>;
|
|
14
|
-
/**
|
|
15
|
-
* 許可証発行
|
|
16
|
-
*/
|
|
17
|
-
issue(params: factory.permit.IPermit[]): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* 許可証有効化
|
|
20
|
-
*/
|
|
21
|
-
activate(params: {
|
|
22
|
-
typeOf: string;
|
|
23
|
-
identifier: string;
|
|
24
|
-
validFrom: Date;
|
|
25
|
-
validUntil?: Date;
|
|
26
|
-
}): Promise<factory.permit.IPermit>;
|
|
27
|
-
deleteByProject(params: {
|
|
28
|
-
project: {
|
|
29
|
-
id: string;
|
|
30
|
-
};
|
|
31
|
-
}): Promise<void>;
|
|
32
|
-
unsetUnnecessaryFields(params: {
|
|
33
|
-
filter: any;
|
|
34
|
-
$unset: any;
|
|
35
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
36
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServiceOutputRepo = void 0;
|
|
4
|
-
const serviceOutput_1 = require("./mongoose/schemas/serviceOutput");
|
|
5
|
-
const factory_1 = require("../factory");
|
|
6
|
-
const settings_1 = require("../settings");
|
|
7
|
-
/**
|
|
8
|
-
* サービスアウトプットリポジトリ
|
|
9
|
-
*/
|
|
10
|
-
class ServiceOutputRepo {
|
|
11
|
-
serviceOutputModel;
|
|
12
|
-
constructor(connection) {
|
|
13
|
-
this.serviceOutputModel = connection.model(serviceOutput_1.modelName, (0, serviceOutput_1.createSchema)());
|
|
14
|
-
}
|
|
15
|
-
static CREATE_MONGO_CONDITIONS(params) {
|
|
16
|
-
// MongoDB検索条件
|
|
17
|
-
const andConditions = [];
|
|
18
|
-
const projectIdEq = params.project?.id?.$eq;
|
|
19
|
-
if (typeof projectIdEq === 'string') {
|
|
20
|
-
andConditions.push({
|
|
21
|
-
'project.id': {
|
|
22
|
-
$eq: projectIdEq
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const typeOfEq = params.typeOf?.$eq;
|
|
27
|
-
if (typeof typeOfEq === 'string') {
|
|
28
|
-
andConditions.push({
|
|
29
|
-
typeOf: { $eq: typeOfEq }
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const idEq = params.id?.$eq;
|
|
33
|
-
if (typeof idEq === 'string') {
|
|
34
|
-
andConditions.push({
|
|
35
|
-
_id: {
|
|
36
|
-
$eq: idEq
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
const identifierEq = params.identifier?.$eq;
|
|
41
|
-
if (typeof identifierEq === 'string') {
|
|
42
|
-
andConditions.push({
|
|
43
|
-
identifier: {
|
|
44
|
-
$exists: true,
|
|
45
|
-
$eq: identifierEq
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const identifierIn = params.identifier?.$in;
|
|
50
|
-
if (Array.isArray(identifierIn)) {
|
|
51
|
-
andConditions.push({
|
|
52
|
-
identifier: {
|
|
53
|
-
$exists: true,
|
|
54
|
-
$in: identifierIn
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const accessCodeEq = params.accessCode?.$eq;
|
|
59
|
-
if (typeof accessCodeEq === 'string') {
|
|
60
|
-
andConditions.push({
|
|
61
|
-
accessCode: {
|
|
62
|
-
$exists: true,
|
|
63
|
-
$eq: accessCodeEq
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
const issuedByIdEq = params.issuedBy?.id?.$eq;
|
|
68
|
-
if (typeof issuedByIdEq === 'string') {
|
|
69
|
-
andConditions.push({
|
|
70
|
-
'issuedBy.id': {
|
|
71
|
-
$exists: true,
|
|
72
|
-
$eq: issuedByIdEq
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const issuedThroughIdEq = params.issuedThrough?.id?.$eq;
|
|
77
|
-
if (typeof issuedThroughIdEq === 'string') {
|
|
78
|
-
andConditions.push({
|
|
79
|
-
'issuedThrough.id': {
|
|
80
|
-
$exists: true,
|
|
81
|
-
$eq: issuedThroughIdEq
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
const issuedThroughTypeOfEq = params.issuedThrough?.typeOf?.$eq;
|
|
86
|
-
if (typeof issuedThroughTypeOfEq === 'string') {
|
|
87
|
-
andConditions.push({
|
|
88
|
-
'issuedThrough.typeOf': {
|
|
89
|
-
$exists: true,
|
|
90
|
-
$eq: issuedThroughTypeOfEq
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const issuedThroughServiceTypeCodeValueEq = params.issuedThrough?.serviceType?.codeValue?.$eq;
|
|
95
|
-
if (typeof issuedThroughServiceTypeCodeValueEq === 'string') {
|
|
96
|
-
andConditions.push({
|
|
97
|
-
'issuedThrough.serviceType.codeValue': {
|
|
98
|
-
$exists: true,
|
|
99
|
-
$eq: issuedThroughServiceTypeCodeValueEq
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return andConditions;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* 許可証検索
|
|
107
|
-
*/
|
|
108
|
-
async search(params, projection) {
|
|
109
|
-
const conditions = ServiceOutputRepo.CREATE_MONGO_CONDITIONS(params);
|
|
110
|
-
const query = this.serviceOutputModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
|
|
111
|
-
__v: 0,
|
|
112
|
-
createdAt: 0,
|
|
113
|
-
updatedAt: 0,
|
|
114
|
-
...projection
|
|
115
|
-
});
|
|
116
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
117
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
118
|
-
query.limit(params.limit)
|
|
119
|
-
.skip(params.limit * (page - 1));
|
|
120
|
-
}
|
|
121
|
-
/* istanbul ignore else */
|
|
122
|
-
// if (params.sort !== undefined) {
|
|
123
|
-
// query.sort(params.sort);
|
|
124
|
-
// }
|
|
125
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
126
|
-
.exec()
|
|
127
|
-
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* 許可証発行
|
|
131
|
-
*/
|
|
132
|
-
async issue(params) {
|
|
133
|
-
await this.serviceOutputModel.create(params);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* 許可証有効化
|
|
137
|
-
*/
|
|
138
|
-
async activate(params) {
|
|
139
|
-
const doc = await this.serviceOutputModel.findOneAndUpdate({
|
|
140
|
-
typeOf: params.typeOf,
|
|
141
|
-
identifier: params.identifier
|
|
142
|
-
}, {
|
|
143
|
-
validFrom: params.validFrom,
|
|
144
|
-
...(params.validUntil instanceof Date)
|
|
145
|
-
? {
|
|
146
|
-
validUntil: params.validUntil
|
|
147
|
-
}
|
|
148
|
-
: undefined
|
|
149
|
-
})
|
|
150
|
-
.exec();
|
|
151
|
-
if (doc === null) {
|
|
152
|
-
throw new factory_1.factory.errors.NotFound(this.serviceOutputModel.modelName);
|
|
153
|
-
}
|
|
154
|
-
return doc.toObject();
|
|
155
|
-
}
|
|
156
|
-
async deleteByProject(params) {
|
|
157
|
-
await this.serviceOutputModel.deleteMany({
|
|
158
|
-
'project.id': { $eq: params.project.id }
|
|
159
|
-
})
|
|
160
|
-
.exec();
|
|
161
|
-
}
|
|
162
|
-
async unsetUnnecessaryFields(params) {
|
|
163
|
-
return this.serviceOutputModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
164
|
-
.exec();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.ServiceOutputRepo = ServiceOutputRepo;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
2
|
-
/**
|
|
3
|
-
* サービスアウトプット識別子リポジトリ
|
|
4
|
-
*/
|
|
5
|
-
export declare class ServiceOutputIdentifierRepo {
|
|
6
|
-
private readonly counterRepo;
|
|
7
|
-
private readonly settingModel;
|
|
8
|
-
constructor(params: {
|
|
9
|
-
connection: Connection;
|
|
10
|
-
});
|
|
11
|
-
/**
|
|
12
|
-
* タイムスタンプから発行する
|
|
13
|
-
*/
|
|
14
|
-
issueServiceOutputIdentifier(params: {
|
|
15
|
-
startDate: Date;
|
|
16
|
-
}): Promise<string>;
|
|
17
|
-
private findSetting;
|
|
18
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ServiceOutputIdentifierRepo = void 0;
|
|
7
|
-
// import * as cdigit from 'cdigit';
|
|
8
|
-
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
9
|
-
// const fpe = require('node-fpe-v1');
|
|
10
|
-
const factory_1 = require("../factory");
|
|
11
|
-
const transactionNumber_1 = require("../factory/transactionNumber");
|
|
12
|
-
const setting_1 = require("./mongoose/schemas/setting");
|
|
13
|
-
const transactionNumber_2 = require("./mongoose/schemas/transactionNumber");
|
|
14
|
-
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
15
|
-
/**
|
|
16
|
-
* サービスアウトプット識別子リポジトリ
|
|
17
|
-
*/
|
|
18
|
-
class ServiceOutputIdentifierRepo {
|
|
19
|
-
counterRepo;
|
|
20
|
-
settingModel;
|
|
21
|
-
constructor(params) {
|
|
22
|
-
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
23
|
-
this.settingModel = params.connection.model(setting_1.modelName, (0, setting_1.createSchema)());
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* タイムスタンプから発行する
|
|
27
|
-
*/
|
|
28
|
-
async issueServiceOutputIdentifier(params) {
|
|
29
|
-
const { fpeSecret, version } = await this.findSetting();
|
|
30
|
-
const timestamp = (0, moment_timezone_1.default)(params.startDate)
|
|
31
|
-
.valueOf()
|
|
32
|
-
.toString();
|
|
33
|
-
const dataFeedIdentifier = timestamp;
|
|
34
|
-
const dataFeedExpires = (0, moment_timezone_1.default)(params.startDate)
|
|
35
|
-
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
36
|
-
.toDate();
|
|
37
|
-
const incrReply = await this.counterRepo.incrementByMongo({
|
|
38
|
-
identifier: dataFeedIdentifier,
|
|
39
|
-
includedInDataCatalog: { identifier: transactionNumber_2.DataCatalogIdentifier.serviceOutputIdentifier },
|
|
40
|
-
expires: dataFeedExpires
|
|
41
|
-
});
|
|
42
|
-
const transactionFactory = new transactionNumber_1.TransactionNumberFactory({ fpeSecret, version });
|
|
43
|
-
return transactionFactory.generate(timestamp, incrReply);
|
|
44
|
-
// let identifier: string = `${timestamp}${incrReply}`;
|
|
45
|
-
// // checkdigit
|
|
46
|
-
// const cd = cdigit.luhn.compute(identifier);
|
|
47
|
-
// identifier = fpe({ password: cd })
|
|
48
|
-
// .encrypt(identifier);
|
|
49
|
-
// identifier = `${cd}${identifier}`;
|
|
50
|
-
// return identifier;
|
|
51
|
-
}
|
|
52
|
-
async findSetting() {
|
|
53
|
-
const filterQuery = { 'project.id': { $eq: '*' } };
|
|
54
|
-
const projection = {
|
|
55
|
-
_id: 0,
|
|
56
|
-
serviceOutputIdentifier: 1
|
|
57
|
-
};
|
|
58
|
-
const setting = await this.settingModel.findOne(filterQuery, projection)
|
|
59
|
-
.lean()
|
|
60
|
-
.exec();
|
|
61
|
-
if (setting === null || setting.serviceOutputIdentifier === undefined) {
|
|
62
|
-
throw new factory_1.factory.errors.NotFound('setting.serviceOutputIdentifier');
|
|
63
|
-
}
|
|
64
|
-
const { fpeSecret, version } = setting.serviceOutputIdentifier;
|
|
65
|
-
if (typeof fpeSecret !== 'string' || fpeSecret === '') {
|
|
66
|
-
throw new factory_1.factory.errors.NotFound('setting.serviceOutputIdentifier.secret');
|
|
67
|
-
}
|
|
68
|
-
if (typeof version !== 'string' || version === '') {
|
|
69
|
-
throw new factory_1.factory.errors.NotFound('setting.serviceOutputIdentifier.version');
|
|
70
|
-
}
|
|
71
|
-
return { fpeSecret, version };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.ServiceOutputIdentifierRepo = ServiceOutputIdentifierRepo;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 口座サービス
|
|
3
|
-
* 開設、閉鎖等、口座アクション実行など
|
|
4
|
-
*/
|
|
5
|
-
import { factory } from '../factory';
|
|
6
|
-
import type { AccountRepo } from '../repo/account';
|
|
7
|
-
import type { AccountTransactionRepo } from '../repo/accountTransaction';
|
|
8
|
-
export type IOpenOperation<T> = (repos: {
|
|
9
|
-
account: AccountRepo;
|
|
10
|
-
}) => Promise<T>;
|
|
11
|
-
/**
|
|
12
|
-
* 口座を開設する
|
|
13
|
-
*/
|
|
14
|
-
export declare function open(params: {
|
|
15
|
-
project: {
|
|
16
|
-
id: string;
|
|
17
|
-
};
|
|
18
|
-
typeOf: string;
|
|
19
|
-
/**
|
|
20
|
-
* 口座タイプ
|
|
21
|
-
*/
|
|
22
|
-
accountType: string;
|
|
23
|
-
/**
|
|
24
|
-
* 口座番号
|
|
25
|
-
* ユニークになるように、Pecorinoサービス利用側で番号を生成すること
|
|
26
|
-
*/
|
|
27
|
-
accountNumber: string;
|
|
28
|
-
/**
|
|
29
|
-
* 口座名義
|
|
30
|
-
*/
|
|
31
|
-
name: string;
|
|
32
|
-
/**
|
|
33
|
-
* 初期金額
|
|
34
|
-
*/
|
|
35
|
-
initialBalance: number;
|
|
36
|
-
}[]): IOpenOperation<factory.account.IAccount[]>;
|
|
37
|
-
/**
|
|
38
|
-
* 口座を解約する
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* 転送する
|
|
42
|
-
* 確定取引結果から、実際の転送アクションを実行します。
|
|
43
|
-
*/
|
|
44
|
-
export declare function transferMoney(actionAttributes: factory.account.action.moneyTransfer.IAttributes): (repos: {
|
|
45
|
-
account: AccountRepo;
|
|
46
|
-
}) => Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* 転送取消
|
|
49
|
-
* 期限切れ、あるいは、中止された取引から、転送をアクションを取り消します。
|
|
50
|
-
*/
|
|
51
|
-
export declare function cancelMoneyTransfer(params: {
|
|
52
|
-
transaction: {
|
|
53
|
-
typeOf: factory.account.transactionType;
|
|
54
|
-
id: string;
|
|
55
|
-
};
|
|
56
|
-
}): (repos: {
|
|
57
|
-
account: AccountRepo;
|
|
58
|
-
accountTransaction: AccountTransactionRepo;
|
|
59
|
-
}) => Promise<void>;
|