@chevre/domain 23.0.0-alpha.8 → 23.0.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/assetTransaction/processReserve.ts +102 -40
- package/example/src/chevre/categoryCode/checkUniqueness.ts +69 -0
- package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
- package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +121 -0
- package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
- package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
- package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
- package/example/src/chevre/product/findHasOfferCatalog.ts +31 -0
- package/example/src/chevre/reIndex.ts +2 -3
- package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
- package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
- package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
- package/example/src/objectId.ts +12 -0
- package/example/src/signPayload.ts +12 -7
- package/lib/chevre/errorHandler.d.ts +6 -2
- package/lib/chevre/errorHandler.js +18 -2
- package/lib/chevre/repo/categoryCode.d.ts +26 -14
- package/lib/chevre/repo/categoryCode.js +53 -42
- package/lib/chevre/repo/event.d.ts +25 -11
- package/lib/chevre/repo/event.js +60 -35
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
- package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
- package/lib/chevre/repo/issuer.js +9 -5
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
- package/lib/chevre/repo/movieTicketType.d.ts +57 -0
- package/lib/chevre/repo/movieTicketType.js +253 -0
- package/lib/chevre/repo/noteAboutOrder.d.ts +4 -11
- package/lib/chevre/repo/noteAboutOrder.js +16 -4
- package/lib/chevre/repo/offerCatalog.d.ts +17 -2
- package/lib/chevre/repo/offerCatalog.js +5 -2
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -139
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
- package/lib/chevre/service/offer/onEventChanged.js +26 -30
- package/lib/chevre/service/project.d.ts +3 -0
- package/lib/chevre/service/project.js +2 -1
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +4 -4
- package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
- package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
- package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
- package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
- package/example/src/chevre/searchPaymentServices.ts +0 -32
- package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
- package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
|
@@ -0,0 +1,31 @@
|
|
|
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 productHasOfferCatalogRepo = await chevre.repository.ProductHasOfferCatalog.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const offerCatalogs = (await productHasOfferCatalogRepo.findOfferCatalogs(
|
|
15
|
+
{
|
|
16
|
+
limit: 10,
|
|
17
|
+
page: 1,
|
|
18
|
+
project: { id: { $eq: project.id } },
|
|
19
|
+
product: { id: { $in: ['656038908b1cd5ce629f5992', '60c1c0031fb182000bed5eff'] } }
|
|
20
|
+
}
|
|
21
|
+
));
|
|
22
|
+
// tslint:disable-next-line:no-null-keyword
|
|
23
|
+
console.dir(offerCatalogs, { depth: null });
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw await chevre.errorHandler.handleMongoError(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main()
|
|
30
|
+
.then()
|
|
31
|
+
.catch(console.error);
|
|
@@ -11,9 +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.
|
|
15
|
-
await chevre.repository.
|
|
16
|
-
await chevre.repository.ProductOffer.createInstance(mongoose.connection);
|
|
14
|
+
await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
15
|
+
// await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
|
|
17
16
|
console.log('success!');
|
|
18
17
|
}
|
|
19
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
|
+
const roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager
|
|
13
|
+
// chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
// chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
+
];
|
|
16
|
+
const permissions = [
|
|
17
|
+
'admin.notes.*'
|
|
18
|
+
];
|
|
19
|
+
for (const roleName of roleNames) {
|
|
20
|
+
for (const permission of permissions) {
|
|
21
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
22
|
+
roleName: { $eq: roleName },
|
|
23
|
+
permission
|
|
24
|
+
});
|
|
25
|
+
console.log('permission added.', result, roleName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// roleNames = [
|
|
30
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
31
|
+
// ];
|
|
32
|
+
// permissions = [
|
|
33
|
+
// 'admin.sellers.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);
|
|
@@ -8,29 +8,14 @@ async function main() {
|
|
|
8
8
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const roleNames = [
|
|
12
12
|
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
13
|
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
-
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
-
];
|
|
16
|
-
let permissions = [
|
|
17
|
-
'admin.sellers.productOffers.*'
|
|
18
|
-
];
|
|
19
|
-
for (const roleName of roleNames) {
|
|
20
|
-
for (const permission of permissions) {
|
|
21
|
-
const result = await roleRepo.addPermissionIfNotExists({
|
|
22
|
-
roleName: { $eq: roleName },
|
|
23
|
-
permission
|
|
24
|
-
});
|
|
25
|
-
console.log('permission added.', result, roleName);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
roleNames = [
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
30
15
|
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
31
16
|
];
|
|
32
|
-
permissions = [
|
|
33
|
-
'admin.
|
|
17
|
+
const permissions = [
|
|
18
|
+
'admin.paymentServices.read'
|
|
34
19
|
];
|
|
35
20
|
for (const roleName of roleNames) {
|
|
36
21
|
for (const permission of permissions) {
|
|
@@ -41,6 +26,22 @@ async function main() {
|
|
|
41
26
|
console.log('permission added.', result, roleName);
|
|
42
27
|
}
|
|
43
28
|
}
|
|
29
|
+
|
|
30
|
+
// roleNames = [
|
|
31
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
32
|
+
// ];
|
|
33
|
+
// permissions = [
|
|
34
|
+
// 'admin.sellers.productOffers.read'
|
|
35
|
+
// ];
|
|
36
|
+
// for (const roleName of roleNames) {
|
|
37
|
+
// for (const permission of permissions) {
|
|
38
|
+
// const result = await roleRepo.addPermissionIfNotExists({
|
|
39
|
+
// roleName: { $eq: roleName },
|
|
40
|
+
// permission
|
|
41
|
+
// });
|
|
42
|
+
// console.log('permission added.', result, roleName);
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
main()
|
|
@@ -0,0 +1,33 @@
|
|
|
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.InventoryManager
|
|
13
|
+
// chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
// chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
15
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
|
+
];
|
|
17
|
+
const permissions = [
|
|
18
|
+
'admin.productHasOfferCatalog.read'
|
|
19
|
+
];
|
|
20
|
+
for (const roleName of roleNames) {
|
|
21
|
+
for (const permission of permissions) {
|
|
22
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
23
|
+
roleName: { $eq: roleName },
|
|
24
|
+
permission
|
|
25
|
+
});
|
|
26
|
+
console.log('permission added.', result, roleName);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
main()
|
|
32
|
+
.then()
|
|
33
|
+
.catch(console.error);
|
|
@@ -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
|
+
const roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
+
];
|
|
16
|
+
const permissions = [
|
|
17
|
+
'admin.sellers.events.*'
|
|
18
|
+
];
|
|
19
|
+
for (const roleName of roleNames) {
|
|
20
|
+
for (const permission of permissions) {
|
|
21
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
22
|
+
roleName: { $eq: roleName },
|
|
23
|
+
permission
|
|
24
|
+
});
|
|
25
|
+
console.log('permission added.', result, roleName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// roleNames = [
|
|
30
|
+
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
31
|
+
// ];
|
|
32
|
+
// permissions = [
|
|
33
|
+
// 'admin.sellers.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,7 +9,7 @@ async function main() {
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
const permissions = [
|
|
12
|
-
'
|
|
12
|
+
'products.read'
|
|
13
13
|
];
|
|
14
14
|
for (const permission of permissions) {
|
|
15
15
|
const roles = await roleRepo.projectFields(
|
|
@@ -9,12 +9,7 @@ async function main() {
|
|
|
9
9
|
const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
const permissions = [
|
|
12
|
-
'
|
|
13
|
-
'authorizations.create',
|
|
14
|
-
'permits.read',
|
|
15
|
-
'tasks.read',
|
|
16
|
-
'transactionNumbers.write',
|
|
17
|
-
'chevre.admin'
|
|
12
|
+
'admin.sellers.productOffers.*'
|
|
18
13
|
];
|
|
19
14
|
for (const permission of permissions) {
|
|
20
15
|
const roles = await roleRepo.projectFields(
|
|
@@ -9,18 +9,16 @@ 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 noteRepo = await chevre.repository.NoteAboutOrder.createInstance(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
let updateResult: any;
|
|
15
15
|
|
|
16
|
-
updateResult = await
|
|
16
|
+
updateResult = await noteRepo.unsetUnnecessaryFields({
|
|
17
17
|
filter: {
|
|
18
|
-
|
|
19
|
-
// 'location.maximumAttendeeCapacity': { $exists: true },
|
|
20
|
-
maximumPhysicalAttendeeCapacity: { $exists: true }
|
|
18
|
+
'about.identifier': { $exists: true }
|
|
21
19
|
},
|
|
22
|
-
$unset:
|
|
23
|
-
'
|
|
20
|
+
$unset: {
|
|
21
|
+
'about.identifier': 1
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
24
|
console.log(updateResult);
|
|
@@ -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);
|
|
@@ -3,13 +3,18 @@ import * as jwt from 'jsonwebtoken';
|
|
|
3
3
|
|
|
4
4
|
async function main(): Promise<void> {
|
|
5
5
|
const payload = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
/**
|
|
7
|
+
* アプリケーションオファーコード
|
|
8
|
+
*/
|
|
9
|
+
identifier: 'LegacyReservation',
|
|
10
|
+
validFrom: '2025-10-20T00:00:00Z',
|
|
11
|
+
validThrough: '2025-10-25T00:00:00Z',
|
|
12
|
+
eligibleQuantity: { maxValue: 1 },
|
|
13
|
+
itemOffered: {
|
|
14
|
+
/**
|
|
15
|
+
* イベント識別子
|
|
16
|
+
*/
|
|
17
|
+
identifier: '251025001001010900'
|
|
13
18
|
}
|
|
14
19
|
};
|
|
15
20
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://www.mongodb.com/ja-jp/docs/manual/reference/error-codes/
|
|
3
|
+
*/
|
|
1
4
|
export declare enum MongoErrorCode {
|
|
2
|
-
|
|
5
|
+
ConflictUpdateOperator = 40,
|
|
3
6
|
MaxTimeMSExpired = 50,
|
|
4
|
-
ExceededTimeLimit = 262
|
|
7
|
+
ExceededTimeLimit = 262,
|
|
8
|
+
DuplicateKey = 11000
|
|
5
9
|
}
|
|
6
10
|
export declare function isMongoError(error: unknown): Promise<boolean>;
|
|
7
11
|
export declare function handleMongoError(error: unknown): Promise<unknown>;
|
|
@@ -24,11 +24,16 @@ exports.handleAWSError = handleAWSError;
|
|
|
24
24
|
const http_status_1 = require("http-status");
|
|
25
25
|
const factory_1 = require("./factory");
|
|
26
26
|
let mongo;
|
|
27
|
+
let mongooseError;
|
|
28
|
+
/**
|
|
29
|
+
* https://www.mongodb.com/ja-jp/docs/manual/reference/error-codes/
|
|
30
|
+
*/
|
|
27
31
|
var MongoErrorCode;
|
|
28
32
|
(function (MongoErrorCode) {
|
|
29
|
-
MongoErrorCode[MongoErrorCode["
|
|
33
|
+
MongoErrorCode[MongoErrorCode["ConflictUpdateOperator"] = 40] = "ConflictUpdateOperator";
|
|
30
34
|
MongoErrorCode[MongoErrorCode["MaxTimeMSExpired"] = 50] = "MaxTimeMSExpired";
|
|
31
35
|
MongoErrorCode[MongoErrorCode["ExceededTimeLimit"] = 262] = "ExceededTimeLimit";
|
|
36
|
+
MongoErrorCode[MongoErrorCode["DuplicateKey"] = 11000] = "DuplicateKey";
|
|
32
37
|
})(MongoErrorCode || (exports.MongoErrorCode = MongoErrorCode = {}));
|
|
33
38
|
function isMongoError(error) {
|
|
34
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40,15 +45,21 @@ function isMongoError(error) {
|
|
|
40
45
|
}
|
|
41
46
|
function handleMongoError(error) {
|
|
42
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
var _a;
|
|
43
49
|
if (mongo === undefined) {
|
|
44
50
|
mongo = (yield Promise.resolve().then(() => require('mongoose'))).mongo;
|
|
45
51
|
}
|
|
52
|
+
if (mongooseError === undefined) {
|
|
53
|
+
mongooseError = (yield Promise.resolve().then(() => require('mongoose'))).Error;
|
|
54
|
+
}
|
|
46
55
|
let handledError = error;
|
|
47
56
|
if (handledError instanceof mongo.MongoError || handledError instanceof mongo.MongoServerError) {
|
|
48
57
|
switch (handledError.code) {
|
|
58
|
+
case MongoErrorCode.ConflictUpdateOperator:
|
|
59
|
+
handledError = new factory_1.errors.Argument('', `Some updating fields conflict. code:${handledError.code} message:${handledError.message}`);
|
|
60
|
+
break;
|
|
49
61
|
case MongoErrorCode.DuplicateKey:
|
|
50
62
|
handledError = new factory_1.errors.AlreadyInUse('', [], `Some fields already in use. code:${handledError.code} message:${handledError.message}`);
|
|
51
|
-
// no op
|
|
52
63
|
break;
|
|
53
64
|
case MongoErrorCode.MaxTimeMSExpired:
|
|
54
65
|
case MongoErrorCode.ExceededTimeLimit:
|
|
@@ -60,6 +71,11 @@ function handleMongoError(error) {
|
|
|
60
71
|
if (mongo.BSON.BSONError.isBSONError(handledError)) {
|
|
61
72
|
handledError = new factory_1.errors.Argument('', handledError.message);
|
|
62
73
|
}
|
|
74
|
+
// handle CastError(2025-10-27~)
|
|
75
|
+
// CastError: Cast to ObjectId failed for value "xxx" (type string) at path "_id" for model "xxxxxxxxxxxxx"
|
|
76
|
+
if (handledError instanceof mongooseError.CastError) {
|
|
77
|
+
handledError = new factory_1.errors.Argument(`${(_a = handledError.model) === null || _a === void 0 ? void 0 : _a.modelName}.${handledError.path}`, (handledError.reason instanceof Error) ? handledError.reason.message : handledError.message);
|
|
78
|
+
}
|
|
63
79
|
return handledError;
|
|
64
80
|
});
|
|
65
81
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AnyExpression, Connection, FilterQuery, Types } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode;
|
|
4
3
|
type IUnset = {
|
|
5
|
-
[key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image'
|
|
4
|
+
[key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image'>]?: 1;
|
|
6
5
|
};
|
|
6
|
+
export type CategorySetIdentifierExceptMovieTicketType = factory.categoryCode.CategorySetIdentifier;
|
|
7
|
+
export type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'inCodeSet'>;
|
|
8
|
+
type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode;
|
|
9
|
+
type IKeyOfProjectionExceptMovieTicketType = keyof ICategoryCodeExceptMovieTicketType;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* 区分(決済カード区分を除く)リポジトリ
|
|
9
12
|
*/
|
|
10
13
|
export declare class CategoryCodeRepo {
|
|
11
14
|
private readonly categoryCodeModel;
|
|
@@ -15,41 +18,50 @@ export declare class CategoryCodeRepo {
|
|
|
15
18
|
[field: string]: AnyExpression;
|
|
16
19
|
};
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* 区分集計検索(publicな属性検索が目的)
|
|
19
22
|
*/
|
|
20
|
-
|
|
23
|
+
findCategoryCodesByAggregate(conditions: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjectionExceptMovieTicketType[]): Promise<(ICategoryCodeExceptMovieTicketType & {
|
|
24
|
+
id: string;
|
|
25
|
+
})[]>;
|
|
21
26
|
/**
|
|
22
|
-
*
|
|
27
|
+
* 区分検索
|
|
23
28
|
*/
|
|
24
|
-
|
|
29
|
+
projectCategoryCodeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet'> & {
|
|
30
|
+
inCodeSet?: {
|
|
31
|
+
identifier?: {
|
|
32
|
+
$eq?: CategorySetIdentifierExceptMovieTicketType;
|
|
33
|
+
$in?: CategorySetIdentifierExceptMovieTicketType[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
},
|
|
25
37
|
/**
|
|
26
38
|
* 空の場合無効
|
|
27
39
|
*/
|
|
28
|
-
inclusion: IKeyOfProjection[]): Promise<(
|
|
40
|
+
inclusion: IKeyOfProjection[]): Promise<(ICategoryCodeExceptMovieTicketType & {
|
|
29
41
|
id: string;
|
|
30
42
|
})[]>;
|
|
31
|
-
|
|
43
|
+
saveCategoryCode(params: {
|
|
32
44
|
id?: string;
|
|
33
|
-
attributes:
|
|
45
|
+
attributes: ICategoryCodeExceptMovieTicketType & {
|
|
34
46
|
$unset?: IUnset;
|
|
35
47
|
};
|
|
36
48
|
}): Promise<{
|
|
37
49
|
id: string;
|
|
38
50
|
}>;
|
|
39
|
-
|
|
40
|
-
attributes:
|
|
51
|
+
saveCategoryCodesByCodeValue(params: {
|
|
52
|
+
attributes: ICategoryCodeExceptMovieTicketType;
|
|
41
53
|
upsert?: boolean;
|
|
42
54
|
}[]): Promise<void>;
|
|
43
55
|
/**
|
|
44
56
|
* 削除する
|
|
45
57
|
*/
|
|
46
|
-
|
|
58
|
+
deleteCategoryCodeById(params: {
|
|
47
59
|
id: string;
|
|
48
60
|
}): Promise<void>;
|
|
49
61
|
/**
|
|
50
62
|
* プロジェクト指定で削除する
|
|
51
63
|
*/
|
|
52
|
-
|
|
64
|
+
deleteCategoryCodesByProject(params: {
|
|
53
65
|
project: {
|
|
54
66
|
id: string;
|
|
55
67
|
};
|