@chevre/domain 24.0.0 → 24.1.0-alpha.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.
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
import type { Connection
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
|
-
import { IProductModel } from './mongoose/schemas/productModel';
|
|
4
|
-
type IKeyOfProjection = keyof IProductModel | '_id';
|
|
5
|
-
type ISearchConditions = Pick<factory.product.ISearchConditions, 'id' | 'limit' | 'page' | 'project'> & {
|
|
6
|
-
category?: {
|
|
7
|
-
codeValue?: {
|
|
8
|
-
$in?: string[];
|
|
9
|
-
};
|
|
10
|
-
inCodeSet?: {
|
|
11
|
-
identifier?: {
|
|
12
|
-
$eq?: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
3
|
/**
|
|
18
4
|
* プロダクトモデルリポジトリ
|
|
19
5
|
*/
|
|
20
6
|
export declare class ProductModelRepo {
|
|
21
7
|
private readonly productModelModel;
|
|
22
8
|
constructor(connection: Connection);
|
|
23
|
-
static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<factory.product.IProduct>[];
|
|
24
|
-
search(conditions: ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<IProductModel[]>;
|
|
25
|
-
deleteById(params: {
|
|
26
|
-
id: string;
|
|
27
|
-
}): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* プロダクトを保管する
|
|
30
|
-
*/
|
|
31
|
-
save(params: {
|
|
32
|
-
/**
|
|
33
|
-
* idを指定すれば更新
|
|
34
|
-
*/
|
|
35
|
-
id?: string;
|
|
36
|
-
$set: Omit<IProductModel, 'id'> & {
|
|
37
|
-
id?: never;
|
|
38
|
-
};
|
|
39
|
-
}): Promise<{
|
|
40
|
-
id: string;
|
|
41
|
-
}>;
|
|
42
9
|
/**
|
|
43
10
|
* 区分から同期する
|
|
44
11
|
*/
|
|
@@ -57,9 +24,4 @@ export declare class ProductModelRepo {
|
|
|
57
24
|
id: string;
|
|
58
25
|
};
|
|
59
26
|
}): Promise<void>;
|
|
60
|
-
unsetUnnecessaryFields(params: {
|
|
61
|
-
filter: any;
|
|
62
|
-
$unset: any;
|
|
63
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
64
27
|
}
|
|
65
|
-
export {};
|
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProductModelRepo = void 0;
|
|
4
4
|
const factory_1 = require("../factory");
|
|
5
|
-
|
|
5
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
6
6
|
const productModel_1 = require("./mongoose/schemas/productModel");
|
|
7
|
+
// type IKeyOfProjection = keyof IProductModel | '_id';
|
|
8
|
+
// type ISearchConditions = Pick<factory.product.ISearchConditions, 'id' | 'limit' | 'page' | 'project'> & {
|
|
9
|
+
// category?: {
|
|
10
|
+
// codeValue?: { $in?: string[] };
|
|
11
|
+
// inCodeSet?: { identifier?: { $eq?: string } };
|
|
12
|
+
// };
|
|
13
|
+
// };
|
|
7
14
|
/**
|
|
8
15
|
* プロダクトモデルリポジトリ
|
|
9
16
|
*/
|
|
@@ -12,97 +19,112 @@ class ProductModelRepo {
|
|
|
12
19
|
constructor(connection) {
|
|
13
20
|
this.productModelModel = connection.model(productModel_1.modelName, (0, productModel_1.createSchema)());
|
|
14
21
|
}
|
|
15
|
-
static CREATE_MONGO_CONDITIONS(params) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
async search(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
22
|
+
// public static CREATE_MONGO_CONDITIONS(params: ISearchConditions) {
|
|
23
|
+
// // MongoDB検索条件
|
|
24
|
+
// const andConditions: FilterQuery<factory.product.IProduct>[] = [];
|
|
25
|
+
// const projectIdEq = params.project?.id?.$eq;
|
|
26
|
+
// if (typeof projectIdEq === 'string') {
|
|
27
|
+
// andConditions.push({
|
|
28
|
+
// 'project.id': { $eq: projectIdEq }
|
|
29
|
+
// });
|
|
30
|
+
// }
|
|
31
|
+
// const idEq = params.id?.$eq;
|
|
32
|
+
// if (typeof idEq === 'string') {
|
|
33
|
+
// andConditions.push({ _id: { $eq: idEq } });
|
|
34
|
+
// }
|
|
35
|
+
// const idIn = params.id?.$in;
|
|
36
|
+
// if (Array.isArray(idIn)) {
|
|
37
|
+
// andConditions.push({ _id: { $in: idIn } });
|
|
38
|
+
// }
|
|
39
|
+
// const categoryCodeValueIn = params.category?.codeValue?.$in;
|
|
40
|
+
// if (Array.isArray(categoryCodeValueIn)) {
|
|
41
|
+
// andConditions.push({ 'category.codeValue': { $exists: true, $in: categoryCodeValueIn } });
|
|
42
|
+
// }
|
|
43
|
+
// const categoryInCodeSetIdentifierEq = params.category?.inCodeSet?.identifier?.$eq;
|
|
44
|
+
// if (typeof categoryInCodeSetIdentifierEq === 'string') {
|
|
45
|
+
// andConditions.push({ 'category.inCodeSet.identifier': { $exists: true, $eq: categoryInCodeSetIdentifierEq } });
|
|
46
|
+
// }
|
|
47
|
+
// return andConditions;
|
|
48
|
+
// }
|
|
49
|
+
// public async search(
|
|
50
|
+
// conditions: ISearchConditions,
|
|
51
|
+
// inclusion: IKeyOfProjection[],
|
|
52
|
+
// exclusion: IKeyOfProjection[]
|
|
53
|
+
// ): Promise<IProductModel[]> {
|
|
54
|
+
// const andConditions = ProductModelRepo.CREATE_MONGO_CONDITIONS(conditions);
|
|
55
|
+
// let projection: Record<string, number> = {};
|
|
56
|
+
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
57
|
+
// inclusion.forEach((field) => {
|
|
58
|
+
// projection[field] = 1;
|
|
59
|
+
// });
|
|
60
|
+
// } else {
|
|
61
|
+
// projection = {
|
|
62
|
+
// __v: 0,
|
|
63
|
+
// createdAt: 0,
|
|
64
|
+
// updatedAt: 0
|
|
65
|
+
// };
|
|
66
|
+
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
67
|
+
// exclusion.forEach((field) => {
|
|
68
|
+
// projection[field] = 0;
|
|
69
|
+
// });
|
|
70
|
+
// }
|
|
71
|
+
// }
|
|
72
|
+
// const query = this.productModelModel.find(
|
|
73
|
+
// (andConditions.length > 0) ? { $and: andConditions } : {},
|
|
74
|
+
// projection
|
|
75
|
+
// );
|
|
76
|
+
// if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
77
|
+
// const page: number = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
78
|
+
// query.limit(conditions.limit)
|
|
79
|
+
// .skip(conditions.limit * (page - 1));
|
|
80
|
+
// }
|
|
81
|
+
// // if (conditions.sort?.productID !== undefined) {
|
|
82
|
+
// // query.sort({ productID: conditions.sort.productID });
|
|
83
|
+
// // }
|
|
84
|
+
// return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
85
|
+
// .exec()
|
|
86
|
+
// .then((docs) => docs.map((doc) => doc.toObject({ virtuals: true })));
|
|
87
|
+
// }
|
|
88
|
+
// public async deleteById(params: { id: string }) {
|
|
89
|
+
// await this.productModelModel.findOneAndDelete({ _id: params.id })
|
|
90
|
+
// .exec();
|
|
91
|
+
// }
|
|
92
|
+
// /**
|
|
93
|
+
// * プロダクトを保管する
|
|
94
|
+
// */
|
|
95
|
+
// public async save(params: {
|
|
96
|
+
// /**
|
|
97
|
+
// * idを指定すれば更新
|
|
98
|
+
// */
|
|
99
|
+
// id?: string;
|
|
100
|
+
// $set: Omit<IProductModel, 'id'> & { id?: never };
|
|
101
|
+
// }): Promise<{ id: string }> {
|
|
102
|
+
// let savedId: string;
|
|
103
|
+
// if (typeof params.id === 'string') {
|
|
104
|
+
// // 上書き禁止属性を除外
|
|
105
|
+
// const { category, id, project, typeOf, ...setFields } = params.$set; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
106
|
+
// const updatedDoc = await this.productModelModel.findOneAndUpdate(
|
|
107
|
+
// { _id: { $eq: params.id } },
|
|
108
|
+
// {
|
|
109
|
+
// $set: setFields
|
|
110
|
+
// },
|
|
111
|
+
// { upsert: false, new: true, projection: { _id: 1 } }
|
|
112
|
+
// )
|
|
113
|
+
// .exec();
|
|
114
|
+
// if (updatedDoc === null) {
|
|
115
|
+
// throw new factory.errors.NotFound(this.productModelModel.modelName);
|
|
116
|
+
// }
|
|
117
|
+
// savedId = updatedDoc.id;
|
|
118
|
+
// } else {
|
|
119
|
+
// const { id, ...createParams } = params.$set; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
120
|
+
// const createdDoc = await this.productModelModel.create(createParams);
|
|
121
|
+
// savedId = createdDoc.id;
|
|
122
|
+
// }
|
|
123
|
+
// // if (doc === null) {
|
|
124
|
+
// // throw new factory.errors.NotFound(this.productModelModel.modelName);
|
|
125
|
+
// // }
|
|
126
|
+
// return { id: savedId };
|
|
127
|
+
// }
|
|
106
128
|
/**
|
|
107
129
|
* 区分から同期する
|
|
108
130
|
*/
|
|
@@ -144,9 +166,5 @@ class ProductModelRepo {
|
|
|
144
166
|
})
|
|
145
167
|
.exec();
|
|
146
168
|
}
|
|
147
|
-
async unsetUnnecessaryFields(params) {
|
|
148
|
-
return this.productModelModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
149
|
-
.exec();
|
|
150
|
-
}
|
|
151
169
|
}
|
|
152
170
|
exports.ProductModelRepo = ProductModelRepo;
|
|
@@ -66,7 +66,6 @@ import type { PotentialActionRepo } from './repo/potentialAction';
|
|
|
66
66
|
import type { PriceSpecificationRepo } from './repo/priceSpecification';
|
|
67
67
|
import type { ProductRepo } from './repo/product';
|
|
68
68
|
import type { ProductHasOfferCatalogRepo } from './repo/productHasOfferCatalog';
|
|
69
|
-
import type { ProductModelRepo } from './repo/productModel';
|
|
70
69
|
import type { ProjectRepo } from './repo/project';
|
|
71
70
|
import type { ProjectMakesOfferRepo } from './repo/projectMakesOffer';
|
|
72
71
|
import type { OfferRateLimitRepo } from './repo/rateLimit/offer';
|
|
@@ -389,10 +388,6 @@ export type ProductHasOfferCatalog = ProductHasOfferCatalogRepo;
|
|
|
389
388
|
export declare namespace ProductHasOfferCatalog {
|
|
390
389
|
function createInstance(...params: ConstructorParameters<typeof ProductHasOfferCatalogRepo>): Promise<ProductHasOfferCatalogRepo>;
|
|
391
390
|
}
|
|
392
|
-
export type ProductModel = ProductModelRepo;
|
|
393
|
-
export declare namespace ProductModel {
|
|
394
|
-
function createInstance(...params: ConstructorParameters<typeof ProductModelRepo>): Promise<ProductModelRepo>;
|
|
395
|
-
}
|
|
396
391
|
export type Project = ProjectRepo;
|
|
397
392
|
export declare namespace Project {
|
|
398
393
|
function createInstance(...params: ConstructorParameters<typeof ProjectRepo>): Promise<ProjectRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
|
|
4
|
-
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.
|
|
4
|
+
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = void 0;
|
|
5
5
|
var AcceptedOffer;
|
|
6
6
|
(function (AcceptedOffer) {
|
|
7
7
|
let repo;
|
|
@@ -777,17 +777,6 @@ var ProductHasOfferCatalog;
|
|
|
777
777
|
}
|
|
778
778
|
ProductHasOfferCatalog.createInstance = createInstance;
|
|
779
779
|
})(ProductHasOfferCatalog || (exports.ProductHasOfferCatalog = ProductHasOfferCatalog = {}));
|
|
780
|
-
var ProductModel;
|
|
781
|
-
(function (ProductModel) {
|
|
782
|
-
let repo;
|
|
783
|
-
async function createInstance(...params) {
|
|
784
|
-
if (repo === undefined) {
|
|
785
|
-
repo = (await import('./repo/productModel.js')).ProductModelRepo;
|
|
786
|
-
}
|
|
787
|
-
return new repo(...params);
|
|
788
|
-
}
|
|
789
|
-
ProductModel.createInstance = createInstance;
|
|
790
|
-
})(ProductModel || (exports.ProductModel = ProductModel = {}));
|
|
791
780
|
var Project;
|
|
792
781
|
(function (Project) {
|
|
793
782
|
let repo;
|
package/package.json
CHANGED