@chevre/domain 21.30.0-alpha.32 → 21.30.0-alpha.33
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/code.d.ts +5 -12
- package/lib/chevre/repo/code.js +3 -8
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/service/code.d.ts +1 -2
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +4 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +6 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +3 -1
- package/package.json +3 -3
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
export type IObject = factory.authorization.IObject;
|
|
4
3
|
export type ICode = string;
|
|
5
4
|
type IFindValidOneResult = Pick<factory.authorization.IAuthorization, 'object' | 'typeOf' | 'audience'> & {
|
|
6
5
|
id: string;
|
|
7
6
|
};
|
|
7
|
+
type ISaveParams = Pick<factory.authorization.IAuthorization, 'audience' | 'author' | 'code' | 'issuedBy' | 'project' | 'validFrom' | 'object'> & {
|
|
8
|
+
expiresInSeconds: number;
|
|
9
|
+
};
|
|
10
|
+
type IPublishParams = Pick<ISaveParams, 'audience' | 'author' | 'expiresInSeconds' | 'issuedBy' | 'object' | 'project' | 'validFrom'>;
|
|
8
11
|
/**
|
|
9
12
|
* 承認リポジトリ
|
|
10
13
|
*/
|
|
@@ -15,17 +18,7 @@ export declare class AuthorizationRepo {
|
|
|
15
18
|
/**
|
|
16
19
|
* コードを発行する
|
|
17
20
|
*/
|
|
18
|
-
publish(params:
|
|
19
|
-
project: {
|
|
20
|
-
id: string;
|
|
21
|
-
typeOf: factory.organizationType.Project;
|
|
22
|
-
};
|
|
23
|
-
object: IObject;
|
|
24
|
-
validFrom: Date;
|
|
25
|
-
expiresInSeconds: number;
|
|
26
|
-
audience?: factory.authorization.IAudience;
|
|
27
|
-
author: factory.authorization.IAuthor;
|
|
28
|
-
}[]): Promise<factory.authorization.IAuthorization[]>;
|
|
21
|
+
publish(params: IPublishParams[]): Promise<factory.authorization.IAuthorization[]>;
|
|
29
22
|
/**
|
|
30
23
|
* コードで有効な承認を参照する
|
|
31
24
|
*/
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -83,11 +83,6 @@ class AuthorizationRepo {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
// if (Array.isArray(params.codes)) {
|
|
87
|
-
// andConditions.push({
|
|
88
|
-
// code: { $exists: true, $in: params.codes }
|
|
89
|
-
// });
|
|
90
|
-
// }
|
|
91
86
|
if (params.validFrom instanceof Date) {
|
|
92
87
|
andConditions.push({ validUntil: { $gte: params.validFrom } });
|
|
93
88
|
}
|
|
@@ -194,15 +189,15 @@ class AuthorizationRepo {
|
|
|
194
189
|
save(params) {
|
|
195
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
191
|
if (params.length > 0) {
|
|
197
|
-
const docs = params.map(({ project, code, object, validFrom, expiresInSeconds, audience, author }) => {
|
|
192
|
+
const docs = params.map(({ project, code, object, validFrom, expiresInSeconds, audience, author, issuedBy }) => {
|
|
198
193
|
const validUntil = moment(validFrom)
|
|
199
194
|
.add(expiresInSeconds, 'seconds')
|
|
200
195
|
.toDate();
|
|
201
|
-
return Object.assign({ project, typeOf: 'Authorization', author,
|
|
196
|
+
return Object.assign(Object.assign({ project, typeOf: 'Authorization', author,
|
|
202
197
|
code,
|
|
203
198
|
object,
|
|
204
199
|
validFrom,
|
|
205
|
-
validUntil }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined);
|
|
200
|
+
validUntil }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined), (typeof (issuedBy === null || issuedBy === void 0 ? void 0 : issuedBy.id) === 'string') ? { issuedBy } : undefined);
|
|
206
201
|
});
|
|
207
202
|
const result = yield this.authorizationModel.insertMany(docs, { ordered: false, rawResult: true });
|
|
208
203
|
if (result.insertedCount !== docs.length) {
|
|
@@ -29,7 +29,8 @@ const schemaDefinition = {
|
|
|
29
29
|
required: true
|
|
30
30
|
},
|
|
31
31
|
audience: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
-
author: mongoose_1.SchemaTypes.Mixed
|
|
32
|
+
author: mongoose_1.SchemaTypes.Mixed,
|
|
33
|
+
issuedBy: mongoose_1.SchemaTypes.Mixed // add(2024-05-06~)
|
|
33
34
|
};
|
|
34
35
|
const schemaOptions = {
|
|
35
36
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { MongoRepository as ActionRepo } from '../repo/action';
|
|
2
|
-
import type { AuthorizationRepo } from '../repo/code';
|
|
2
|
+
import type { AuthorizationRepo, ICode } from '../repo/code';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
type IToken = string;
|
|
5
|
-
type ICode = string;
|
|
6
5
|
interface IPayload {
|
|
7
6
|
sub: string;
|
|
8
7
|
aud?: string;
|
|
@@ -14,8 +14,8 @@ exports.verifyToken = exports.getToken = void 0;
|
|
|
14
14
|
* 承認サービス
|
|
15
15
|
*/
|
|
16
16
|
const jwt = require("jsonwebtoken");
|
|
17
|
-
const factory = require("../factory");
|
|
18
17
|
const credentials_1 = require("../credentials");
|
|
18
|
+
const factory = require("../factory");
|
|
19
19
|
const ALGORITHM = 'HS256';
|
|
20
20
|
/**
|
|
21
21
|
* コードをトークンに変換する
|
|
@@ -66,7 +66,10 @@ function confirm(params) {
|
|
|
66
66
|
if (typeof publishCodeExpiresInSeconds === 'number') {
|
|
67
67
|
code = yield (0, publishCode_1.publishCode)({
|
|
68
68
|
project: { id: transaction.project.id },
|
|
69
|
-
object: {
|
|
69
|
+
object: {
|
|
70
|
+
orderNumber,
|
|
71
|
+
seller: { id: transaction.seller.id }
|
|
72
|
+
},
|
|
70
73
|
validFrom: params.result.order.orderDate,
|
|
71
74
|
expiresInSeconds: publishCodeExpiresInSeconds,
|
|
72
75
|
author: { id: transaction.agent.id, typeOf: transaction.agent.typeOf }
|
|
@@ -18,6 +18,7 @@ function publishCode(params) {
|
|
|
18
18
|
typeOf: factory.order.OrderType.Order,
|
|
19
19
|
orderNumber: params.object.orderNumber
|
|
20
20
|
};
|
|
21
|
+
const issuedBy = { id: params.object.seller.id, typeOf: factory.organizationType.Corporation };
|
|
21
22
|
let authorizations;
|
|
22
23
|
try {
|
|
23
24
|
authorizations = yield repos.authorization.publish([{
|
|
@@ -25,7 +26,8 @@ function publishCode(params) {
|
|
|
25
26
|
object: authorizationObject,
|
|
26
27
|
validFrom: params.validFrom,
|
|
27
28
|
expiresInSeconds: params.expiresInSeconds,
|
|
28
|
-
author: params.author
|
|
29
|
+
author: params.author,
|
|
30
|
+
issuedBy // add issuedBy(2024-05-06~)
|
|
29
31
|
}]);
|
|
30
32
|
}
|
|
31
33
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.369.0-alpha.
|
|
14
|
-
"@cinerino/sdk": "5.18.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.369.0-alpha.7",
|
|
14
|
+
"@cinerino/sdk": "5.18.0-alpha.19",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.30.0-alpha.
|
|
113
|
+
"version": "21.30.0-alpha.33"
|
|
114
114
|
}
|