@chevre/domain 22.8.0-alpha.8 → 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/searchMembers.ts +55 -0
- 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 +32 -7
- package/lib/chevre/repo/member.js +126 -31
- 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 +6 -6
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +42 -13
- 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
|
@@ -27,7 +27,7 @@ class MemberRepo {
|
|
|
27
27
|
}
|
|
28
28
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
29
29
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
31
31
|
const andConditions = [];
|
|
32
32
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
33
33
|
if (typeof idEq === 'string') {
|
|
@@ -37,27 +37,31 @@ class MemberRepo {
|
|
|
37
37
|
if (typeof projectIdEq === 'string') {
|
|
38
38
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const projectIdIn = (_e = (_d = params.project) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$in;
|
|
41
|
+
if (Array.isArray(projectIdIn)) {
|
|
42
|
+
andConditions.push({ 'project.id': { $in: projectIdIn } });
|
|
43
|
+
}
|
|
44
|
+
const memberMemberOfTypeOfEq = (_h = (_g = (_f = params.member) === null || _f === void 0 ? void 0 : _f.memberOf) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
41
45
|
if (typeof memberMemberOfTypeOfEq === 'string') {
|
|
42
46
|
andConditions.push({ 'member.memberOf.typeOf': { $eq: memberMemberOfTypeOfEq } });
|
|
43
47
|
}
|
|
44
|
-
const memberMemberOfIdEq = (
|
|
48
|
+
const memberMemberOfIdEq = (_l = (_k = (_j = params.member) === null || _j === void 0 ? void 0 : _j.memberOf) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
45
49
|
if (typeof memberMemberOfIdEq === 'string') {
|
|
46
50
|
andConditions.push({ 'member.memberOf.id': { $eq: memberMemberOfIdEq } });
|
|
47
51
|
}
|
|
48
|
-
const memberTypeOfEq = (
|
|
52
|
+
const memberTypeOfEq = (_o = (_m = params.member) === null || _m === void 0 ? void 0 : _m.typeOf) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
49
53
|
if (typeof memberTypeOfEq === 'string') {
|
|
50
54
|
andConditions.push({ 'member.typeOf': { $exists: true, $eq: memberTypeOfEq } });
|
|
51
55
|
}
|
|
52
|
-
const memberIdEq = (
|
|
56
|
+
const memberIdEq = (_q = (_p = params.member) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
53
57
|
if (typeof memberIdEq === 'string') {
|
|
54
58
|
andConditions.push({ 'member.id': { $eq: memberIdEq } });
|
|
55
59
|
}
|
|
56
|
-
const memberIdIn = (
|
|
60
|
+
const memberIdIn = (_s = (_r = params.member) === null || _r === void 0 ? void 0 : _r.id) === null || _s === void 0 ? void 0 : _s.$in;
|
|
57
61
|
if (Array.isArray(memberIdIn)) {
|
|
58
62
|
andConditions.push({ 'member.id': { $in: memberIdIn } });
|
|
59
63
|
}
|
|
60
|
-
const memberNameRegex = (
|
|
64
|
+
const memberNameRegex = (_u = (_t = params.member) === null || _t === void 0 ? void 0 : _t.name) === null || _u === void 0 ? void 0 : _u.$regex;
|
|
61
65
|
if (typeof memberNameRegex === 'string' && memberNameRegex.length > 0) {
|
|
62
66
|
andConditions.push({
|
|
63
67
|
'member.name': {
|
|
@@ -66,7 +70,7 @@ class MemberRepo {
|
|
|
66
70
|
}
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
|
-
const memberHasRoleRoleNameEq = (
|
|
73
|
+
const memberHasRoleRoleNameEq = (_x = (_w = (_v = params.member) === null || _v === void 0 ? void 0 : _v.hasRole) === null || _w === void 0 ? void 0 : _w.roleName) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
70
74
|
if (typeof memberHasRoleRoleNameEq === 'string') {
|
|
71
75
|
andConditions.push({
|
|
72
76
|
'member.hasRole.roleName': {
|
|
@@ -75,32 +79,87 @@ class MemberRepo {
|
|
|
75
79
|
}
|
|
76
80
|
});
|
|
77
81
|
}
|
|
82
|
+
const memberHasRoleRoleNameIn = (_0 = (_z = (_y = params.member) === null || _y === void 0 ? void 0 : _y.hasRole) === null || _z === void 0 ? void 0 : _z.roleName) === null || _0 === void 0 ? void 0 : _0.$in;
|
|
83
|
+
if (Array.isArray(memberHasRoleRoleNameIn)) {
|
|
84
|
+
andConditions.push({
|
|
85
|
+
'member.hasRole.roleName': {
|
|
86
|
+
$exists: true,
|
|
87
|
+
$in: memberHasRoleRoleNameIn
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
78
91
|
return andConditions;
|
|
79
92
|
}
|
|
80
|
-
|
|
93
|
+
/**
|
|
94
|
+
* プロジェクト指定で検索する
|
|
95
|
+
*/
|
|
96
|
+
projectFieldsByProjectId(project, conditions, inclusion) {
|
|
81
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
85
|
-
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
98
|
+
if (typeof project.id !== 'string' || project.id === '') {
|
|
99
|
+
throw new factory.errors.ArgumentNull('project.id');
|
|
86
100
|
}
|
|
87
|
-
|
|
88
|
-
|
|
101
|
+
return this.projectFields(Object.assign(Object.assign({}, conditions), { project: { id: { $eq: project.id } } }), inclusion);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 注文取引クライアントメンバーを検索する
|
|
106
|
+
* 全プロジェクトで利用可能なクライアントも考慮される
|
|
107
|
+
*/
|
|
108
|
+
searchCustomerMembers(params) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
111
|
+
if (typeof params.project.id !== 'string' || params.project.id === '') {
|
|
112
|
+
throw new factory.errors.ArgumentNull('project.id');
|
|
113
|
+
}
|
|
114
|
+
const filterQueries = MemberRepo.CREATE_MONGO_CONDITIONS({
|
|
115
|
+
project: { id: { $in: [params.project.id, '*'] } }, // 全プロジェクトで利用可能なクライアントを考慮(2025-01-11~)
|
|
116
|
+
member: {
|
|
117
|
+
typeOf: { $eq: factory.creativeWorkType.WebApplication },
|
|
118
|
+
memberOf: { typeOf: { $eq: factory.organizationType.Project } }, // プロジェクトメンバーのはず
|
|
119
|
+
hasRole: {
|
|
120
|
+
roleName: {
|
|
121
|
+
$in: [
|
|
122
|
+
factory.iam.RoleName.Customer,
|
|
123
|
+
factory.iam.RoleName.POS
|
|
124
|
+
]
|
|
125
|
+
}
|
|
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),
|
|
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)
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const projection = {
|
|
132
|
+
_id: 0,
|
|
133
|
+
// id: { $toString: '$_id' },
|
|
134
|
+
member: {
|
|
135
|
+
// typeOf: 'WebApplication',
|
|
136
|
+
hasRole: '$member.hasRole',
|
|
137
|
+
id: '$member.id',
|
|
138
|
+
member: '$member.member',
|
|
139
|
+
memberOf: '$member.memberOf',
|
|
140
|
+
name: '$member.name'
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const matchStages = [{ $match: { $and: filterQueries } }];
|
|
144
|
+
const aggregate = this.memberModel.aggregate([
|
|
145
|
+
...matchStages,
|
|
146
|
+
{
|
|
147
|
+
$group: {
|
|
148
|
+
_id: '$member.id',
|
|
149
|
+
member: { $first: '$member' }
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{ $project: projection }
|
|
153
|
+
]);
|
|
154
|
+
if (typeof ((_g = params.sort) === null || _g === void 0 ? void 0 : _g['member.id']) === 'number') {
|
|
155
|
+
aggregate.sort(params.sort);
|
|
89
156
|
}
|
|
90
|
-
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
91
|
-
const query = this.memberModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
92
157
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
93
158
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
94
|
-
|
|
159
|
+
aggregate.limit(params.limit * page)
|
|
95
160
|
.skip(params.limit * (page - 1));
|
|
96
161
|
}
|
|
97
|
-
|
|
98
|
-
query.sort(params.sort);
|
|
99
|
-
}
|
|
100
|
-
// const explainResult = await (<any>query).explain();
|
|
101
|
-
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
102
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
103
|
-
.lean()
|
|
162
|
+
return aggregate
|
|
104
163
|
.exec();
|
|
105
164
|
});
|
|
106
165
|
}
|
|
@@ -173,13 +232,22 @@ class MemberRepo {
|
|
|
173
232
|
'member.id': { $eq: params.member.id },
|
|
174
233
|
'member.memberOf.id': { $eq: params.member.memberOf.id },
|
|
175
234
|
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
|
|
176
|
-
},
|
|
177
|
-
? {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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~)
|
|
181
242
|
}
|
|
182
|
-
|
|
243
|
+
// ...(params.$unset['member.member'] === 1)
|
|
244
|
+
// ? {
|
|
245
|
+
// $unset: {
|
|
246
|
+
// 'member.member': 1
|
|
247
|
+
// }
|
|
248
|
+
// }
|
|
249
|
+
// : undefined
|
|
250
|
+
})
|
|
183
251
|
.exec();
|
|
184
252
|
if (doc === null) {
|
|
185
253
|
throw new factory.errors.NotFound(this.memberModel.modelName);
|
|
@@ -275,5 +343,32 @@ class MemberRepo {
|
|
|
275
343
|
.exec();
|
|
276
344
|
});
|
|
277
345
|
}
|
|
346
|
+
projectFields(params, inclusion) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
const conditions = MemberRepo.CREATE_MONGO_CONDITIONS(params);
|
|
349
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
350
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
351
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// no op
|
|
355
|
+
}
|
|
356
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
357
|
+
const query = this.memberModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
358
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
359
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
360
|
+
query.limit(params.limit)
|
|
361
|
+
.skip(params.limit * (page - 1));
|
|
362
|
+
}
|
|
363
|
+
if (params.sort !== undefined) {
|
|
364
|
+
query.sort(params.sort);
|
|
365
|
+
}
|
|
366
|
+
// const explainResult = await (<any>query).explain();
|
|
367
|
+
// console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
368
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
369
|
+
.lean()
|
|
370
|
+
.exec();
|
|
371
|
+
});
|
|
372
|
+
}
|
|
278
373
|
}
|
|
279
374
|
exports.MemberRepo = MemberRepo;
|
|
@@ -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 };
|