@chevre/domain 23.2.0-alpha.40 → 23.2.0-alpha.41
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/offerCatalog/upsertOfferCatalogItemsByIdentifier.ts +4 -1
- package/example/src/chevre/offerCatalog/upsertOfferCatalogsByIdentifier.ts +4 -1
- package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
- package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
- package/lib/chevre/repo/aggregateOffer.js +11 -3
- package/lib/chevre/repo/offerCatalog.d.ts +4 -0
- package/lib/chevre/repo/offerCatalog.js +9 -3
- package/lib/chevre/repo/offerCatalogItem.d.ts +4 -0
- package/lib/chevre/repo/offerCatalogItem.js +9 -3
- package/package.json +1 -1
package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
|
|
4
|
-
import { chevre } from '
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
5
|
|
|
6
6
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
7
|
const PRICE = 1234;
|
|
@@ -49,8 +49,10 @@ async function main() {
|
|
|
49
49
|
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
50
50
|
typeOf: chevre.factory.offerType.Offer
|
|
51
51
|
}
|
|
52
|
-
]
|
|
53
|
-
|
|
52
|
+
],
|
|
53
|
+
{
|
|
54
|
+
productType: chevre.factory.product.ProductType.EventService
|
|
55
|
+
}
|
|
54
56
|
);
|
|
55
57
|
// tslint:disable-next-line:no-null-keyword
|
|
56
58
|
console.dir(result, { depth: null });
|
|
@@ -74,7 +74,12 @@ export declare class AggregateOfferRepo {
|
|
|
74
74
|
/**
|
|
75
75
|
* コードをキーにして冪等置換(2023-12-13~)
|
|
76
76
|
*/
|
|
77
|
-
upsertByIdentifier(params: Omit<factory.unitPriceOffer.IUnitPriceOffer, 'id'>[]
|
|
77
|
+
upsertByIdentifier(params: Omit<factory.unitPriceOffer.IUnitPriceOffer, 'id'>[], options: {
|
|
78
|
+
/**
|
|
79
|
+
* プロダクトタイプでfilter(2026-01-30~)
|
|
80
|
+
*/
|
|
81
|
+
productType: factory.product.ProductType;
|
|
82
|
+
}): Promise<{
|
|
78
83
|
bulkWriteResult: BulkWriteResult;
|
|
79
84
|
modifiedOffers: {
|
|
80
85
|
id: string;
|
|
@@ -648,22 +648,30 @@ class AggregateOfferRepo {
|
|
|
648
648
|
/**
|
|
649
649
|
* コードをキーにして冪等置換(2023-12-13~)
|
|
650
650
|
*/
|
|
651
|
-
upsertByIdentifier(params) {
|
|
651
|
+
upsertByIdentifier(params, options) {
|
|
652
652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
653
|
+
const { productType } = options;
|
|
653
654
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
654
655
|
const insertBulkWriteOps = [];
|
|
655
656
|
// const updateBulkWriteOps: AnyBulkWriteOperation<factory.aggregateOffer.IAggregateOffer>[] = [];
|
|
656
657
|
const queryFilters = [];
|
|
657
658
|
if (Array.isArray(params)) {
|
|
658
659
|
params.forEach((p) => {
|
|
660
|
+
var _a;
|
|
661
|
+
// 指定されたproductTypeを強制する
|
|
662
|
+
if (((_a = p.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) !== productType) {
|
|
663
|
+
throw new factory.errors.Argument('itemOffered.typeOf', `not matched with productType: ${productType}`);
|
|
664
|
+
}
|
|
659
665
|
// リソースのユニークネスを保証するfilter
|
|
660
666
|
const filter = {
|
|
661
667
|
'project.id': { $eq: p.project.id },
|
|
662
|
-
'offers.identifier': { $exists: true, $eq: p.identifier }
|
|
668
|
+
'offers.identifier': { $exists: true, $eq: p.identifier },
|
|
669
|
+
'offers.itemOffered.typeOf': { $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
663
670
|
};
|
|
664
671
|
queryFilters.push({
|
|
665
672
|
'project.id': { $eq: p.project.id },
|
|
666
|
-
'offers.identifier': { $exists: true, $eq: p.identifier }
|
|
673
|
+
'offers.identifier': { $exists: true, $eq: p.identifier },
|
|
674
|
+
'offers.itemOffered.typeOf': { $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
667
675
|
});
|
|
668
676
|
const newOfferId = uniqid(); // setOnInsert時のみに利用する新ID
|
|
669
677
|
// サブオファー最適化(2023-12-22~)
|
|
@@ -40,6 +40,10 @@ export declare class OfferCatalogRepo {
|
|
|
40
40
|
* support only update(2026-01-30~)
|
|
41
41
|
*/
|
|
42
42
|
update: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* プロダクトタイプでfilter(2026-01-30~)
|
|
45
|
+
*/
|
|
46
|
+
productType: factory.product.ProductType;
|
|
43
47
|
}): Promise<{
|
|
44
48
|
bulkWriteResult: BulkWriteResult;
|
|
45
49
|
modifiedCatalogs: {
|
|
@@ -197,7 +197,7 @@ class OfferCatalogRepo {
|
|
|
197
197
|
*/
|
|
198
198
|
upsertManyByIdentifier(params, options) {
|
|
199
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const { update } = options;
|
|
200
|
+
const { productType, update } = options;
|
|
201
201
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
202
202
|
const bulkWriteOps = [];
|
|
203
203
|
const queryFilters = [];
|
|
@@ -207,14 +207,20 @@ class OfferCatalogRepo {
|
|
|
207
207
|
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
208
208
|
throw new factory.errors.ArgumentNull('identifier');
|
|
209
209
|
}
|
|
210
|
+
// 指定されたproductTypeを強制する
|
|
211
|
+
if (setFields.itemOffered.typeOf !== productType) {
|
|
212
|
+
throw new factory.errors.Argument('itemOffered.typeOf', `not matched with productType: ${productType}`);
|
|
213
|
+
}
|
|
210
214
|
// リソースのユニークネスを保証するfilter
|
|
211
215
|
const filter = {
|
|
212
216
|
'project.id': { $eq: project.id },
|
|
213
|
-
identifier: { $eq: identifier }
|
|
217
|
+
identifier: { $eq: identifier },
|
|
218
|
+
'itemOffered.typeOf': { $exists: true, $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
214
219
|
};
|
|
215
220
|
queryFilters.push({
|
|
216
221
|
'project.id': { $eq: project.id },
|
|
217
|
-
identifier: { $eq: identifier }
|
|
222
|
+
identifier: { $eq: identifier },
|
|
223
|
+
'itemOffered.typeOf': { $exists: true, $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
218
224
|
});
|
|
219
225
|
if (update === true) {
|
|
220
226
|
const updateOne = {
|
|
@@ -37,6 +37,10 @@ export declare class OfferCatalogItemRepo {
|
|
|
37
37
|
* support only update(2026-01-30~)
|
|
38
38
|
*/
|
|
39
39
|
update: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* プロダクトタイプでfilter(2026-01-30~)
|
|
42
|
+
*/
|
|
43
|
+
productType: factory.product.ProductType;
|
|
40
44
|
}): Promise<{
|
|
41
45
|
bulkWriteResult: BulkWriteResult;
|
|
42
46
|
modifiedCatalogs: {
|
|
@@ -161,7 +161,7 @@ class OfferCatalogItemRepo {
|
|
|
161
161
|
*/
|
|
162
162
|
upsertManyByIdentifier(params, options) {
|
|
163
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
const { update } = options;
|
|
164
|
+
const { productType, update } = options;
|
|
165
165
|
const bulkWriteOps = [];
|
|
166
166
|
const queryFilters = [];
|
|
167
167
|
if (Array.isArray(params)) {
|
|
@@ -170,14 +170,20 @@ class OfferCatalogItemRepo {
|
|
|
170
170
|
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
171
171
|
throw new factory.errors.ArgumentNull('identifier');
|
|
172
172
|
}
|
|
173
|
+
// 指定されたproductTypeを強制する
|
|
174
|
+
if (setFields.itemOffered.typeOf !== productType) {
|
|
175
|
+
throw new factory.errors.Argument('itemOffered.typeOf', `not matched with productType: ${productType}`);
|
|
176
|
+
}
|
|
173
177
|
// リソースのユニークネスを保証するfilter
|
|
174
178
|
const filter = {
|
|
175
179
|
'project.id': { $eq: project.id },
|
|
176
|
-
identifier: { $eq: identifier }
|
|
180
|
+
identifier: { $eq: identifier },
|
|
181
|
+
'itemOffered.typeOf': { $exists: true, $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
177
182
|
};
|
|
178
183
|
queryFilters.push({
|
|
179
184
|
'project.id': { $eq: project.id },
|
|
180
|
-
identifier: { $eq: identifier }
|
|
185
|
+
identifier: { $eq: identifier },
|
|
186
|
+
'itemOffered.typeOf': { $exists: true, $eq: productType } // プロダクトタイプを変更させないためにフィルター追加(2026-01-30~)
|
|
181
187
|
});
|
|
182
188
|
if (update === true) {
|
|
183
189
|
const updateOne = {
|
package/package.json
CHANGED