@chevre/domain 22.8.0-alpha.9 → 22.8.0
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/adminSellerReturnPolicy.ts +102 -0
- package/example/src/chevre/{searchActions.ts → searchActionsByOrderNumber.ts} +3 -5
- package/example/src/chevre/searchSellersByAggregate.ts +7 -20
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/lib/chevre/repo/action.d.ts +5 -1
- package/lib/chevre/repo/action.js +51 -45
- package/lib/chevre/repo/issuer.d.ts +32 -0
- package/lib/chevre/repo/issuer.js +150 -0
- package/lib/chevre/repo/member.d.ts +4 -5
- package/lib/chevre/repo/member.js +19 -9
- package/lib/chevre/repo/memberProgram.d.ts +59 -0
- package/lib/chevre/repo/memberProgram.js +140 -0
- package/lib/chevre/repo/mongoose/schemas/action.js +20 -10
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +40 -0
- package/lib/chevre/repo/mongoose/schemas/issuer.js +56 -0
- package/lib/chevre/repo/mongoose/schemas/seller.js +3 -12
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +92 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +0 -66
- package/lib/chevre/repo/projectMakesOffer.d.ts +2 -1
- package/lib/chevre/repo/projectMakesOffer.js +4 -5
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +25 -21
- package/lib/chevre/repo/sellerReturnPolicy.d.ts +36 -0
- package/lib/chevre/repo/sellerReturnPolicy.js +164 -0
- package/lib/chevre/repository.d.ts +15 -0
- package/lib/chevre/repository.js +41 -2
- package/lib/chevre/service/notification.js +3 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +5 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +20 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
- package/lib/chevre/service/order/onOrderUpdated/factory.js +1 -0
- package/lib/chevre/service/order/returnOrder.js +16 -11
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +34 -7
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +19 -7
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/package.json +3 -3
- package/example/src/chevre/adminSellerPaymentAccepted.ts +0 -60
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -129
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.IssuerRepo = void 0;
|
|
24
|
+
const factory = require("../factory");
|
|
25
|
+
const settings_1 = require("../settings");
|
|
26
|
+
const issuer_1 = require("./mongoose/schemas/issuer");
|
|
27
|
+
/**
|
|
28
|
+
* 発行者リポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class IssuerRepo {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.issuerModel = connection.model(issuer_1.modelName, (0, issuer_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
const andConditions = [];
|
|
37
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
38
|
+
if (typeof projectIdEq === 'string') {
|
|
39
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
40
|
+
}
|
|
41
|
+
const identifiereEq = (_c = params.identifier) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
42
|
+
if (typeof identifiereEq === 'string') {
|
|
43
|
+
andConditions.push({ identifier: { $eq: identifiereEq } });
|
|
44
|
+
}
|
|
45
|
+
const idEq = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
46
|
+
if (typeof idEq === 'string') {
|
|
47
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
48
|
+
}
|
|
49
|
+
return andConditions;
|
|
50
|
+
}
|
|
51
|
+
saveIssuer(params) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
let savedId;
|
|
54
|
+
let doc;
|
|
55
|
+
if (params.id === '') {
|
|
56
|
+
const { id } = params, creatingParams = __rest(params, ["id"]);
|
|
57
|
+
doc = yield this.issuerModel.create(creatingParams);
|
|
58
|
+
savedId = doc.id;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const { id, identifier, project } = params, updateFields = __rest(params, ["id", "identifier", "project"]);
|
|
62
|
+
doc = yield this.issuerModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $set: updateFields }, { upsert: false, new: true, projection: { _id: 1 } })
|
|
63
|
+
.exec();
|
|
64
|
+
savedId = params.id;
|
|
65
|
+
}
|
|
66
|
+
if (doc === null) {
|
|
67
|
+
throw new factory.errors.NotFound(this.issuerModel.modelName);
|
|
68
|
+
}
|
|
69
|
+
return { id: savedId };
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
projectPublicFields(params) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a;
|
|
75
|
+
const conditions = IssuerRepo.CREATE_MONGO_CONDITIONS(params);
|
|
76
|
+
const projection = {
|
|
77
|
+
_id: 0,
|
|
78
|
+
id: { $toString: '$_id' },
|
|
79
|
+
identifier: 1,
|
|
80
|
+
project: 1
|
|
81
|
+
};
|
|
82
|
+
const query = this.issuerModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
83
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
84
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
85
|
+
query.limit(params.limit)
|
|
86
|
+
.skip(params.limit * (page - 1));
|
|
87
|
+
}
|
|
88
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) === 'number') {
|
|
89
|
+
query.sort({ identifier: params.sort.identifier });
|
|
90
|
+
}
|
|
91
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
92
|
+
.lean()
|
|
93
|
+
.exec();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
findById(params) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const projection = {
|
|
99
|
+
_id: 0,
|
|
100
|
+
id: { $toString: '$_id' },
|
|
101
|
+
identifier: 1,
|
|
102
|
+
project: 1,
|
|
103
|
+
tokenSecret: 1
|
|
104
|
+
};
|
|
105
|
+
const query = this.issuerModel.findOne({
|
|
106
|
+
_id: { $eq: params.id },
|
|
107
|
+
'project.id': { $eq: params.project.id }
|
|
108
|
+
}, projection);
|
|
109
|
+
const issuer = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
110
|
+
.lean()
|
|
111
|
+
.exec();
|
|
112
|
+
if (issuer === null) {
|
|
113
|
+
throw new factory.errors.NotFound('Issuer');
|
|
114
|
+
}
|
|
115
|
+
return issuer;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
findByIdentifier(params) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const projection = {
|
|
121
|
+
_id: 0,
|
|
122
|
+
id: { $toString: '$_id' },
|
|
123
|
+
identifier: 1,
|
|
124
|
+
project: 1,
|
|
125
|
+
tokenSecret: 1
|
|
126
|
+
};
|
|
127
|
+
const query = this.issuerModel.findOne({
|
|
128
|
+
identifier: { $eq: params.identifier },
|
|
129
|
+
'project.id': { $eq: params.project.id }
|
|
130
|
+
}, projection);
|
|
131
|
+
const issuer = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
132
|
+
.lean()
|
|
133
|
+
.exec();
|
|
134
|
+
if (issuer === null) {
|
|
135
|
+
throw new factory.errors.NotFound('Issuer');
|
|
136
|
+
}
|
|
137
|
+
return issuer;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
deleteById(params) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
yield this.issuerModel.findOneAndDelete({
|
|
143
|
+
_id: { $eq: params.id },
|
|
144
|
+
'project.id': { $eq: params.project.id }
|
|
145
|
+
}, { projection: { _id: 1 } })
|
|
146
|
+
.exec();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.IssuerRepo = IssuerRepo;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
type IKeyOfProjection = keyof factory.iam.IMember;
|
|
4
|
-
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'
|
|
4
|
+
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'>;
|
|
5
5
|
/**
|
|
6
6
|
* IAMメンバーリポジトリ
|
|
7
7
|
*/
|
|
@@ -30,6 +30,9 @@ export declare class MemberRepo {
|
|
|
30
30
|
$eq?: string;
|
|
31
31
|
$in?: string[];
|
|
32
32
|
};
|
|
33
|
+
name?: {
|
|
34
|
+
$regex?: string;
|
|
35
|
+
};
|
|
33
36
|
};
|
|
34
37
|
}): Promise<{
|
|
35
38
|
member: ICustomerMember;
|
|
@@ -81,10 +84,6 @@ export declare class MemberRepo {
|
|
|
81
84
|
hasRole?: factory.iam.IMemberRole[];
|
|
82
85
|
image?: string;
|
|
83
86
|
name?: string;
|
|
84
|
-
/**
|
|
85
|
-
* 所属会員
|
|
86
|
-
*/
|
|
87
|
-
member?: factory.iam.IMemberOfWebApplication[];
|
|
88
87
|
};
|
|
89
88
|
$unset: {
|
|
90
89
|
'member.member'?: 1;
|
|
@@ -107,7 +107,7 @@ class MemberRepo {
|
|
|
107
107
|
*/
|
|
108
108
|
searchCustomerMembers(params) {
|
|
109
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
var _a, _b, _c, _d, _e;
|
|
110
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
111
111
|
if (typeof params.project.id !== 'string' || params.project.id === '') {
|
|
112
112
|
throw new factory.errors.ArgumentNull('project.id');
|
|
113
113
|
}
|
|
@@ -124,7 +124,8 @@ class MemberRepo {
|
|
|
124
124
|
]
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
id: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.member) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') ? { $eq: params.member.id.$eq } : undefined), (Array.isArray((_d = (_c = params.member) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in)) ? { $in: params.member.id.$in } : undefined)
|
|
127
|
+
id: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.member) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') ? { $eq: params.member.id.$eq } : undefined), (Array.isArray((_d = (_c = params.member) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in)) ? { $in: params.member.id.$in } : undefined),
|
|
128
|
+
name: Object.assign({}, (typeof ((_f = (_e = params.member) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.$regex) === 'string') ? { $regex: params.member.name.$regex } : undefined)
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
131
|
const projection = {
|
|
@@ -150,7 +151,7 @@ class MemberRepo {
|
|
|
150
151
|
},
|
|
151
152
|
{ $project: projection }
|
|
152
153
|
]);
|
|
153
|
-
if (typeof ((
|
|
154
|
+
if (typeof ((_g = params.sort) === null || _g === void 0 ? void 0 : _g['member.id']) === 'number') {
|
|
154
155
|
aggregate.sort(params.sort);
|
|
155
156
|
}
|
|
156
157
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
@@ -231,13 +232,22 @@ class MemberRepo {
|
|
|
231
232
|
'member.id': { $eq: params.member.id },
|
|
232
233
|
'member.memberOf.id': { $eq: params.member.memberOf.id },
|
|
233
234
|
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
|
|
234
|
-
},
|
|
235
|
-
? {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
}, {
|
|
236
|
+
$set: Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined
|
|
237
|
+
// discontinue(2025-01-14~)
|
|
238
|
+
// ...(Array.isArray(params.member.member)) ? { 'member.member': params.member.member } : undefined
|
|
239
|
+
),
|
|
240
|
+
$unset: {
|
|
241
|
+
'member.member': 1 // 廃止につき常にunset(2025-01-14~)
|
|
239
242
|
}
|
|
240
|
-
|
|
243
|
+
// ...(params.$unset['member.member'] === 1)
|
|
244
|
+
// ? {
|
|
245
|
+
// $unset: {
|
|
246
|
+
// 'member.member': 1
|
|
247
|
+
// }
|
|
248
|
+
// }
|
|
249
|
+
// : undefined
|
|
250
|
+
})
|
|
241
251
|
.exec();
|
|
242
252
|
if (doc === null) {
|
|
243
253
|
throw new factory.errors.NotFound(this.memberModel.modelName);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import { IMemberProgram } from './mongoose/schemas/issuer';
|
|
3
|
+
type IMemberProgramAsSearchResult = IMemberProgram & {
|
|
4
|
+
hostingOrganization: {
|
|
5
|
+
identifier: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* メンバープログラムリポジトリ
|
|
10
|
+
*/
|
|
11
|
+
export declare class MemberProgramRepo {
|
|
12
|
+
private readonly issuerModel;
|
|
13
|
+
constructor(connection: Connection);
|
|
14
|
+
search(params: {
|
|
15
|
+
limit?: number;
|
|
16
|
+
page?: number;
|
|
17
|
+
project?: {
|
|
18
|
+
id?: {
|
|
19
|
+
$eq?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
hostingOrganization?: {
|
|
23
|
+
id?: {
|
|
24
|
+
$eq?: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
identifier?: {
|
|
28
|
+
$eq?: string;
|
|
29
|
+
};
|
|
30
|
+
}): Promise<IMemberProgramAsSearchResult[]>;
|
|
31
|
+
create(params: {
|
|
32
|
+
project: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
identifier: string;
|
|
36
|
+
hostingOrganization: {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
updateOne(params: {
|
|
41
|
+
project: {
|
|
42
|
+
id: string;
|
|
43
|
+
};
|
|
44
|
+
identifier: string;
|
|
45
|
+
hostingOrganization: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
deleteOne(params: {
|
|
50
|
+
project: {
|
|
51
|
+
id: string;
|
|
52
|
+
};
|
|
53
|
+
identifier: string;
|
|
54
|
+
hostingOrganization: {
|
|
55
|
+
id: string;
|
|
56
|
+
};
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
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.MemberProgramRepo = void 0;
|
|
13
|
+
const mongoose_1 = require("mongoose");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const settings_1 = require("../settings");
|
|
16
|
+
const issuer_1 = require("./mongoose/schemas/issuer");
|
|
17
|
+
/**
|
|
18
|
+
* メンバープログラムリポジトリ
|
|
19
|
+
*/
|
|
20
|
+
class MemberProgramRepo {
|
|
21
|
+
constructor(connection) {
|
|
22
|
+
this.issuerModel = connection.model(issuer_1.modelName, (0, issuer_1.createSchema)());
|
|
23
|
+
}
|
|
24
|
+
search(params) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
27
|
+
const matchStages = [];
|
|
28
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
29
|
+
if (typeof projectIdEq === 'string') {
|
|
30
|
+
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
31
|
+
}
|
|
32
|
+
const hostingOrganizationIdEq = (_d = (_c = params.hostingOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
33
|
+
if (typeof hostingOrganizationIdEq === 'string') {
|
|
34
|
+
matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(hostingOrganizationIdEq) } } });
|
|
35
|
+
}
|
|
36
|
+
const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
37
|
+
if (typeof identifierEq === 'string') {
|
|
38
|
+
matchStages.push({ $match: { 'hasMemberProgram.identifier': { $exists: true, $eq: identifierEq } } });
|
|
39
|
+
}
|
|
40
|
+
const aggregate = this.issuerModel.aggregate([
|
|
41
|
+
{
|
|
42
|
+
$unwind: {
|
|
43
|
+
path: '$hasMemberProgram'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
...matchStages,
|
|
47
|
+
// { $sort: { 'makesOffer.availableAtOrFrom.id': factory.sortType.Ascending } },
|
|
48
|
+
{
|
|
49
|
+
$project: {
|
|
50
|
+
_id: 0,
|
|
51
|
+
typeOf: '$hasMemberProgram.typeOf',
|
|
52
|
+
identifier: '$hasMemberProgram.identifier',
|
|
53
|
+
hostingOrganization: {
|
|
54
|
+
identifier: '$identifier'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
60
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
61
|
+
aggregate.limit(params.limit * page)
|
|
62
|
+
.skip(params.limit * (page - 1));
|
|
63
|
+
}
|
|
64
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
65
|
+
.exec();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
create(params) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
let doc = yield this.issuerModel.findOne({
|
|
71
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
72
|
+
'project.id': { $eq: params.project.id }
|
|
73
|
+
}, { _id: 1 })
|
|
74
|
+
.exec();
|
|
75
|
+
if (doc === null) {
|
|
76
|
+
throw new factory.errors.NotFound('Issuer');
|
|
77
|
+
}
|
|
78
|
+
const creatingMemberProgram = {
|
|
79
|
+
typeOf: 'MemberProgram',
|
|
80
|
+
identifier: params.identifier
|
|
81
|
+
};
|
|
82
|
+
doc = yield this.issuerModel.findOneAndUpdate({
|
|
83
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
84
|
+
'project.id': { $eq: params.project.id },
|
|
85
|
+
'hasMemberProgram.identifier': { $ne: params.identifier }
|
|
86
|
+
}, {
|
|
87
|
+
$push: { hasMemberProgram: creatingMemberProgram }
|
|
88
|
+
}, {
|
|
89
|
+
projection: { _id: 1 }
|
|
90
|
+
})
|
|
91
|
+
.exec();
|
|
92
|
+
if (doc === null) {
|
|
93
|
+
throw new factory.errors.AlreadyInUse('hasMemberProgram', ['identifier']);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
updateOne(params) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const updatingMakesOffer = {
|
|
100
|
+
typeOf: 'MemberProgram',
|
|
101
|
+
identifier: params.identifier
|
|
102
|
+
};
|
|
103
|
+
const doc = yield this.issuerModel.findOneAndUpdate({
|
|
104
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
105
|
+
'project.id': { $eq: params.project.id },
|
|
106
|
+
'hasMemberProgram.identifier': { $exists: true, $eq: params.identifier }
|
|
107
|
+
}, {
|
|
108
|
+
$set: { 'hasMemberProgram.$[hasMemberProgramElement]': updatingMakesOffer }
|
|
109
|
+
}, {
|
|
110
|
+
new: true,
|
|
111
|
+
arrayFilters: [
|
|
112
|
+
{ 'hasMemberProgramElement.identifier': { $eq: params.identifier } }
|
|
113
|
+
],
|
|
114
|
+
projection: { _id: 1 }
|
|
115
|
+
})
|
|
116
|
+
.exec();
|
|
117
|
+
if (doc === null) {
|
|
118
|
+
throw new factory.errors.NotFound('MemberProgram');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
deleteOne(params) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const doc = yield this.issuerModel.findOneAndUpdate({
|
|
125
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
126
|
+
'project.id': { $eq: params.project.id },
|
|
127
|
+
'hasMemberProgram.identifier': { $exists: true, $eq: params.identifier }
|
|
128
|
+
}, {
|
|
129
|
+
$pull: { hasMemberProgram: { identifier: params.identifier } }
|
|
130
|
+
}, {
|
|
131
|
+
projection: { _id: 1 }
|
|
132
|
+
})
|
|
133
|
+
.exec();
|
|
134
|
+
if (doc === null) {
|
|
135
|
+
throw new factory.errors.NotFound('MemberProgram');
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.MemberProgramRepo = MemberProgramRepo;
|
|
@@ -29,7 +29,8 @@ const schemaDefinition = {
|
|
|
29
29
|
replacer: mongoose_1.SchemaTypes.Mixed, // add replacer(2024-03-19~)
|
|
30
30
|
targetCollection: mongoose_1.SchemaTypes.Mixed, // add targetCollection(2024-03-19~)
|
|
31
31
|
sameAs: mongoose_1.SchemaTypes.Mixed, // タスク関連付けのために追加(2024-04-20~)
|
|
32
|
-
cancelAction: mongoose_1.SchemaTypes.Mixed // add(2024-05-26~)
|
|
32
|
+
cancelAction: mongoose_1.SchemaTypes.Mixed, // add(2024-05-26~)
|
|
33
|
+
about: mongoose_1.SchemaTypes.Mixed // add(2025-01-22~)
|
|
33
34
|
};
|
|
34
35
|
const schemaOptions = {
|
|
35
36
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -227,15 +228,15 @@ const indexes = [
|
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
],
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
231
|
+
[
|
|
232
|
+
{ 'about.orderNumber': 1, startDate: -1 },
|
|
233
|
+
{
|
|
234
|
+
name: 'aboutOrderNumber',
|
|
235
|
+
partialFilterExpression: {
|
|
236
|
+
'about.orderNumber': { $exists: true }
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
],
|
|
239
240
|
[
|
|
240
241
|
{ 'object.orderNumber': 1, startDate: -1 },
|
|
241
242
|
{
|
|
@@ -389,6 +390,15 @@ const indexes = [
|
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
392
|
],
|
|
393
|
+
[
|
|
394
|
+
{ 'instrument.identifier': 1, startDate: -1 },
|
|
395
|
+
{
|
|
396
|
+
name: 'instrumentIdentifier',
|
|
397
|
+
partialFilterExpression: {
|
|
398
|
+
'instrument.identifier': { $exists: true }
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
],
|
|
392
402
|
[
|
|
393
403
|
{ 'object.transactionNumber': 1, startDate: -1 },
|
|
394
404
|
{
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
export interface ISearchConditions {
|
|
4
|
+
limit?: number;
|
|
5
|
+
page?: number;
|
|
6
|
+
sort?: {
|
|
7
|
+
identifier?: factory.sortType;
|
|
8
|
+
};
|
|
9
|
+
id?: {
|
|
10
|
+
$eq?: string;
|
|
11
|
+
};
|
|
12
|
+
identifier?: {
|
|
13
|
+
$eq?: string;
|
|
14
|
+
};
|
|
15
|
+
project?: {
|
|
16
|
+
id?: {
|
|
17
|
+
$eq?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface IIssuer {
|
|
22
|
+
id: string;
|
|
23
|
+
identifier: string;
|
|
24
|
+
project: Pick<factory.project.IProject, 'id' | 'typeOf'>;
|
|
25
|
+
tokenSecret?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IMemberProgram {
|
|
28
|
+
typeOf: 'MemberProgram';
|
|
29
|
+
identifier: string;
|
|
30
|
+
}
|
|
31
|
+
export type IDocType = IIssuer & {
|
|
32
|
+
hasMemberProgram?: IMemberProgram[];
|
|
33
|
+
};
|
|
34
|
+
type IModel = Model<IDocType>;
|
|
35
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
36
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
37
|
+
declare const modelName = "Issuer";
|
|
38
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
39
|
+
declare function createSchema(): ISchema;
|
|
40
|
+
export { createSchema, IModel, indexes, modelName };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = void 0;
|
|
4
|
+
exports.createSchema = createSchema;
|
|
5
|
+
const mongoose_1 = require("mongoose");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const writeConcern_1 = require("../writeConcern");
|
|
8
|
+
const modelName = 'Issuer';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
|
+
identifier: { type: String, required: true },
|
|
13
|
+
tokenSecret: String,
|
|
14
|
+
hasMemberProgram: [mongoose_1.SchemaTypes.Mixed]
|
|
15
|
+
};
|
|
16
|
+
const schemaOptions = {
|
|
17
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
18
|
+
autoCreate: false,
|
|
19
|
+
collection: 'issuers',
|
|
20
|
+
id: true,
|
|
21
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
22
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
23
|
+
strict: true,
|
|
24
|
+
strictQuery: false,
|
|
25
|
+
timestamps: false,
|
|
26
|
+
versionKey: false,
|
|
27
|
+
toJSON: {
|
|
28
|
+
getters: false,
|
|
29
|
+
virtuals: false,
|
|
30
|
+
minimize: false,
|
|
31
|
+
versionKey: false
|
|
32
|
+
},
|
|
33
|
+
toObject: {
|
|
34
|
+
getters: false,
|
|
35
|
+
virtuals: true,
|
|
36
|
+
minimize: false,
|
|
37
|
+
versionKey: false
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const indexes = [];
|
|
41
|
+
exports.indexes = indexes;
|
|
42
|
+
/**
|
|
43
|
+
* 発行者スキーマ
|
|
44
|
+
*/
|
|
45
|
+
let schema;
|
|
46
|
+
function createSchema() {
|
|
47
|
+
if (schema === undefined) {
|
|
48
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
49
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
50
|
+
indexes.forEach((indexParams) => {
|
|
51
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return schema;
|
|
56
|
+
}
|
|
@@ -100,20 +100,11 @@ const indexes = [
|
|
|
100
100
|
}
|
|
101
101
|
],
|
|
102
102
|
[
|
|
103
|
-
{ 'hasMerchantReturnPolicy.
|
|
103
|
+
{ 'hasMerchantReturnPolicy.identifier': 1, branchCode: 1 },
|
|
104
104
|
{
|
|
105
|
-
name: '
|
|
105
|
+
name: 'hasMerchantReturnPolicyIdentifier',
|
|
106
106
|
partialFilterExpression: {
|
|
107
|
-
'hasMerchantReturnPolicy.
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
[
|
|
112
|
-
{ 'hasMerchantReturnPolicy.itemCondition.id': 1, branchCode: 1 },
|
|
113
|
-
{
|
|
114
|
-
name: 'searchByHasMerchantReturnPolicyItemConditionId',
|
|
115
|
-
partialFilterExpression: {
|
|
116
|
-
'hasMerchantReturnPolicy.itemCondition.id': { $exists: true }
|
|
107
|
+
'hasMerchantReturnPolicy.identifier': { $exists: true }
|
|
117
108
|
}
|
|
118
109
|
}
|
|
119
110
|
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IDocType = Omit<factory.sellerReturnPolicy.ISellerReturnPolicy, 'id'>;
|
|
4
|
+
type IModel = Model<IDocType>;
|
|
5
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
|
+
declare const modelName = "SellerReturnPolicy";
|
|
8
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
|
+
export { createSchema, IModel, indexes, modelName };
|