@chevre/domain 22.11.0-alpha.1 → 22.11.0-alpha.11
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/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/addProjectCreatorRole.ts +48 -0
- package/example/src/chevre/roles/assignRoles.ts +71 -0
- 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/example/src/idaas/auth0/adminApplications.ts +183 -0
- package/example/src/idaas/auth0/getToken.ts +55 -0
- package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +84 -0
- 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/member.d.ts +1 -0
- package/lib/chevre/repo/member.js +7 -2
- 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 +5 -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
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Connection, FilterQuery, QueryOptions } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
|
|
3
|
+
type ISavingSoftwareApplicationIdentity = Pick<factory.creativeWork.certification.softwareApplication.ICertification, 'about' | 'project' | 'typeOf'>;
|
|
4
|
+
type ISavingWebApplicationIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'>;
|
|
5
|
+
export type ISavingIdentity = (ISavingSoftwareApplicationIdentity | ISavingWebApplicationIdentity) & {
|
|
4
6
|
id?: never;
|
|
5
7
|
dateCreated?: never;
|
|
6
8
|
dateModified?: never;
|
|
@@ -11,7 +13,7 @@ interface IUnset {
|
|
|
11
13
|
[key: string]: 1;
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
|
-
type IIdentityWithId = factory.creativeWork.certification.webApplication.ICertification & {
|
|
16
|
+
type IIdentityWithId = (factory.creativeWork.certification.softwareApplication.ICertification | factory.creativeWork.certification.webApplication.ICertification) & {
|
|
15
17
|
id: string;
|
|
16
18
|
};
|
|
17
19
|
type IKeyOfProjection = keyof factory.creativeWork.certification.webApplication.ICertification;
|
|
@@ -35,39 +37,15 @@ export declare class IdentityRepo {
|
|
|
35
37
|
id: string;
|
|
36
38
|
};
|
|
37
39
|
}): Promise<void>;
|
|
38
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
39
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
40
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
41
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
42
|
-
dateCreated?: Date | undefined;
|
|
43
|
-
dateModified?: Date | undefined;
|
|
44
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
45
|
-
}> & {
|
|
46
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
47
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
48
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
49
|
-
dateCreated?: Date | undefined;
|
|
50
|
-
dateModified?: Date | undefined;
|
|
51
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
52
|
-
} & {
|
|
40
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
|
|
53
41
|
_id: import("mongoose").Types.ObjectId;
|
|
54
|
-
}
|
|
55
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
56
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
57
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
58
|
-
dateCreated?: Date | undefined;
|
|
59
|
-
dateModified?: Date | undefined;
|
|
60
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
61
|
-
}> & {
|
|
62
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
63
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
64
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
65
|
-
dateCreated?: Date | undefined;
|
|
66
|
-
dateModified?: Date | undefined;
|
|
67
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
68
|
-
} & {
|
|
42
|
+
}) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
|
|
69
43
|
_id: import("mongoose").Types.ObjectId;
|
|
70
|
-
}
|
|
44
|
+
})), QueryOptions<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
|
|
45
|
+
_id: import("mongoose").Types.ObjectId;
|
|
46
|
+
}) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
|
|
47
|
+
_id: import("mongoose").Types.ObjectId;
|
|
48
|
+
}))>>;
|
|
71
49
|
updateIssuedBy2array(params: Pick<ISavingIdentity, 'issuedBy'> & {
|
|
72
50
|
id: string;
|
|
73
51
|
}): Promise<void>;
|
|
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.IdentityRepo = void 0;
|
|
24
13
|
const factory = require("../factory");
|
|
@@ -76,12 +65,15 @@ class IdentityRepo {
|
|
|
76
65
|
throw new factory.errors.ArgumentNull('id');
|
|
77
66
|
}
|
|
78
67
|
// issuedByのみ更新可能
|
|
79
|
-
const
|
|
68
|
+
const { project, $unset, issuedBy } = params.attributes;
|
|
80
69
|
const filter = {
|
|
81
70
|
_id: { $eq: savingId },
|
|
82
71
|
'project.id': { $eq: project.id }
|
|
83
72
|
};
|
|
84
|
-
const update = Object.assign({ $set:
|
|
73
|
+
const update = Object.assign({ $set: {
|
|
74
|
+
issuedBy,
|
|
75
|
+
dateModified: new Date()
|
|
76
|
+
} }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
85
77
|
const options = {
|
|
86
78
|
upsert: false,
|
|
87
79
|
new: true,
|
|
@@ -96,8 +88,11 @@ class IdentityRepo {
|
|
|
96
88
|
savedId = savingId;
|
|
97
89
|
}
|
|
98
90
|
else {
|
|
99
|
-
const
|
|
100
|
-
const result = yield this.identityModel.insertMany(
|
|
91
|
+
const { typeOf, about, project, issuedBy } = params.attributes;
|
|
92
|
+
const result = yield this.identityModel.insertMany({
|
|
93
|
+
typeOf, about, project, issuedBy,
|
|
94
|
+
dateCreated: new Date()
|
|
95
|
+
}, { rawResult: true });
|
|
101
96
|
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
102
97
|
if (typeof insertedId !== 'string') {
|
|
103
98
|
throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
@@ -18,6 +18,7 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
18
18
|
'typeOf',
|
|
19
19
|
'member'
|
|
20
20
|
];
|
|
21
|
+
const ANY_PROJECT_ID = '*';
|
|
21
22
|
/**
|
|
22
23
|
* IAMメンバーリポジトリ
|
|
23
24
|
*/
|
|
@@ -112,7 +113,7 @@ class MemberRepo {
|
|
|
112
113
|
throw new factory.errors.ArgumentNull('project.id');
|
|
113
114
|
}
|
|
114
115
|
const filterQueries = MemberRepo.CREATE_MONGO_CONDITIONS({
|
|
115
|
-
project: { id: { $in: [params.project.id,
|
|
116
|
+
project: { id: { $in: [params.project.id, ANY_PROJECT_ID] } }, // 全プロジェクトで利用可能なクライアントを考慮(2025-01-11~)
|
|
116
117
|
member: {
|
|
117
118
|
typeOf: { $eq: factory.creativeWorkType.WebApplication },
|
|
118
119
|
memberOf: { typeOf: { $eq: factory.organizationType.Project } }, // プロジェクトメンバーのはず
|
|
@@ -283,6 +284,7 @@ class MemberRepo {
|
|
|
283
284
|
}
|
|
284
285
|
/**
|
|
285
286
|
* メンバーの権限を持つプロジェクト検索
|
|
287
|
+
* ANY_PROJECT_IDは除外
|
|
286
288
|
*/
|
|
287
289
|
searchProjectIdsByMemberId(params) {
|
|
288
290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -293,7 +295,10 @@ class MemberRepo {
|
|
|
293
295
|
if (typeof params.page !== 'number') {
|
|
294
296
|
throw new factory.errors.ArgumentNull('page');
|
|
295
297
|
}
|
|
296
|
-
const matchStages = [
|
|
298
|
+
const matchStages = [
|
|
299
|
+
{ $match: { 'member.id': { $eq: params.member.id } } },
|
|
300
|
+
{ $match: { 'project.id': { $ne: ANY_PROJECT_ID } } }
|
|
301
|
+
];
|
|
297
302
|
if (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') {
|
|
298
303
|
matchStages.push({ $match: { 'project.id': { $eq: params.project.id.$eq } } });
|
|
299
304
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
type IDocType = Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
|
|
3
|
+
type IDocType = Omit<factory.creativeWork.certification.softwareApplication.ICertification, 'id'> | Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
|
|
4
4
|
type IModel = Model<IDocType>;
|
|
5
5
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
6
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
|
-
import { RedisClientType } from 'redis';
|
|
3
|
-
import { ISetting } from './mongoose/schemas/setting';
|
|
4
2
|
/**
|
|
5
3
|
* 注文番号リポジトリ
|
|
6
4
|
*/
|
|
7
5
|
export declare class OrderNumberRepo {
|
|
8
|
-
private readonly settingModel;
|
|
9
6
|
private readonly counterRepo;
|
|
10
7
|
constructor(params: {
|
|
11
|
-
redisClient: RedisClientType;
|
|
12
8
|
connection: Connection;
|
|
13
9
|
});
|
|
14
10
|
/**
|
|
@@ -23,11 +19,4 @@ export declare class OrderNumberRepo {
|
|
|
23
19
|
*/
|
|
24
20
|
orderDate: Date;
|
|
25
21
|
}): Promise<string>;
|
|
26
|
-
/**
|
|
27
|
-
* DB移行時のみに使用目的の設定更新
|
|
28
|
-
*/
|
|
29
|
-
setUseMongo4orderNumberFrom(params: {
|
|
30
|
-
useMongo4orderNumberFrom: Date;
|
|
31
|
-
}): Promise<Pick<ISetting, "useMongo4orderNumberFrom"> | null>;
|
|
32
|
-
private useMongoBySettings;
|
|
33
22
|
}
|
|
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.OrderNumberRepo = 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
|
const ORDER_NUMBER_SEPARATOR = '-';
|
|
@@ -23,8 +24,8 @@ const ORDER_NUMBER_SEPARATOR = '-';
|
|
|
23
24
|
*/
|
|
24
25
|
class OrderNumberRepo {
|
|
25
26
|
constructor(params) {
|
|
26
|
-
const { connection } = params;
|
|
27
|
-
this.settingModel = connection.model(
|
|
27
|
+
// const { connection } = params;
|
|
28
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
28
29
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
29
30
|
}
|
|
30
31
|
// private static createKey(params: {
|
|
@@ -52,27 +53,15 @@ class OrderNumberRepo {
|
|
|
52
53
|
let dataFeedExpires;
|
|
53
54
|
const dataFeedIdentifier = `${projectPrefix}:${timestamp}`;
|
|
54
55
|
let incrReply;
|
|
55
|
-
const useMongoBySettings =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
dataFeedExpires = moment(params.orderDate)
|
|
68
|
-
.add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
|
|
69
|
-
.toDate();
|
|
70
|
-
incrReply = yield this.counterRepo.incrementByRedis({
|
|
71
|
-
identifier: dataFeedIdentifier,
|
|
72
|
-
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
|
|
73
|
-
expires: dataFeedExpires
|
|
74
|
-
});
|
|
75
|
-
}
|
|
56
|
+
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
57
|
+
dataFeedExpires = moment(params.orderDate)
|
|
58
|
+
.add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
|
|
59
|
+
.toDate();
|
|
60
|
+
incrReply = yield this.counterRepo.incrementByMongo({
|
|
61
|
+
identifier: dataFeedIdentifier,
|
|
62
|
+
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
|
|
63
|
+
expires: dataFeedExpires
|
|
64
|
+
});
|
|
76
65
|
let orderNumber = `${timestamp}${incrReply}`;
|
|
77
66
|
// checkdigit
|
|
78
67
|
const cd = cdigit.luhn.compute(orderNumber);
|
|
@@ -90,32 +79,5 @@ class OrderNumberRepo {
|
|
|
90
79
|
return orderNumber;
|
|
91
80
|
});
|
|
92
81
|
}
|
|
93
|
-
/**
|
|
94
|
-
* DB移行時のみに使用目的の設定更新
|
|
95
|
-
*/
|
|
96
|
-
setUseMongo4orderNumberFrom(params) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const { useMongo4orderNumberFrom } = params;
|
|
99
|
-
return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
|
|
100
|
-
$set: { useMongo4orderNumberFrom }
|
|
101
|
-
}, { projection: { _id: 0, useMongo4orderNumberFrom: 1 } })
|
|
102
|
-
.lean()
|
|
103
|
-
.exec();
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
useMongoBySettings(params) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
|
|
109
|
-
_id: 0,
|
|
110
|
-
useMongo4orderNumberFrom: 1
|
|
111
|
-
})
|
|
112
|
-
.lean()
|
|
113
|
-
.exec();
|
|
114
|
-
const useMongo4orderNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4orderNumberFrom;
|
|
115
|
-
return useMongo4orderNumberFrom instanceof Date
|
|
116
|
-
&& moment(params.orderDate)
|
|
117
|
-
.isSameOrAfter(moment(useMongo4orderNumberFrom));
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
82
|
}
|
|
121
83
|
exports.OrderNumberRepo = OrderNumberRepo;
|
|
@@ -26,8 +26,19 @@ export declare class RoleRepo {
|
|
|
26
26
|
}): Promise<(import("mongoose").FlattenMaps<IDocType> & {
|
|
27
27
|
_id: import("mongoose").Types.ObjectId;
|
|
28
28
|
}) | null>;
|
|
29
|
+
removePermissionIfExists(params: {
|
|
30
|
+
roleName: {
|
|
31
|
+
$eq: factory.role.organizationRole.RoleName;
|
|
32
|
+
};
|
|
33
|
+
permission: string;
|
|
34
|
+
}): Promise<(import("mongoose").FlattenMaps<IDocType> & {
|
|
35
|
+
_id: import("mongoose").Types.ObjectId;
|
|
36
|
+
}) | null>;
|
|
29
37
|
addMember(params: Pick<IRole, 'member' | 'memberOf' | 'roleName'>): Promise<(import("mongoose").FlattenMaps<IDocType> & {
|
|
30
38
|
_id: import("mongoose").Types.ObjectId;
|
|
31
39
|
}) | null>;
|
|
40
|
+
create(params: Pick<IRole, 'member' | 'memberOf' | 'permissions' | 'roleName'>): Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
}>;
|
|
32
43
|
}
|
|
33
44
|
export {};
|
package/lib/chevre/repo/role.js
CHANGED
|
@@ -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.RoleRepo = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
13
14
|
const settings_1 = require("../settings");
|
|
14
15
|
const role_1 = require("./mongoose/schemas/role");
|
|
15
16
|
const AVAILABLE_PROJECT_FIELDS = [
|
|
@@ -132,6 +133,23 @@ class RoleRepo {
|
|
|
132
133
|
.exec();
|
|
133
134
|
});
|
|
134
135
|
}
|
|
136
|
+
removePermissionIfExists(params) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
return this.roleModel.findOneAndUpdate({
|
|
139
|
+
roleName: { $eq: params.roleName.$eq },
|
|
140
|
+
permissions: { $eq: params.permission }
|
|
141
|
+
}, {
|
|
142
|
+
$pull: {
|
|
143
|
+
permissions: params.permission
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
new: true,
|
|
147
|
+
projection: { _id: 1 }
|
|
148
|
+
})
|
|
149
|
+
.lean()
|
|
150
|
+
.exec();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
135
153
|
addMember(params) {
|
|
136
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
155
|
const { roleName, member, memberOf } = params;
|
|
@@ -148,5 +166,23 @@ class RoleRepo {
|
|
|
148
166
|
.exec();
|
|
149
167
|
});
|
|
150
168
|
}
|
|
169
|
+
create(params) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
let savedId;
|
|
173
|
+
const { member, memberOf, permissions, roleName } = params;
|
|
174
|
+
const creatingRole = {
|
|
175
|
+
member, memberOf, permissions, roleName,
|
|
176
|
+
typeOf: factory.role.RoleType.OrganizationRole
|
|
177
|
+
};
|
|
178
|
+
const result = yield this.roleModel.insertMany(creatingRole, { rawResult: true });
|
|
179
|
+
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
180
|
+
if (typeof insertedId !== 'string') {
|
|
181
|
+
throw new factory.errors.Internal(`role not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
182
|
+
}
|
|
183
|
+
savedId = insertedId;
|
|
184
|
+
return { id: savedId };
|
|
185
|
+
});
|
|
186
|
+
}
|
|
151
187
|
}
|
|
152
188
|
exports.RoleRepo = RoleRepo;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
|
-
import { RedisClientType } from 'redis';
|
|
3
2
|
/**
|
|
4
3
|
* サービスアウトプット識別子リポジトリ
|
|
5
4
|
*/
|
|
6
5
|
export declare class ServiceOutputIdentifierRepo {
|
|
7
|
-
private readonly settingModel;
|
|
8
6
|
private readonly counterRepo;
|
|
9
7
|
constructor(params: {
|
|
10
|
-
redisClient: RedisClientType;
|
|
11
8
|
connection: Connection;
|
|
12
9
|
});
|
|
13
10
|
/**
|
|
@@ -16,5 +13,4 @@ export declare class ServiceOutputIdentifierRepo {
|
|
|
16
13
|
publishByTimestamp(params: {
|
|
17
14
|
startDate: Date;
|
|
18
15
|
}): Promise<string>;
|
|
19
|
-
private useMongoBySettings;
|
|
20
16
|
}
|
|
@@ -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 {};
|