@chevre/domain 22.11.0-alpha.1 → 22.11.0-alpha.10
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/assetTransaction/processReserve.ts +0 -1
- package/example/src/chevre/checkProjectMembers.ts +55 -0
- package/example/src/chevre/orders/searchWithUnwoundAcceptedOffers.ts +73 -0
- package/example/src/chevre/roles/addAdminInventoryManagerRole.ts +50 -0
- package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +132 -0
- package/example/src/chevre/roles/addDefaultPermissionIfNotExists.ts +37 -0
- package/example/src/chevre/roles/addEventOfferPermissionIfNotExists.ts +27 -0
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +39 -6
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +38 -0
- package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +46 -0
- package/example/src/chevre/roles/removePermissionIfExists.ts +39 -0
- package/example/src/chevre/settings/addSettings.ts +32 -0
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +11 -20
- package/example/src/chevre/unsetUnnecessaryFields.ts +8 -5
- package/lib/chevre/index.d.ts +0 -2
- package/lib/chevre/index.js +0 -10
- package/lib/chevre/repo/acceptedOffer.d.ts +3 -1
- package/lib/chevre/repo/acceptedOffer.js +11 -3
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -11
- package/lib/chevre/repo/confirmationNumber.js +15 -54
- package/lib/chevre/repo/identity.d.ts +11 -33
- package/lib/chevre/repo/identity.js +10 -15
- package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
- package/lib/chevre/repo/orderNumber.d.ts +0 -11
- package/lib/chevre/repo/orderNumber.js +13 -51
- package/lib/chevre/repo/role.d.ts +11 -0
- package/lib/chevre/repo/role.js +36 -0
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -4
- package/lib/chevre/repo/serviceOutputIdentifier.js +13 -38
- package/lib/chevre/repo/setting.d.ts +14 -1
- package/lib/chevre/repo/setting.js +15 -0
- package/lib/chevre/repo/stockHolder.js +0 -11
- package/lib/chevre/repo/transactionNumber.d.ts +0 -11
- package/lib/chevre/repo/transactionNumber.js +13 -51
- package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
- package/lib/chevre/repo/transactionNumberCounter.js +34 -29
- package/lib/chevre/service/code.d.ts +5 -28
- package/lib/chevre/service/code.js +3 -79
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +22 -14
- package/lib/chevre/service/task/acceptCOAOffer.js +6 -5
- package/lib/chevre/service/task/authorizePayment.js +7 -6
- package/lib/chevre/service/task/checkMovieTicket.js +4 -3
- package/lib/chevre/service/task/givePointAward.js +1 -1
- package/lib/chevre/service/task/moneyTransfer.js +1 -1
- package/lib/chevre/service/task/publishPaymentUrl.js +6 -7
- package/lib/chevre/service/task/refund.js +1 -1
- package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnPointAward.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +4 -3
- package/lib/chevre/service/validation/validateOrder.js +55 -37
- package/lib/chevre/service.d.ts +0 -4
- package/lib/chevre/service.js +10 -14
- package/package.json +3 -3
- package/example/src/chevre/adminAuth/adminIdentity.ts +0 -38
- package/example/src/chevre/checkActions.ts +0 -65
- package/example/src/chevre/roles/addRoleMembers.ts +0 -75
- package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
- package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
- package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +0 -45
- package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +0 -41
- package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +0 -41
- package/lib/chevre/adminAuth.d.ts +0 -2
- package/lib/chevre/adminAuth.js +0 -6
|
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ServiceOutputIdentifierRepo = void 0;
|
|
13
13
|
const cdigit = require("cdigit");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
+
// import { RedisClientType } from 'redis';
|
|
15
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
17
|
const fpe = require('node-fpe');
|
|
17
|
-
|
|
18
|
+
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
18
19
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
19
20
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
20
21
|
/**
|
|
@@ -22,8 +23,8 @@ const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
|
22
23
|
*/
|
|
23
24
|
class ServiceOutputIdentifierRepo {
|
|
24
25
|
constructor(params) {
|
|
25
|
-
const { connection } = params;
|
|
26
|
-
this.settingModel = connection.model(
|
|
26
|
+
// const { connection } = params;
|
|
27
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
27
28
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
28
29
|
}
|
|
29
30
|
// private static createKey(params: {
|
|
@@ -47,27 +48,15 @@ class ServiceOutputIdentifierRepo {
|
|
|
47
48
|
let dataFeedExpires;
|
|
48
49
|
const dataFeedIdentifier = timestamp;
|
|
49
50
|
let incrReply;
|
|
50
|
-
const useMongoBySettings =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
dataFeedExpires = moment(params.startDate)
|
|
63
|
-
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
64
|
-
.toDate();
|
|
65
|
-
incrReply = yield this.counterRepo.incrementByRedis({
|
|
66
|
-
identifier: dataFeedIdentifier,
|
|
67
|
-
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.serviceOutputIdentifier },
|
|
68
|
-
expires: dataFeedExpires
|
|
69
|
-
});
|
|
70
|
-
}
|
|
51
|
+
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
52
|
+
dataFeedExpires = moment(params.startDate)
|
|
53
|
+
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
54
|
+
.toDate();
|
|
55
|
+
incrReply = yield this.counterRepo.incrementByMongo({
|
|
56
|
+
identifier: dataFeedIdentifier,
|
|
57
|
+
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.serviceOutputIdentifier },
|
|
58
|
+
expires: dataFeedExpires
|
|
59
|
+
});
|
|
71
60
|
let identifier = `${timestamp}${incrReply}`;
|
|
72
61
|
// checkdigit
|
|
73
62
|
const cd = cdigit.luhn.compute(identifier);
|
|
@@ -77,19 +66,5 @@ class ServiceOutputIdentifierRepo {
|
|
|
77
66
|
return identifier;
|
|
78
67
|
});
|
|
79
68
|
}
|
|
80
|
-
useMongoBySettings(params) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
|
|
83
|
-
_id: 0,
|
|
84
|
-
useMongo4transactionNumberFrom: 1
|
|
85
|
-
})
|
|
86
|
-
.lean()
|
|
87
|
-
.exec();
|
|
88
|
-
const useMongo4transactionNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4transactionNumberFrom;
|
|
89
|
-
return useMongo4transactionNumberFrom instanceof Date
|
|
90
|
-
&& moment(params.startDate)
|
|
91
|
-
.isSameOrAfter(moment(useMongo4transactionNumberFrom));
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
69
|
}
|
|
95
70
|
exports.ServiceOutputIdentifierRepo = ServiceOutputIdentifierRepo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import { ISetting } from './mongoose/schemas/setting';
|
|
3
3
|
type IKeyOfProjection = keyof ISetting;
|
|
4
4
|
export { ISetting };
|
|
@@ -23,4 +23,17 @@ export declare class SettingRepo {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
}, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onResourceUpdated' | 'defaultSenderEmail' | 'useInformResourceTypes' | 'userPoolIdNew' | 'userPoolIdOld' | 'storage' | 'quota' | 'triggerWebhook' | 'waiter'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
26
|
+
updateByProject4migration(filter: {
|
|
27
|
+
project: {
|
|
28
|
+
id: {
|
|
29
|
+
$eq: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}, update: {
|
|
33
|
+
$set: any;
|
|
34
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
35
|
+
unsetUnnecessaryFields(params: {
|
|
36
|
+
filter: FilterQuery<ISetting>;
|
|
37
|
+
$unset: any;
|
|
38
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
26
39
|
}
|
|
@@ -56,5 +56,20 @@ class SettingRepo {
|
|
|
56
56
|
.exec();
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
+
updateByProject4migration(filter, update) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const { $set } = update;
|
|
62
|
+
return this.settingModel.updateOne({ 'project.id': { $eq: filter.project.id.$eq } }, {
|
|
63
|
+
$set
|
|
64
|
+
})
|
|
65
|
+
.exec();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
unsetUnnecessaryFields(params) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
return this.settingModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
71
|
+
.exec();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
59
74
|
}
|
|
60
75
|
exports.SettingRepo = SettingRepo;
|
|
@@ -287,17 +287,6 @@ class StockHolderRepo {
|
|
|
287
287
|
throw new factory.errors.Argument('startDate', 'must be Date');
|
|
288
288
|
}
|
|
289
289
|
let useMongoose = false;
|
|
290
|
-
// useMongoAsStockHolder設定有の場合のみmongo利用(2025-04-18~)
|
|
291
|
-
// const useMongoAsStockHolderBySettings = await this.useMongoAsStockHolderBySettings({ project: { id: params.project.id } });
|
|
292
|
-
// if (useMongoAsStockHolderBySettings) {
|
|
293
|
-
// const redisKeyExists = await this.redisKeyExists(params);
|
|
294
|
-
// if (redisKeyExists) {
|
|
295
|
-
// useMongoose = false;
|
|
296
|
-
// } else {
|
|
297
|
-
// // redis keyが存在しなければmongo利用
|
|
298
|
-
// useMongoose = true;
|
|
299
|
-
// }
|
|
300
|
-
// }
|
|
301
290
|
// always use mongo(2025-05-21~)
|
|
302
291
|
const redisKeyExists = yield this.redisKeyExists(params);
|
|
303
292
|
if (redisKeyExists) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
|
-
import { RedisClientType } from 'redis';
|
|
3
|
-
import { ISetting } from './mongoose/schemas/setting';
|
|
4
2
|
interface IPublishResult {
|
|
5
3
|
transactionNumber: string;
|
|
6
4
|
}
|
|
@@ -8,10 +6,8 @@ interface IPublishResult {
|
|
|
8
6
|
* 取引番号リポジトリ
|
|
9
7
|
*/
|
|
10
8
|
export declare class TransactionNumberRepo {
|
|
11
|
-
private readonly settingModel;
|
|
12
9
|
private readonly counterRepo;
|
|
13
10
|
constructor(params: {
|
|
14
|
-
redisClient: RedisClientType;
|
|
15
11
|
connection: Connection;
|
|
16
12
|
});
|
|
17
13
|
/**
|
|
@@ -20,12 +16,5 @@ export declare class TransactionNumberRepo {
|
|
|
20
16
|
publishByTimestamp(params: {
|
|
21
17
|
startDate: Date;
|
|
22
18
|
}): Promise<IPublishResult>;
|
|
23
|
-
/**
|
|
24
|
-
* DB移行時のみに使用目的の設定更新
|
|
25
|
-
*/
|
|
26
|
-
setUseMongo4transactionNumberFrom(params: {
|
|
27
|
-
useMongo4transactionNumberFrom: Date;
|
|
28
|
-
}): Promise<Pick<ISetting, "useMongo4transactionNumberFrom"> | null>;
|
|
29
|
-
private useMongoBySettings;
|
|
30
19
|
}
|
|
31
20
|
export {};
|
|
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.TransactionNumberRepo = void 0;
|
|
13
13
|
const cdigit = require("cdigit");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
+
// import { RedisClientType } from 'redis';
|
|
15
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
17
|
const fpe = require('node-fpe');
|
|
17
|
-
|
|
18
|
+
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
18
19
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
19
20
|
const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
20
21
|
/**
|
|
@@ -22,8 +23,8 @@ const transactionNumberCounter_1 = require("./transactionNumberCounter");
|
|
|
22
23
|
*/
|
|
23
24
|
class TransactionNumberRepo {
|
|
24
25
|
constructor(params) {
|
|
25
|
-
const { connection } = params;
|
|
26
|
-
this.settingModel = connection.model(
|
|
26
|
+
// const { connection } = params;
|
|
27
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
27
28
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
28
29
|
}
|
|
29
30
|
// private static createKey(params: {
|
|
@@ -47,27 +48,15 @@ class TransactionNumberRepo {
|
|
|
47
48
|
let dataFeedExpires;
|
|
48
49
|
const dataFeedIdentifier = timestamp;
|
|
49
50
|
let incrReply;
|
|
50
|
-
const useMongoBySettings =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
dataFeedExpires = moment(params.startDate)
|
|
63
|
-
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
64
|
-
.toDate();
|
|
65
|
-
incrReply = yield this.counterRepo.incrementByRedis({
|
|
66
|
-
identifier: dataFeedIdentifier,
|
|
67
|
-
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.transactionNumber },
|
|
68
|
-
expires: dataFeedExpires
|
|
69
|
-
});
|
|
70
|
-
}
|
|
51
|
+
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
52
|
+
dataFeedExpires = moment(params.startDate)
|
|
53
|
+
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
54
|
+
.toDate();
|
|
55
|
+
incrReply = yield this.counterRepo.incrementByMongo({
|
|
56
|
+
identifier: dataFeedIdentifier,
|
|
57
|
+
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.transactionNumber },
|
|
58
|
+
expires: dataFeedExpires
|
|
59
|
+
});
|
|
71
60
|
let transactionNumber = `${timestamp}${incrReply}`;
|
|
72
61
|
// checkdigit
|
|
73
62
|
const cd = cdigit.luhn.compute(transactionNumber);
|
|
@@ -77,32 +66,5 @@ class TransactionNumberRepo {
|
|
|
77
66
|
return { transactionNumber };
|
|
78
67
|
});
|
|
79
68
|
}
|
|
80
|
-
/**
|
|
81
|
-
* DB移行時のみに使用目的の設定更新
|
|
82
|
-
*/
|
|
83
|
-
setUseMongo4transactionNumberFrom(params) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const { useMongo4transactionNumberFrom } = params;
|
|
86
|
-
return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
|
|
87
|
-
$set: { useMongo4transactionNumberFrom }
|
|
88
|
-
}, { projection: { _id: 0, useMongo4transactionNumberFrom: 1 } })
|
|
89
|
-
.lean()
|
|
90
|
-
.exec();
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
useMongoBySettings(params) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
|
|
96
|
-
_id: 0,
|
|
97
|
-
useMongo4transactionNumberFrom: 1
|
|
98
|
-
})
|
|
99
|
-
.lean()
|
|
100
|
-
.exec();
|
|
101
|
-
const useMongo4transactionNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4transactionNumberFrom;
|
|
102
|
-
return useMongo4transactionNumberFrom instanceof Date
|
|
103
|
-
&& moment(params.startDate)
|
|
104
|
-
.isSameOrAfter(moment(useMongo4transactionNumberFrom));
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
69
|
}
|
|
108
70
|
exports.TransactionNumberRepo = TransactionNumberRepo;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
|
-
import { RedisClientType } from 'redis';
|
|
3
2
|
import { DataCatalogIdentifier } from './mongoose/schemas/transactionNumber';
|
|
4
3
|
/**
|
|
5
4
|
* 取引番号カウンターリポジトリ
|
|
6
5
|
*/
|
|
7
6
|
export declare class TransactionNumberCounterRepo {
|
|
8
|
-
private readonly redisClient;
|
|
9
7
|
private readonly transactionNumberModel;
|
|
10
8
|
constructor(params: {
|
|
11
|
-
redisClient: RedisClientType;
|
|
12
9
|
connection: Connection;
|
|
13
10
|
});
|
|
14
|
-
incrementByRedis(params: {
|
|
15
|
-
identifier: string;
|
|
16
|
-
includedInDataCatalog: {
|
|
17
|
-
identifier: DataCatalogIdentifier;
|
|
18
|
-
};
|
|
19
|
-
expires: Date;
|
|
20
|
-
}): Promise<number>;
|
|
21
11
|
incrementByMongo(params: {
|
|
22
12
|
identifier: string;
|
|
23
13
|
includedInDataCatalog: {
|
|
@@ -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.TransactionNumberCounterRepo = void 0;
|
|
13
|
+
// import { RedisClientType } from 'redis';
|
|
13
14
|
const errorHandler_1 = require("../errorHandler");
|
|
14
15
|
const factory = require("../factory");
|
|
15
16
|
const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
|
|
@@ -19,37 +20,41 @@ const MAX_RETRY_INCREMENT = 1;
|
|
|
19
20
|
*/
|
|
20
21
|
class TransactionNumberCounterRepo {
|
|
21
22
|
constructor(params) {
|
|
22
|
-
const {
|
|
23
|
-
this.redisClient = redisClient;
|
|
23
|
+
const { connection } = params;
|
|
24
|
+
// this.redisClient = redisClient;
|
|
24
25
|
this.transactionNumberModel = connection.model(transactionNumber_1.modelName, (0, transactionNumber_1.createSchema)());
|
|
25
26
|
}
|
|
26
|
-
incrementByRedis(params
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
// public async incrementByRedis(params: {
|
|
28
|
+
// identifier: string;
|
|
29
|
+
// includedInDataCatalog: {
|
|
30
|
+
// identifier: DataCatalogIdentifier;
|
|
31
|
+
// };
|
|
32
|
+
// expires: Date;
|
|
33
|
+
// }): Promise<number> {
|
|
34
|
+
// // const now = moment();
|
|
35
|
+
// const { expires } = params;
|
|
36
|
+
// const key = `${params.includedInDataCatalog.identifier}:${params.identifier}`;
|
|
37
|
+
// // const TTL = moment(expires)
|
|
38
|
+
// // .diff(now, 'seconds');
|
|
39
|
+
// const [incrReply, expireAtReply] = await this.redisClient.multi()
|
|
40
|
+
// .incr(key)
|
|
41
|
+
// // .expire(key, TTL)
|
|
42
|
+
// .expireAt(key, expires)
|
|
43
|
+
// .exec();
|
|
44
|
+
// // tslint:disable-next-line:no-single-line-block-comment
|
|
45
|
+
// /* istanbul ignore else: please write tests */
|
|
46
|
+
// if (typeof incrReply !== 'number') {
|
|
47
|
+
// // 基本的にありえないフロー
|
|
48
|
+
// throw new factory.errors.Internal('transaction number not incremented unexpectedly');
|
|
49
|
+
// }
|
|
50
|
+
// // expireAtReplyの検証も追加する(2023-04-19~)
|
|
51
|
+
// const expiredSet = expireAtReply === 1 || <any>expireAtReply === true;
|
|
52
|
+
// if (!expiredSet) {
|
|
53
|
+
// // 基本的にありえないフロー
|
|
54
|
+
// throw new factory.errors.Internal('transaction number expiration not set unexpectedly');
|
|
55
|
+
// }
|
|
56
|
+
// return incrReply;
|
|
57
|
+
// }
|
|
53
58
|
incrementByMongo(params) {
|
|
54
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
60
|
var _a;
|
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type IToken = string;
|
|
6
|
-
interface IPayload extends Pick<factory.clientUser.IClientUser, 'aud' | 'exp' | 'iat' | 'iss' | 'sub' | 'token_use' | 'typ' | 'version'> {
|
|
7
|
-
version: string;
|
|
8
|
-
typ: string;
|
|
9
|
-
jti?: string;
|
|
10
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 承認サービス
|
|
3
|
+
* ひとまず不要なので廃止(2025-07-18~)
|
|
4
|
+
*/
|
|
11
5
|
/**
|
|
12
6
|
* コードをトークンに変換する
|
|
13
7
|
*/
|
|
14
|
-
|
|
15
|
-
agent: {
|
|
16
|
-
id: string;
|
|
17
|
-
typeOf: factory.creativeWorkType.SoftwareApplication | factory.creativeWorkType.WebApplication | factory.personType.Person;
|
|
18
|
-
};
|
|
19
|
-
project: {
|
|
20
|
-
id: string;
|
|
21
|
-
};
|
|
22
|
-
code: string;
|
|
23
|
-
expiresIn: number;
|
|
24
|
-
}): (repos: {
|
|
25
|
-
authorization: AuthorizationRepo;
|
|
26
|
-
jwtSetting: JWTSettingRepo;
|
|
27
|
-
ticket: TicketRepo;
|
|
28
|
-
}) => Promise<{
|
|
29
|
-
token: IToken;
|
|
30
|
-
}>;
|
|
31
|
-
export { IPayload, getToken };
|
|
8
|
+
export {};
|
|
@@ -1,83 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getToken = getToken;
|
|
13
2
|
/**
|
|
14
3
|
* 承認サービス
|
|
4
|
+
* ひとまず不要なので廃止(2025-07-18~)
|
|
15
5
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* コードをトークンに変換する
|
|
20
|
-
*/
|
|
21
|
-
function getToken(params) {
|
|
22
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
var _a;
|
|
24
|
-
const jwtSetting = yield repos.jwtSetting.findDefault();
|
|
25
|
-
if (typeof params.project.id !== 'string' || params.project.id.length === 0) {
|
|
26
|
-
throw new factory.errors.ArgumentNull('project.id');
|
|
27
|
-
}
|
|
28
|
-
if (typeof params.code !== 'string' || params.code.length === 0) {
|
|
29
|
-
throw new factory.errors.ArgumentNull('code');
|
|
30
|
-
}
|
|
31
|
-
const authorization = yield repos.authorization.findValidOneByCode({
|
|
32
|
-
project: { id: params.project.id },
|
|
33
|
-
code: params.code
|
|
34
|
-
});
|
|
35
|
-
// if (typeof params.issuer !== 'string' || params.issuer.length === 0) {
|
|
36
|
-
// throw new factory.errors.ArgumentNull('issuer');
|
|
37
|
-
// }
|
|
38
|
-
let subject;
|
|
39
|
-
let typ;
|
|
40
|
-
// jti必須化(2024-08-22~)
|
|
41
|
-
const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
|
|
42
|
-
const jti = id;
|
|
43
|
-
// ロール承認の場合、subjectはメンバーID,typはメンバータイプ
|
|
44
|
-
if (authorization.object.typeOf === factory.role.RoleType.OrganizationRole) {
|
|
45
|
-
subject = authorization.object.member.id;
|
|
46
|
-
typ = `${jwtSetting.payloadTypPrefix}:${authorization.object.member.typeOf}`;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// useJtiの場合、subject,typはagent(2024-05-09~)
|
|
50
|
-
subject = params.agent.id;
|
|
51
|
-
typ = `${jwtSetting.payloadTypPrefix}:${params.agent.typeOf}`;
|
|
52
|
-
}
|
|
53
|
-
const payload = {
|
|
54
|
-
token_use: 'access', // 拡張(2024-05-01~)
|
|
55
|
-
version: jwtSetting.version, // 拡張(2024-05-02~)
|
|
56
|
-
typ // 拡張(2024-05-07~)
|
|
57
|
-
};
|
|
58
|
-
const token = yield new Promise((resolve, reject) => {
|
|
59
|
-
// 所有権を暗号化する
|
|
60
|
-
jwt.sign(payload, jwtSetting.secret, {
|
|
61
|
-
algorithm: jwtSetting.algorithm, // 明示的に指定(2024-05-05~)
|
|
62
|
-
issuer: jwtSetting.issuer, // 都度指定に変更(2024-05-05~)
|
|
63
|
-
expiresIn: params.expiresIn,
|
|
64
|
-
subject, // 拡張(2024-05-01~)
|
|
65
|
-
audience: jwtSetting.issuer, // 拡張(2024-05-02~)
|
|
66
|
-
jwtid: jti // 拡張(2024-05-08~)
|
|
67
|
-
}, (err, encoded) => {
|
|
68
|
-
if (err instanceof Error) {
|
|
69
|
-
reject(err);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
if (typeof encoded !== 'string') {
|
|
73
|
-
reject(new factory.errors.Internal('authorization.object cannot be signed unexpectedly'));
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
resolve(encoded);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
return { token };
|
|
82
|
-
});
|
|
83
|
-
}
|
|
6
|
+
// import * as jwt from 'jsonwebtoken';
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -4,24 +4,22 @@ exports.createInformTasks = createInformTasks;
|
|
|
4
4
|
exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
|
|
5
5
|
const factory = require("../../../../factory");
|
|
6
6
|
function createInformTasks(order, returnOrderAction, setting) {
|
|
7
|
-
var _a, _b
|
|
7
|
+
var _a, _b;
|
|
8
8
|
const taskRunsAt = new Date();
|
|
9
9
|
const informOrder = (_a = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
|
|
10
|
-
const useInformReturnAction = (
|
|
10
|
+
// const useInformReturnAction = (<any>setting)?.onOrderStatusChanged?.useInformReturnAction === true; // discontinue(2025-07-01~)
|
|
11
11
|
const informTasks = [];
|
|
12
|
-
// support returnAction4inform(2025-01-22~)
|
|
13
|
-
let informObject;
|
|
14
12
|
const informIdentifier = `${factory.order.OrderType.Order}:${order.orderNumber}:${factory.orderStatus.OrderReturned}`;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
else {
|
|
19
|
-
|
|
20
|
-
}
|
|
13
|
+
const informObject = createReturnAction4inform(returnOrderAction);
|
|
14
|
+
// if (useInformReturnAction) { // discontinue(2025-07-01~)
|
|
15
|
+
// informObject = createReturnAction4inform(returnOrderAction);
|
|
16
|
+
// } else {
|
|
17
|
+
// informObject = createOrder4inform(order);
|
|
18
|
+
// }
|
|
21
19
|
if (Array.isArray(informOrder) && informOrder.length > 0) {
|
|
22
20
|
let recipientId = '';
|
|
23
21
|
recipientId = order.customer.id;
|
|
24
|
-
if (typeof ((
|
|
22
|
+
if (typeof ((_b = order.returner) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
25
23
|
recipientId = order.returner.id;
|
|
26
24
|
}
|
|
27
25
|
informOrder.forEach((informOrderParams) => {
|
|
@@ -63,9 +61,19 @@ function createReturnAction4inform(returnOrderAction) {
|
|
|
63
61
|
const { id, instrument, object, project, typeOf } = returnOrderAction;
|
|
64
62
|
return Object.assign({ id, object, project, typeOf }, (Array.isArray(instrument)) ? { instrument } : undefined);
|
|
65
63
|
}
|
|
66
|
-
function createOrder4inform(
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
// function createOrder4inform(
|
|
65
|
+
// order: IReturnedOrder
|
|
66
|
+
// ): IOrder4inform {
|
|
67
|
+
// return {
|
|
68
|
+
// project: order.project,
|
|
69
|
+
// typeOf: order.typeOf,
|
|
70
|
+
// orderNumber: order.orderNumber,
|
|
71
|
+
// orderStatus: factory.orderStatus.OrderReturned,
|
|
72
|
+
// ...(order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined,
|
|
73
|
+
// // ↓hub側で使用している可能性もあるので念のため
|
|
74
|
+
// ...(typeof order.id === 'string') ? { id: order.id } : undefined
|
|
75
|
+
// };
|
|
76
|
+
// }
|
|
69
77
|
/**
|
|
70
78
|
* 注文返品後のアクション
|
|
71
79
|
*/
|
|
@@ -19,7 +19,7 @@ const orderNumber_1 = require("../../repo/orderNumber");
|
|
|
19
19
|
const project_1 = require("../../repo/project");
|
|
20
20
|
const reserveInterface_1 = require("../../repo/reserveInterface");
|
|
21
21
|
const transaction_1 = require("../../repo/transaction");
|
|
22
|
-
|
|
22
|
+
// import { TransactionProcessRepo } from '../../repo/transactionProcess';
|
|
23
23
|
const acceptOffer_1 = require("../offer/eventServiceByCOA/acceptOffer");
|
|
24
24
|
let coaAuthClient;
|
|
25
25
|
/**
|
|
@@ -62,7 +62,7 @@ function call(params) {
|
|
|
62
62
|
coaAuthClient = new COA.auth.RefreshToken(Object.assign(Object.assign({}, credentials), (credentialsRepo !== undefined) ? { credentialsRepo } : undefined));
|
|
63
63
|
}
|
|
64
64
|
const actionRepo = new action_1.ActionRepo(connection);
|
|
65
|
-
const transactionProcessRepo = new
|
|
65
|
+
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
66
66
|
try {
|
|
67
67
|
const reserveService = new COA.service.Reserve({
|
|
68
68
|
endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
@@ -86,7 +86,7 @@ function call(params) {
|
|
|
86
86
|
})({
|
|
87
87
|
action: actionRepo,
|
|
88
88
|
event: new event_1.EventRepo(connection),
|
|
89
|
-
orderNumber: new orderNumber_1.OrderNumberRepo({
|
|
89
|
+
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
90
90
|
project: new project_1.ProjectRepo(connection),
|
|
91
91
|
transaction: new transaction_1.TransactionRepo(connection),
|
|
92
92
|
reserveService,
|
|
@@ -104,7 +104,7 @@ function call(params) {
|
|
|
104
104
|
})({
|
|
105
105
|
action: actionRepo,
|
|
106
106
|
event: new event_1.EventRepo(connection),
|
|
107
|
-
orderNumber: new orderNumber_1.OrderNumberRepo({
|
|
107
|
+
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
108
108
|
project: new project_1.ProjectRepo(connection),
|
|
109
109
|
transaction: new transaction_1.TransactionRepo(connection),
|
|
110
110
|
reserveService,
|
|
@@ -128,8 +128,9 @@ function call(params) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
finally {
|
|
131
|
+
// taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
|
|
131
132
|
// 取引プロセスロック解除
|
|
132
|
-
|
|
133
|
+
// await transactionProcessRepo.unlock({ typeOf: factory.transactionType.PlaceOrder, id: params.data.purpose.id });
|
|
133
134
|
}
|
|
134
135
|
});
|
|
135
136
|
}
|