@chevre/domain 24.0.0 → 24.1.0-alpha.1
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/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +1 -12
- package/lib/chevre/service/task/onResourceDeleted.js +7 -8
- package/lib/chevre/service/task/onResourceUpdated.js +7 -8
- package/package.json +1 -1
- package/lib/chevre/repo/productModel.d.ts +0 -65
- package/lib/chevre/repo/productModel.js +0 -152
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.d.ts +0 -15
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +0 -16
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.d.ts +0 -15
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +0 -47
|
@@ -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;
|
|
@@ -17,7 +17,6 @@ const hasPOS_1 = require("../../repo/place/hasPOS");
|
|
|
17
17
|
const movieTheater_1 = require("../../repo/place/movieTheater");
|
|
18
18
|
const screeningRoom_1 = require("../../repo/place/screeningRoom");
|
|
19
19
|
const product_1 = require("../../repo/product");
|
|
20
|
-
const productModel_1 = require("../../repo/productModel");
|
|
21
20
|
const setting_1 = require("../../repo/setting");
|
|
22
21
|
const task_1 = require("../../repo/task");
|
|
23
22
|
const deleteResourcesByAggregateOffer_1 = require("./onResourceDeleted/deleteResourcesByAggregateOffer");
|
|
@@ -28,7 +27,7 @@ const deleteResourcesByProduct_1 = require("./onResourceDeleted/deleteResourcesB
|
|
|
28
27
|
const deleteResourcesByRoom_1 = require("./onResourceDeleted/deleteResourcesByRoom");
|
|
29
28
|
const deleteResourcesBySeller_1 = require("./onResourceDeleted/deleteResourcesBySeller");
|
|
30
29
|
const onHasPOSUpdated_1 = require("./onResourceUpdated/onHasPOSUpdated");
|
|
31
|
-
|
|
30
|
+
// import { syncCategoryCode } from './onResourceUpdated/syncCategoryCode';
|
|
32
31
|
const syncOfferCatalog_1 = require("./onResourceUpdated/syncOfferCatalog");
|
|
33
32
|
/**
|
|
34
33
|
* タスク実行関数
|
|
@@ -51,7 +50,6 @@ function call(params) {
|
|
|
51
50
|
paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
|
|
52
51
|
screeningRoom: new screeningRoom_1.ScreeningRoomRepo(connection),
|
|
53
52
|
product: new product_1.ProductRepo(connection),
|
|
54
|
-
productModel: new productModel_1.ProductModelRepo(connection),
|
|
55
53
|
setting: new setting_1.SettingRepo(connection),
|
|
56
54
|
task: new task_1.TaskRepo(connection)
|
|
57
55
|
});
|
|
@@ -136,11 +134,12 @@ function onResourceDeleted(params) {
|
|
|
136
134
|
break;
|
|
137
135
|
// 区分削除に対応(2024-04-18~)
|
|
138
136
|
case 'CategoryCode':
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
// discontinue sync to productModels(2026-04-30~)
|
|
138
|
+
// await syncCategoryCode({
|
|
139
|
+
// project: { id: params.project.id },
|
|
140
|
+
// ids: params.id,
|
|
141
|
+
// isDeleted: true
|
|
142
|
+
// })(repos);
|
|
144
143
|
break;
|
|
145
144
|
default:
|
|
146
145
|
// no op
|
|
@@ -20,11 +20,10 @@ const hasPOS_1 = require("../../repo/place/hasPOS");
|
|
|
20
20
|
const movieTheater_1 = require("../../repo/place/movieTheater");
|
|
21
21
|
const screeningRoom_1 = require("../../repo/place/screeningRoom");
|
|
22
22
|
const product_1 = require("../../repo/product");
|
|
23
|
-
const productModel_1 = require("../../repo/productModel");
|
|
24
23
|
const setting_1 = require("../../repo/setting");
|
|
25
24
|
const task_1 = require("../../repo/task");
|
|
26
25
|
const onAggregateOfferUpdated_1 = require("./onResourceUpdated/onAggregateOfferUpdated");
|
|
27
|
-
|
|
26
|
+
// import { onCategoryCodeUpdated } from './onResourceUpdated/onCategoryCodeUpdated';
|
|
28
27
|
const onHasPOSUpdated_1 = require("./onResourceUpdated/onHasPOSUpdated");
|
|
29
28
|
const onOfferCatalogUpdated_1 = require("./onResourceUpdated/onOfferCatalogUpdated");
|
|
30
29
|
/**
|
|
@@ -51,7 +50,6 @@ function call(data) {
|
|
|
51
50
|
paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
|
|
52
51
|
screeningRoom: new screeningRoom_1.ScreeningRoomRepo(connection),
|
|
53
52
|
product: new product_1.ProductRepo(connection),
|
|
54
|
-
productModel: new productModel_1.ProductModelRepo(connection),
|
|
55
53
|
setting: new setting_1.SettingRepo(connection),
|
|
56
54
|
task: new task_1.TaskRepo(connection)
|
|
57
55
|
});
|
|
@@ -170,11 +168,12 @@ function onResourceUpdated(params) {
|
|
|
170
168
|
break;
|
|
171
169
|
// 区分に対応(2024-04-18~)
|
|
172
170
|
case 'CategoryCode':
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
// discontinue sync to productModels(2026-04-30~)
|
|
172
|
+
// await onCategoryCodeUpdated({
|
|
173
|
+
// project: { id: params.project.id },
|
|
174
|
+
// ids: params.id,
|
|
175
|
+
// isDeleted: false
|
|
176
|
+
// })(repos);
|
|
178
177
|
break;
|
|
179
178
|
default:
|
|
180
179
|
// no op
|
package/package.json
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Connection, FilterQuery } from 'mongoose';
|
|
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
|
-
/**
|
|
18
|
-
* プロダクトモデルリポジトリ
|
|
19
|
-
*/
|
|
20
|
-
export declare class ProductModelRepo {
|
|
21
|
-
private readonly productModelModel;
|
|
22
|
-
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
|
-
/**
|
|
43
|
-
* 区分から同期する
|
|
44
|
-
*/
|
|
45
|
-
upsertByCategory(params: {
|
|
46
|
-
category: Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'inCodeSet' | 'name' | 'project'> & {
|
|
47
|
-
id: string;
|
|
48
|
-
};
|
|
49
|
-
}): Promise<{
|
|
50
|
-
id: string;
|
|
51
|
-
}>;
|
|
52
|
-
/**
|
|
53
|
-
* 区分から削除する
|
|
54
|
-
*/
|
|
55
|
-
deleteByCategory(params: {
|
|
56
|
-
category: Pick<factory.categoryCode.ICategoryCode, 'project'> & {
|
|
57
|
-
id: string;
|
|
58
|
-
};
|
|
59
|
-
}): Promise<void>;
|
|
60
|
-
unsetUnnecessaryFields(params: {
|
|
61
|
-
filter: any;
|
|
62
|
-
$unset: any;
|
|
63
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductModelRepo = void 0;
|
|
4
|
-
const factory_1 = require("../factory");
|
|
5
|
-
const settings_1 = require("../settings");
|
|
6
|
-
const productModel_1 = require("./mongoose/schemas/productModel");
|
|
7
|
-
/**
|
|
8
|
-
* プロダクトモデルリポジトリ
|
|
9
|
-
*/
|
|
10
|
-
class ProductModelRepo {
|
|
11
|
-
productModelModel;
|
|
12
|
-
constructor(connection) {
|
|
13
|
-
this.productModelModel = connection.model(productModel_1.modelName, (0, productModel_1.createSchema)());
|
|
14
|
-
}
|
|
15
|
-
static CREATE_MONGO_CONDITIONS(params) {
|
|
16
|
-
// MongoDB検索条件
|
|
17
|
-
const andConditions = [];
|
|
18
|
-
const projectIdEq = params.project?.id?.$eq;
|
|
19
|
-
if (typeof projectIdEq === 'string') {
|
|
20
|
-
andConditions.push({
|
|
21
|
-
'project.id': { $eq: projectIdEq }
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
const idEq = params.id?.$eq;
|
|
25
|
-
if (typeof idEq === 'string') {
|
|
26
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
27
|
-
}
|
|
28
|
-
const idIn = params.id?.$in;
|
|
29
|
-
if (Array.isArray(idIn)) {
|
|
30
|
-
andConditions.push({ _id: { $in: idIn } });
|
|
31
|
-
}
|
|
32
|
-
const categoryCodeValueIn = params.category?.codeValue?.$in;
|
|
33
|
-
if (Array.isArray(categoryCodeValueIn)) {
|
|
34
|
-
andConditions.push({ 'category.codeValue': { $exists: true, $in: categoryCodeValueIn } });
|
|
35
|
-
}
|
|
36
|
-
const categoryInCodeSetIdentifierEq = params.category?.inCodeSet?.identifier?.$eq;
|
|
37
|
-
if (typeof categoryInCodeSetIdentifierEq === 'string') {
|
|
38
|
-
andConditions.push({ 'category.inCodeSet.identifier': { $exists: true, $eq: categoryInCodeSetIdentifierEq } });
|
|
39
|
-
}
|
|
40
|
-
return andConditions;
|
|
41
|
-
}
|
|
42
|
-
async search(conditions, inclusion, exclusion) {
|
|
43
|
-
const andConditions = ProductModelRepo.CREATE_MONGO_CONDITIONS(conditions);
|
|
44
|
-
let projection = {};
|
|
45
|
-
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
46
|
-
inclusion.forEach((field) => {
|
|
47
|
-
projection[field] = 1;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
projection = {
|
|
52
|
-
__v: 0,
|
|
53
|
-
createdAt: 0,
|
|
54
|
-
updatedAt: 0
|
|
55
|
-
};
|
|
56
|
-
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
57
|
-
exclusion.forEach((field) => {
|
|
58
|
-
projection[field] = 0;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const query = this.productModelModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
63
|
-
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
64
|
-
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
65
|
-
query.limit(conditions.limit)
|
|
66
|
-
.skip(conditions.limit * (page - 1));
|
|
67
|
-
}
|
|
68
|
-
// if (conditions.sort?.productID !== undefined) {
|
|
69
|
-
// query.sort({ productID: conditions.sort.productID });
|
|
70
|
-
// }
|
|
71
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
72
|
-
.exec()
|
|
73
|
-
.then((docs) => docs.map((doc) => doc.toObject({ virtuals: true })));
|
|
74
|
-
}
|
|
75
|
-
async deleteById(params) {
|
|
76
|
-
await this.productModelModel.findOneAndDelete({ _id: params.id })
|
|
77
|
-
.exec();
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* プロダクトを保管する
|
|
81
|
-
*/
|
|
82
|
-
async save(params) {
|
|
83
|
-
let savedId;
|
|
84
|
-
if (typeof params.id === 'string') {
|
|
85
|
-
// 上書き禁止属性を除外
|
|
86
|
-
const { category, id, project, typeOf, ...setFields } = params.$set; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
87
|
-
const updatedDoc = await this.productModelModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
88
|
-
$set: setFields
|
|
89
|
-
}, { upsert: false, new: true, projection: { _id: 1 } })
|
|
90
|
-
.exec();
|
|
91
|
-
if (updatedDoc === null) {
|
|
92
|
-
throw new factory_1.factory.errors.NotFound(this.productModelModel.modelName);
|
|
93
|
-
}
|
|
94
|
-
savedId = updatedDoc.id;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
const { id, ...createParams } = params.$set; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
98
|
-
const createdDoc = await this.productModelModel.create(createParams);
|
|
99
|
-
savedId = createdDoc.id;
|
|
100
|
-
}
|
|
101
|
-
// if (doc === null) {
|
|
102
|
-
// throw new factory.errors.NotFound(this.productModelModel.modelName);
|
|
103
|
-
// }
|
|
104
|
-
return { id: savedId };
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 区分から同期する
|
|
108
|
-
*/
|
|
109
|
-
async upsertByCategory(params) {
|
|
110
|
-
const upsertingProductModel = {
|
|
111
|
-
project: { id: params.category.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
112
|
-
typeOf: 'ProductModel',
|
|
113
|
-
category: {
|
|
114
|
-
codeValue: params.category.codeValue,
|
|
115
|
-
inCodeSet: params.category.inCodeSet,
|
|
116
|
-
id: params.category.id
|
|
117
|
-
},
|
|
118
|
-
name: params.category.name,
|
|
119
|
-
offers: [{
|
|
120
|
-
typeOf: factory_1.factory.offerType.Offer
|
|
121
|
-
}]
|
|
122
|
-
};
|
|
123
|
-
const { project, typeOf, offers, category, ...setFields } = upsertingProductModel;
|
|
124
|
-
const doc = await this.productModelModel.findOneAndUpdate({
|
|
125
|
-
'project.id': { $eq: upsertingProductModel.project.id },
|
|
126
|
-
'category.id': { $exists: true, $eq: upsertingProductModel.category.id }
|
|
127
|
-
}, {
|
|
128
|
-
$setOnInsert: { project, typeOf, offers, category },
|
|
129
|
-
$set: setFields
|
|
130
|
-
}, { new: true, upsert: true, projection: { _id: 1 } })
|
|
131
|
-
.exec();
|
|
132
|
-
if (doc === null) {
|
|
133
|
-
throw new factory_1.factory.errors.NotFound(this.productModelModel.modelName);
|
|
134
|
-
}
|
|
135
|
-
return doc.toObject({ virtuals: true });
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 区分から削除する
|
|
139
|
-
*/
|
|
140
|
-
async deleteByCategory(params) {
|
|
141
|
-
await this.productModelModel.deleteMany({
|
|
142
|
-
'project.id': { $eq: params.category.project.id },
|
|
143
|
-
'category.id': { $exists: true, $eq: params.category.id }
|
|
144
|
-
})
|
|
145
|
-
.exec();
|
|
146
|
-
}
|
|
147
|
-
async unsetUnnecessaryFields(params) {
|
|
148
|
-
return this.productModelModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
149
|
-
.exec();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.ProductModelRepo = ProductModelRepo;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
2
|
-
import type { ProductModelRepo } from '../../../repo/productModel';
|
|
3
|
-
/**
|
|
4
|
-
* 区分変更時処理
|
|
5
|
-
*/
|
|
6
|
-
export declare function onCategoryCodeUpdated(params: {
|
|
7
|
-
project: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
ids: string[];
|
|
11
|
-
isDeleted: boolean;
|
|
12
|
-
}): (repos: {
|
|
13
|
-
categoryCode: CategoryCodeRepo;
|
|
14
|
-
productModel: ProductModelRepo;
|
|
15
|
-
}) => Promise<void>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onCategoryCodeUpdated = onCategoryCodeUpdated;
|
|
4
|
-
const syncCategoryCode_1 = require("./syncCategoryCode");
|
|
5
|
-
/**
|
|
6
|
-
* 区分変更時処理
|
|
7
|
-
*/
|
|
8
|
-
function onCategoryCodeUpdated(params) {
|
|
9
|
-
return async (repos) => {
|
|
10
|
-
await (0, syncCategoryCode_1.syncCategoryCode)({
|
|
11
|
-
project: { id: params.project.id },
|
|
12
|
-
ids: params.ids,
|
|
13
|
-
isDeleted: false
|
|
14
|
-
})(repos);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
2
|
-
import type { ProductModelRepo } from '../../../repo/productModel';
|
|
3
|
-
/**
|
|
4
|
-
* 区分を他リソースへ同期する
|
|
5
|
-
*/
|
|
6
|
-
export declare function syncCategoryCode(params: {
|
|
7
|
-
project: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
ids: string[];
|
|
11
|
-
isDeleted: boolean;
|
|
12
|
-
}): (repos: {
|
|
13
|
-
categoryCode: CategoryCodeRepo;
|
|
14
|
-
productModel: ProductModelRepo;
|
|
15
|
-
}) => Promise<void>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.syncCategoryCode = syncCategoryCode;
|
|
4
|
-
const factory_1 = require("../../../factory");
|
|
5
|
-
/**
|
|
6
|
-
* 区分を他リソースへ同期する
|
|
7
|
-
*/
|
|
8
|
-
function syncCategoryCode(params) {
|
|
9
|
-
return async (repos) => {
|
|
10
|
-
if (params.isDeleted) {
|
|
11
|
-
for (const categoryCodeId of params.ids) {
|
|
12
|
-
// プロダクトモデルを削除
|
|
13
|
-
await repos.productModel.deleteByCategory({
|
|
14
|
-
category: {
|
|
15
|
-
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
16
|
-
id: categoryCodeId
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
for (const categoryCodeId of params.ids) {
|
|
23
|
-
const syncingCategoryCode = (await repos.categoryCode.projectCategoryCodeFields({
|
|
24
|
-
limit: 1,
|
|
25
|
-
page: 1,
|
|
26
|
-
project: { id: { $eq: params.project.id } },
|
|
27
|
-
id: { $eq: categoryCodeId }
|
|
28
|
-
}, ['codeValue', 'inCodeSet', 'name', 'project', 'id'])).shift();
|
|
29
|
-
if (syncingCategoryCode !== undefined) {
|
|
30
|
-
switch (syncingCategoryCode.inCodeSet.identifier) {
|
|
31
|
-
case factory_1.factory.categoryCode.CategorySetIdentifier.SeatingType:
|
|
32
|
-
// プロダクトモデルへ同期
|
|
33
|
-
await repos.productModel.upsertByCategory({
|
|
34
|
-
category: {
|
|
35
|
-
...syncingCategoryCode,
|
|
36
|
-
id: categoryCodeId
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
break;
|
|
40
|
-
default:
|
|
41
|
-
// no op
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|