@chevre/domain 22.14.0-alpha.26 → 22.14.0-alpha.27
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/reIndex.ts +2 -1
- package/example/src/chevre/roles/addAdminProductOfferPermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -2
- package/lib/chevre/repo/mongoose/schemas/place.js +13 -14
- package/lib/chevre/repo/mongoose/schemas/productOffer.js +5 -0
- package/lib/chevre/repo/mongoose/schemas/seller.js +17 -6
- package/lib/chevre/repo/productOffer.d.ts +1 -1
- package/lib/chevre/repo/productOffer.js +11 -6
- package/package.json +3 -3
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +0 -48
|
@@ -11,7 +11,8 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
15
|
+
await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
15
16
|
await chevre.repository.ProductOffer.createInstance(mongoose.connection);
|
|
16
17
|
console.log('success!');
|
|
17
18
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
let roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager
|
|
13
|
+
];
|
|
14
|
+
let permissions = [
|
|
15
|
+
'admin.productOffers.*'
|
|
16
|
+
];
|
|
17
|
+
for (const roleName of roleNames) {
|
|
18
|
+
for (const permission of permissions) {
|
|
19
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
20
|
+
roleName: { $eq: roleName },
|
|
21
|
+
permission
|
|
22
|
+
});
|
|
23
|
+
console.log('permission added.', result, roleName);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
roleNames = [
|
|
28
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
29
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
30
|
+
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
31
|
+
];
|
|
32
|
+
permissions = [
|
|
33
|
+
'admin.productOffers.read'
|
|
34
|
+
];
|
|
35
|
+
for (const roleName of roleNames) {
|
|
36
|
+
for (const permission of permissions) {
|
|
37
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
38
|
+
roleName: { $eq: roleName },
|
|
39
|
+
permission
|
|
40
|
+
});
|
|
41
|
+
console.log('permission added.', result, roleName);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main()
|
|
47
|
+
.then()
|
|
48
|
+
.catch(console.error);
|
|
@@ -9,8 +9,7 @@ async function main() {
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
const permissions = [
|
|
12
|
-
'
|
|
13
|
-
'notes.read'
|
|
12
|
+
'eventOffers.*'
|
|
14
13
|
];
|
|
15
14
|
for (const permission of permissions) {
|
|
16
15
|
const roles = await roleRepo.projectFields(
|
|
@@ -25,7 +25,7 @@ const schemaDefinition = {
|
|
|
25
25
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
26
26
|
address: mongoose_1.SchemaTypes.Mixed,
|
|
27
27
|
branchCode: { type: String, required: true },
|
|
28
|
-
containedInPlace: mongoose_1.SchemaTypes.Mixed,
|
|
28
|
+
containedInPlace: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
29
29
|
containsPlace: [mongoose_1.SchemaTypes.Mixed],
|
|
30
30
|
maximumAttendeeCapacity: Number,
|
|
31
31
|
openingHoursSpecification: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -170,20 +170,19 @@ const indexes = [
|
|
|
170
170
|
'containedInPlace.branchCode': { $exists: true }
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
// unique index(2025-10-01~)
|
|
176
|
+
{
|
|
177
|
+
// 'project.id': 1,
|
|
178
|
+
'containedInPlace.id': 1, // 施設内ユニーク
|
|
179
|
+
branchCode: 1
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
unique: true,
|
|
183
|
+
name: 'uniqueBranchCode'
|
|
184
|
+
}
|
|
173
185
|
]
|
|
174
|
-
// [
|
|
175
|
-
// {
|
|
176
|
-
// typeOf: 1,
|
|
177
|
-
// 'project.id': 1,
|
|
178
|
-
// 'containedInPlace.branchCode': 1,
|
|
179
|
-
// branchCode: 1,
|
|
180
|
-
// 'containsPlace.branchCode': 1,
|
|
181
|
-
// 'containsPlace.containsPlace.branchCode': 1
|
|
182
|
-
// },
|
|
183
|
-
// {
|
|
184
|
-
// name: 'projectSeatsUsingSort'
|
|
185
|
-
// }
|
|
186
|
-
// ]
|
|
187
186
|
];
|
|
188
187
|
exports.indexes = indexes;
|
|
189
188
|
/**
|
|
@@ -12,6 +12,7 @@ const schemaDefinition = {
|
|
|
12
12
|
typeOf: { type: String, required: true },
|
|
13
13
|
identifier: { type: String, required: true },
|
|
14
14
|
itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
15
|
+
offeredBy: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
15
16
|
availability: { type: String, required: true },
|
|
16
17
|
validFrom: { type: Date, required: true },
|
|
17
18
|
validThrough: { type: Date, required: true },
|
|
@@ -71,6 +72,10 @@ const indexes = [
|
|
|
71
72
|
{ 'itemOffered.identifier': 1, validFrom: 1 },
|
|
72
73
|
{ name: 'itemOfferedIdentifier' }
|
|
73
74
|
],
|
|
75
|
+
[
|
|
76
|
+
{ 'offeredBy.id': 1, validFrom: 1 },
|
|
77
|
+
{ name: 'offeredById' }
|
|
78
|
+
],
|
|
74
79
|
[
|
|
75
80
|
{ validThrough: 1, validFrom: 1 },
|
|
76
81
|
{ name: 'validThrough' }
|
|
@@ -57,12 +57,12 @@ const indexes = [
|
|
|
57
57
|
{ typeOf: 1, branchCode: 1 },
|
|
58
58
|
{ name: 'searchByTypeOf' }
|
|
59
59
|
],
|
|
60
|
-
[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
],
|
|
60
|
+
// [
|
|
61
|
+
// { 'project.id': 1, branchCode: 1 },
|
|
62
|
+
// {
|
|
63
|
+
// name: 'searchByProjectId-v20220721'
|
|
64
|
+
// }
|
|
65
|
+
// ],
|
|
66
66
|
[
|
|
67
67
|
{ 'name.ja': 1, branchCode: 1 },
|
|
68
68
|
{
|
|
@@ -107,6 +107,17 @@ const indexes = [
|
|
|
107
107
|
'hasMerchantReturnPolicy.identifier': { $exists: true }
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
// unique index(2025-10-01~)
|
|
113
|
+
{
|
|
114
|
+
'project.id': 1,
|
|
115
|
+
branchCode: 1
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
unique: true,
|
|
119
|
+
name: 'uniqueBranchCode'
|
|
120
|
+
}
|
|
110
121
|
]
|
|
111
122
|
];
|
|
112
123
|
exports.indexes = indexes;
|
|
@@ -21,7 +21,7 @@ export declare class ProductOfferRepo {
|
|
|
21
21
|
* オファーコードとオファーコレクションコードをキーにして冪等置換
|
|
22
22
|
*/
|
|
23
23
|
upsertOffersByIdentifier(params: {
|
|
24
|
-
$set: Pick<IDocType, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'project' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
|
|
24
|
+
$set: Pick<IDocType, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'offeredBy' | 'project' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
|
|
25
25
|
id?: never;
|
|
26
26
|
};
|
|
27
27
|
$unset: IUnset;
|
|
@@ -17,6 +17,7 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
17
17
|
'identifier',
|
|
18
18
|
'project',
|
|
19
19
|
'itemOffered',
|
|
20
|
+
'offeredBy',
|
|
20
21
|
'typeOf',
|
|
21
22
|
'validFrom',
|
|
22
23
|
'validThrough',
|
|
@@ -32,7 +33,7 @@ class ProductOfferRepo {
|
|
|
32
33
|
this.productOfferModel = connection.model(productOffer_1.modelName, (0, productOffer_1.createSchema)());
|
|
33
34
|
}
|
|
34
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
36
37
|
const andConditions = [];
|
|
37
38
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
38
39
|
if (typeof idEq === 'string') {
|
|
@@ -58,15 +59,19 @@ class ProductOfferRepo {
|
|
|
58
59
|
if (Array.isArray(itemOfferedIdentifierIn)) {
|
|
59
60
|
andConditions.push({ 'itemOffered.identifier': { $in: itemOfferedIdentifierIn } });
|
|
60
61
|
}
|
|
61
|
-
const
|
|
62
|
+
const offeredByIdEq = (_l = (_k = params.offeredBy) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
63
|
+
if (typeof offeredByIdEq === 'string') {
|
|
64
|
+
andConditions.push({ 'offeredBy.id': { $eq: offeredByIdEq } });
|
|
65
|
+
}
|
|
66
|
+
const validForMemberTierIdentifierEq = (_o = (_m = params.validForMemberTier) === null || _m === void 0 ? void 0 : _m.identifier) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
62
67
|
if (typeof validForMemberTierIdentifierEq === 'string') {
|
|
63
68
|
andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
|
|
64
69
|
}
|
|
65
|
-
const validFromLte = (
|
|
70
|
+
const validFromLte = (_p = params.validFrom) === null || _p === void 0 ? void 0 : _p.$lte;
|
|
66
71
|
if (validFromLte instanceof Date) {
|
|
67
72
|
andConditions.push({ validFrom: { $lte: validFromLte } });
|
|
68
73
|
}
|
|
69
|
-
const validThroughGte = (
|
|
74
|
+
const validThroughGte = (_q = params.validThrough) === null || _q === void 0 ? void 0 : _q.$gte;
|
|
70
75
|
if (validThroughGte instanceof Date) {
|
|
71
76
|
andConditions.push({ validThrough: { $gte: validThroughGte } });
|
|
72
77
|
}
|
|
@@ -108,7 +113,7 @@ class ProductOfferRepo {
|
|
|
108
113
|
const queryFilters = [];
|
|
109
114
|
if (Array.isArray(params)) {
|
|
110
115
|
params.forEach(({ $set, $unset }) => {
|
|
111
|
-
const { availability, identifier, itemOffered, project, validFrom, validThrough, acceptedPaymentMethod, validForMemberTier } = $set;
|
|
116
|
+
const { availability, identifier, itemOffered, offeredBy, project, validFrom, validThrough, acceptedPaymentMethod, validForMemberTier } = $set;
|
|
112
117
|
if (typeof identifier !== 'string' || identifier === '') {
|
|
113
118
|
throw new factory.errors.ArgumentNull('identifier');
|
|
114
119
|
}
|
|
@@ -139,7 +144,7 @@ class ProductOfferRepo {
|
|
|
139
144
|
bulkWriteOps.push({ updateOne });
|
|
140
145
|
}
|
|
141
146
|
else {
|
|
142
|
-
const setOnInsert = Object.assign(Object.assign({ itemOffered, identifier, project, typeOf: factory.offerType.Offer, availability,
|
|
147
|
+
const setOnInsert = Object.assign(Object.assign({ itemOffered, offeredBy, identifier, project, typeOf: factory.offerType.Offer, availability,
|
|
143
148
|
validFrom,
|
|
144
149
|
validThrough }, (typeof (acceptedPaymentMethod === null || acceptedPaymentMethod === void 0 ? void 0 : acceptedPaymentMethod.typeOf) === 'string') ? { acceptedPaymentMethod } : undefined), (typeof (validForMemberTier === null || validForMemberTier === void 0 ? void 0 : validForMemberTier.typeOf) === 'string') ? { validForMemberTier } : undefined);
|
|
145
150
|
const updateFilter = {
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.399.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "12.
|
|
14
|
+
"@chevre/factory": "4.399.0-alpha.23",
|
|
15
|
+
"@cinerino/sdk": "12.3.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "22.14.0-alpha.
|
|
118
|
+
"version": "22.14.0-alpha.27"
|
|
119
119
|
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../../lib/index';
|
|
5
|
-
|
|
6
|
-
async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
-
|
|
9
|
-
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
-
|
|
11
|
-
const roleNames = [
|
|
12
|
-
chevre.factory.role.organizationRole.RoleName.AdminInventoryManager
|
|
13
|
-
];
|
|
14
|
-
const permissions = [
|
|
15
|
-
'admin.sellers.events.*'
|
|
16
|
-
];
|
|
17
|
-
for (const roleName of roleNames) {
|
|
18
|
-
for (const permission of permissions) {
|
|
19
|
-
const result = await roleRepo.addPermissionIfNotExists({
|
|
20
|
-
roleName: { $eq: roleName },
|
|
21
|
-
permission
|
|
22
|
-
});
|
|
23
|
-
console.log('permission added.', result, roleName);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// roleNames = [
|
|
28
|
-
// chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
29
|
-
// chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
30
|
-
// chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
31
|
-
// ];
|
|
32
|
-
// permissions = [
|
|
33
|
-
// 'admin.sellers.eventSeries.*'
|
|
34
|
-
// ];
|
|
35
|
-
// for (const roleName of roleNames) {
|
|
36
|
-
// for (const permission of permissions) {
|
|
37
|
-
// const result = await roleRepo.addPermissionIfNotExists({
|
|
38
|
-
// roleName: { $eq: roleName },
|
|
39
|
-
// permission
|
|
40
|
-
// });
|
|
41
|
-
// console.log('permission added.', result, roleName);
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
main()
|
|
47
|
-
.then()
|
|
48
|
-
.catch(console.error);
|