@chevre/domain 22.11.0-alpha.0 → 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/reIndex.ts +1 -1
- 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/mongoose/schemas/member.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/member.js +26 -10
- 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
|
@@ -9,17 +9,20 @@ import { chevre } from '../../../lib/index';
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
let updateResult: any;
|
|
15
15
|
|
|
16
|
-
updateResult = await
|
|
16
|
+
updateResult = await settingRepo.unsetUnnecessaryFields({
|
|
17
17
|
filter: {
|
|
18
|
-
'
|
|
19
|
-
// _id: { $eq: 'blj55y1mo' }
|
|
18
|
+
'project.id': { $eq: '*' }
|
|
20
19
|
},
|
|
21
20
|
$unset: {
|
|
22
|
-
|
|
21
|
+
useMongoAsStockHolder: 1,
|
|
22
|
+
useMongoAsStockHolderProjects: 1
|
|
23
|
+
// useMongo4confirmationNumberFrom: 1,
|
|
24
|
+
// useMongo4orderNumberFrom: 1,
|
|
25
|
+
// useMongo4transactionNumberFrom: 1
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
28
|
console.log(updateResult);
|
package/lib/chevre/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type * as COAService from '@motionpicture/coa-service';
|
|
5
5
|
import type * as GMOService from '@motionpicture/gmo-service';
|
|
6
|
-
import type * as AdminAuth from './adminAuth';
|
|
7
6
|
import type * as Pecorinoapi from './pecorinoapi';
|
|
8
7
|
import { credentials } from './credentials';
|
|
9
8
|
import * as errorHandler from './errorHandler';
|
|
@@ -13,7 +12,6 @@ import * as repository from './repository';
|
|
|
13
12
|
import * as service from './service';
|
|
14
13
|
import * as settings from './settings';
|
|
15
14
|
export { credentials, errorHandler, eventEmitter, factory, repository, service, settings };
|
|
16
|
-
export declare function loadAdminAuth(): Promise<typeof AdminAuth>;
|
|
17
15
|
export declare function loadPecorinoapi(): Promise<typeof Pecorinoapi>;
|
|
18
16
|
export type COA = typeof COAService;
|
|
19
17
|
export declare function loadCOA(): Promise<typeof COAService>;
|
package/lib/chevre/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.settings = exports.service = exports.repository = exports.factory = exports.eventEmitter = exports.errorHandler = exports.credentials = void 0;
|
|
13
|
-
exports.loadAdminAuth = loadAdminAuth;
|
|
14
13
|
exports.loadPecorinoapi = loadPecorinoapi;
|
|
15
14
|
exports.loadCOA = loadCOA;
|
|
16
15
|
exports.loadGMO = loadGMO;
|
|
@@ -28,15 +27,6 @@ const service = require("./service");
|
|
|
28
27
|
exports.service = service;
|
|
29
28
|
const settings = require("./settings");
|
|
30
29
|
exports.settings = settings;
|
|
31
|
-
let adminAuth;
|
|
32
|
-
function loadAdminAuth() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
if (adminAuth === undefined) {
|
|
35
|
-
adminAuth = yield Promise.resolve().then(() => require('./adminAuth'));
|
|
36
|
-
}
|
|
37
|
-
return adminAuth;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
30
|
let pecorinoapi;
|
|
41
31
|
function loadPecorinoapi() {
|
|
42
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -20,7 +20,9 @@ export declare class AcceptedOfferRepo {
|
|
|
20
20
|
/**
|
|
21
21
|
* オファー展開の注文検索
|
|
22
22
|
*/
|
|
23
|
-
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection
|
|
23
|
+
searchWithUnwoundAcceptedOffers(params: factory.order.ISearchConditions, projection: IProjection4searchWithUnwoundAcceptedOffers, options: {
|
|
24
|
+
useLimitAfterSkip: boolean;
|
|
25
|
+
}): Promise<factory.order.IOrder[]>;
|
|
24
26
|
aggreateOwnershipInfosByOrder(filter: {
|
|
25
27
|
orderNumber: {
|
|
26
28
|
$eq: string;
|
|
@@ -24,9 +24,10 @@ class AcceptedOfferRepo {
|
|
|
24
24
|
/**
|
|
25
25
|
* オファー展開の注文検索
|
|
26
26
|
*/
|
|
27
|
-
searchWithUnwoundAcceptedOffers(params, projection) {
|
|
27
|
+
searchWithUnwoundAcceptedOffers(params, projection, options) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
var _a;
|
|
30
|
+
const { useLimitAfterSkip } = options;
|
|
30
31
|
const conditions = order_2.OrderRepo.CREATE_MONGO_CONDITIONS(params);
|
|
31
32
|
const aggregate = this.orderModel.aggregate();
|
|
32
33
|
// pipelineの順序に注意
|
|
@@ -43,8 +44,15 @@ class AcceptedOfferRepo {
|
|
|
43
44
|
aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
|
|
44
45
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
45
46
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
// support skip -> limit(2025-07-09~)
|
|
48
|
+
if (useLimitAfterSkip) {
|
|
49
|
+
aggregate.skip(params.limit * (page - 1))
|
|
50
|
+
.limit(params.limit);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
aggregate.limit(params.limit * page)
|
|
54
|
+
.skip(params.limit * (page - 1));
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
return aggregate
|
|
50
58
|
// .allowDiskUse(true) // false化(2023-11-30~)
|
|
@@ -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 ConfirmationNumberRepo {
|
|
8
|
-
private readonly settingModel;
|
|
9
6
|
private readonly counterRepo;
|
|
10
7
|
constructor(params: {
|
|
11
|
-
redisClient: RedisClientType;
|
|
12
8
|
connection: Connection;
|
|
13
9
|
});
|
|
14
10
|
private static alignDigits;
|
|
@@ -20,11 +16,4 @@ export declare class ConfirmationNumberRepo {
|
|
|
20
16
|
publish(params: {
|
|
21
17
|
orderDate: Date;
|
|
22
18
|
}): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* DB移行時のみに使用目的の設定更新
|
|
25
|
-
*/
|
|
26
|
-
setUseMongo4confirmationNumberFrom(params: {
|
|
27
|
-
useMongo4confirmationNumberFrom: Date;
|
|
28
|
-
}): Promise<Pick<ISetting, "useMongo4confirmationNumberFrom"> | null>;
|
|
29
|
-
private useMongoBySettings;
|
|
30
19
|
}
|
|
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ConfirmationNumberRepo = 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 CONFIRMATION_NUMBER_MIN_LENGH = 4;
|
|
@@ -24,8 +25,8 @@ const TIMEZONE = 'Asia/Tokyo';
|
|
|
24
25
|
*/
|
|
25
26
|
class ConfirmationNumberRepo {
|
|
26
27
|
constructor(params) {
|
|
27
|
-
const { connection } = params;
|
|
28
|
-
this.settingModel = connection.model(
|
|
28
|
+
// const { connection } = params;
|
|
29
|
+
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
29
30
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
30
31
|
}
|
|
31
32
|
static alignDigits(params) {
|
|
@@ -72,59 +73,19 @@ class ConfirmationNumberRepo {
|
|
|
72
73
|
const dataFeedIdentifier = ConfirmationNumberRepo.createDataFeedIdentifier({ orderDate: params.orderDate });
|
|
73
74
|
let incrReply;
|
|
74
75
|
// support publishByMongo(2025-05-23~)
|
|
75
|
-
const useMongoBySettings =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// データ保管期間はとりあえず一か月
|
|
90
|
-
dataFeedExpires = moment(params.orderDate)
|
|
91
|
-
.add(1, 'month')
|
|
92
|
-
.toDate();
|
|
93
|
-
incrReply = yield this.counterRepo.incrementByRedis({
|
|
94
|
-
identifier: dataFeedIdentifier,
|
|
95
|
-
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
|
|
96
|
-
expires: dataFeedExpires
|
|
97
|
-
});
|
|
98
|
-
}
|
|
76
|
+
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
77
|
+
// データ保管期間はとりあえず2 months
|
|
78
|
+
dataFeedExpires = moment(params.orderDate)
|
|
79
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
80
|
+
.add(2, 'months')
|
|
81
|
+
.toDate();
|
|
82
|
+
incrReply = yield this.counterRepo.incrementByMongo({
|
|
83
|
+
identifier: dataFeedIdentifier,
|
|
84
|
+
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
|
|
85
|
+
expires: dataFeedExpires
|
|
86
|
+
});
|
|
99
87
|
return ConfirmationNumberRepo.count2confirmationNumber({ count: incrReply });
|
|
100
88
|
});
|
|
101
89
|
}
|
|
102
|
-
/**
|
|
103
|
-
* DB移行時のみに使用目的の設定更新
|
|
104
|
-
*/
|
|
105
|
-
setUseMongo4confirmationNumberFrom(params) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const { useMongo4confirmationNumberFrom } = params;
|
|
108
|
-
return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
|
|
109
|
-
$set: { useMongo4confirmationNumberFrom }
|
|
110
|
-
}, { projection: { _id: 0, useMongo4confirmationNumberFrom: 1 } })
|
|
111
|
-
.lean()
|
|
112
|
-
.exec();
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
useMongoBySettings(params) {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
|
|
118
|
-
_id: 0,
|
|
119
|
-
useMongo4confirmationNumberFrom: 1
|
|
120
|
-
})
|
|
121
|
-
.lean()
|
|
122
|
-
.exec();
|
|
123
|
-
const useMongo4confirmationNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4confirmationNumberFrom;
|
|
124
|
-
return useMongo4confirmationNumberFrom instanceof Date
|
|
125
|
-
&& moment(params.orderDate)
|
|
126
|
-
.isSameOrAfter(moment(useMongo4confirmationNumberFrom));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
90
|
}
|
|
130
91
|
exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
|
|
@@ -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)}`);
|
|
@@ -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>;
|
|
@@ -5,6 +5,6 @@ type IModel = Model<IDocType>;
|
|
|
5
5
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
6
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
7
|
declare const modelName = "Member";
|
|
8
|
-
declare function createSchema(): ISchema;
|
|
9
8
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
10
|
export { createSchema, IModel, indexes, modelName };
|
|
@@ -4,6 +4,7 @@ exports.modelName = exports.indexes = void 0;
|
|
|
4
4
|
exports.createSchema = createSchema;
|
|
5
5
|
const mongoose_1 = require("mongoose");
|
|
6
6
|
const writeConcern_1 = require("../writeConcern");
|
|
7
|
+
const factory = require("../../../factory");
|
|
7
8
|
const settings_1 = require("../../../settings");
|
|
8
9
|
const modelName = 'Member';
|
|
9
10
|
exports.modelName = modelName;
|
|
@@ -45,21 +46,21 @@ const schemaOptions = {
|
|
|
45
46
|
versionKey: false
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
|
-
/**
|
|
49
|
-
* IAMメンバースキーマ
|
|
50
|
-
*/
|
|
51
|
-
let schema;
|
|
52
|
-
function createSchema() {
|
|
53
|
-
if (schema === undefined) {
|
|
54
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
55
|
-
}
|
|
56
|
-
return schema;
|
|
57
|
-
}
|
|
58
49
|
const indexes = [
|
|
59
50
|
[
|
|
60
51
|
{ 'member.id': 1 },
|
|
61
52
|
{ name: 'searchByMemberId' }
|
|
62
53
|
],
|
|
54
|
+
[
|
|
55
|
+
{ 'project.id': 1, 'member.id': 1 },
|
|
56
|
+
{
|
|
57
|
+
name: 'uniqueByMemberId', // プロジェクトメンバーは販売者メンバーになれない
|
|
58
|
+
unique: true,
|
|
59
|
+
partialFilterExpression: {
|
|
60
|
+
'member.memberOf.typeOf': { $eq: factory.organizationType.Project }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
],
|
|
63
64
|
[
|
|
64
65
|
{ 'project.id': 1, 'member.id': 1, 'member.memberOf.id': 1 },
|
|
65
66
|
{
|
|
@@ -95,3 +96,18 @@ const indexes = [
|
|
|
95
96
|
]
|
|
96
97
|
];
|
|
97
98
|
exports.indexes = indexes;
|
|
99
|
+
/**
|
|
100
|
+
* IAMメンバースキーマ
|
|
101
|
+
*/
|
|
102
|
+
let schema;
|
|
103
|
+
function createSchema() {
|
|
104
|
+
if (schema === undefined) {
|
|
105
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
106
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
107
|
+
indexes.forEach((indexParams) => {
|
|
108
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return schema;
|
|
113
|
+
}
|
|
@@ -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
|
}
|