@chevre/domain 23.0.0-alpha.13 → 23.0.0-alpha.14
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/categoryCode/findCategoryCodes.ts +29 -0
- package/example/src/chevre/roles/{addAdminProductReadPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +1 -1
- package/example/src/objectId.ts +12 -0
- package/lib/chevre/repo/categoryCode.d.ts +6 -2
- package/lib/chevre/repo/categoryCode.js +23 -11
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const categoryCodes = await categoryCodeRepo.projectFields(
|
|
14
|
+
{
|
|
15
|
+
limit: 100,
|
|
16
|
+
page: 1,
|
|
17
|
+
project: { id: { $eq: project.id } },
|
|
18
|
+
inCodeSet: { identifier: { $eq: chevre.factory.categoryCode.CategorySetIdentifier.MovieTicketType } }
|
|
19
|
+
},
|
|
20
|
+
[],
|
|
21
|
+
{ excludeMovieTicketType: false }
|
|
22
|
+
);
|
|
23
|
+
// tslint:disable-next-line:no-null-keyword
|
|
24
|
+
console.dir(categoryCodes.map(({ inCodeSet }) => inCodeSet.identifier), { depth: null });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main()
|
|
28
|
+
.then()
|
|
29
|
+
.catch(console.error);
|
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
16
|
];
|
|
17
17
|
const permissions = [
|
|
18
|
-
'admin.
|
|
18
|
+
'admin.paymentServices.read'
|
|
19
19
|
];
|
|
20
20
|
for (const roleName of roleNames) {
|
|
21
21
|
for (const permission of permissions) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
// tslint:disable:no-console no-magic-numbers no-null-keyword
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
// const MONGOLAB_URI = String(process.env.MONGOLAB_URI);
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
console.log(new mongoose.Types.ObjectId());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
main()
|
|
12
|
+
.catch(console.error);
|
|
@@ -10,7 +10,9 @@ type IUnset = {
|
|
|
10
10
|
export declare class CategoryCodeRepo {
|
|
11
11
|
private readonly categoryCodeModel;
|
|
12
12
|
constructor(connection: Connection);
|
|
13
|
-
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions
|
|
13
|
+
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions, options?: {
|
|
14
|
+
excludeMovieTicketType?: boolean;
|
|
15
|
+
}): FilterQuery<factory.categoryCode.ICategoryCode>[];
|
|
14
16
|
static CREATE_AGGREGATE_PROJECTION(inclusion: IKeyOfProjection[]): {
|
|
15
17
|
[field: string]: AnyExpression;
|
|
16
18
|
};
|
|
@@ -25,7 +27,9 @@ export declare class CategoryCodeRepo {
|
|
|
25
27
|
/**
|
|
26
28
|
* 空の場合無効
|
|
27
29
|
*/
|
|
28
|
-
inclusion: IKeyOfProjection[]
|
|
30
|
+
inclusion: IKeyOfProjection[], options?: {
|
|
31
|
+
excludeMovieTicketType?: boolean;
|
|
32
|
+
}): Promise<(factory.categoryCode.ICategoryCode & {
|
|
29
33
|
id: string;
|
|
30
34
|
})[]>;
|
|
31
35
|
save(params: {
|
|
@@ -36,9 +36,29 @@ class CategoryCodeRepo {
|
|
|
36
36
|
this.categoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
|
|
37
37
|
}
|
|
38
38
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
39
|
-
static CREATE_MONGO_CONDITIONS(params) {
|
|
39
|
+
static CREATE_MONGO_CONDITIONS(params, options) {
|
|
40
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
41
|
+
const excludeMovieTicketType = (options === null || options === void 0 ? void 0 : options.excludeMovieTicketType) === true;
|
|
41
42
|
const andConditions = [];
|
|
43
|
+
if (excludeMovieTicketType) {
|
|
44
|
+
andConditions.push({
|
|
45
|
+
'inCodeSet.identifier': {
|
|
46
|
+
$in: [
|
|
47
|
+
factory.categoryCode.CategorySetIdentifier.ContentRatingType,
|
|
48
|
+
factory.categoryCode.CategorySetIdentifier.CurrencyType,
|
|
49
|
+
factory.categoryCode.CategorySetIdentifier.CustomerType,
|
|
50
|
+
factory.categoryCode.CategorySetIdentifier.DistributorType,
|
|
51
|
+
factory.categoryCode.CategorySetIdentifier.MembershipType,
|
|
52
|
+
factory.categoryCode.CategorySetIdentifier.OfferCategoryType,
|
|
53
|
+
factory.categoryCode.CategorySetIdentifier.PaymentMethodType,
|
|
54
|
+
factory.categoryCode.CategorySetIdentifier.SeatingType,
|
|
55
|
+
factory.categoryCode.CategorySetIdentifier.ServiceType,
|
|
56
|
+
factory.categoryCode.CategorySetIdentifier.SoundFormatType,
|
|
57
|
+
factory.categoryCode.CategorySetIdentifier.VideoFormatType
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
42
62
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
43
63
|
/* istanbul ignore else */
|
|
44
64
|
if (params.project !== undefined && params.project !== null) {
|
|
@@ -99,7 +119,6 @@ class CategoryCodeRepo {
|
|
|
99
119
|
if (typeof params.inCodeSet.identifier.$eq === 'string') {
|
|
100
120
|
andConditions.push({
|
|
101
121
|
'inCodeSet.identifier': {
|
|
102
|
-
$exists: true,
|
|
103
122
|
$eq: params.inCodeSet.identifier.$eq
|
|
104
123
|
}
|
|
105
124
|
});
|
|
@@ -110,7 +129,6 @@ class CategoryCodeRepo {
|
|
|
110
129
|
if (Array.isArray(inCodeSetIdentifierIn)) {
|
|
111
130
|
andConditions.push({
|
|
112
131
|
'inCodeSet.identifier': {
|
|
113
|
-
$exists: true,
|
|
114
132
|
$in: inCodeSetIdentifierIn
|
|
115
133
|
}
|
|
116
134
|
});
|
|
@@ -207,18 +225,13 @@ class CategoryCodeRepo {
|
|
|
207
225
|
/**
|
|
208
226
|
* 空の場合無効
|
|
209
227
|
*/
|
|
210
|
-
inclusion) {
|
|
228
|
+
inclusion, options) {
|
|
211
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
const conditions = CategoryCodeRepo.CREATE_MONGO_CONDITIONS(params);
|
|
230
|
+
const conditions = CategoryCodeRepo.CREATE_MONGO_CONDITIONS(params, options);
|
|
213
231
|
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
214
232
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
215
233
|
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
216
234
|
}
|
|
217
|
-
else {
|
|
218
|
-
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
219
|
-
// positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
|
|
220
|
-
// }
|
|
221
|
-
}
|
|
222
235
|
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
223
236
|
const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
224
237
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
@@ -280,7 +293,6 @@ class CategoryCodeRepo {
|
|
|
280
293
|
'project.id': { $eq: p.attributes.project.id },
|
|
281
294
|
codeValue: { $eq: p.attributes.codeValue },
|
|
282
295
|
'inCodeSet.identifier': {
|
|
283
|
-
$exists: true,
|
|
284
296
|
$eq: p.attributes.inCodeSet.identifier
|
|
285
297
|
}
|
|
286
298
|
},
|
package/package.json
CHANGED