@chevre/domain 24.1.0-alpha.0 → 24.1.0-alpha.2
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/repo/accountingReport.js +24 -22
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +10 -9
- package/lib/chevre/repo/project.d.ts +0 -3
- package/lib/chevre/repo/project.js +0 -10
- package/lib/chevre/service/task/onResourceDeleted.js +7 -8
- package/lib/chevre/service/task/onResourceUpdated.js +7 -8
- package/package.json +2 -2
- package/lib/chevre/repo/mongoose/schemas/productModel.d.ts +0 -33
- package/lib/chevre/repo/mongoose/schemas/productModel.js +0 -57
- package/lib/chevre/repo/productModel.d.ts +0 -27
- package/lib/chevre/repo/productModel.js +0 -170
- 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
|
@@ -49,28 +49,30 @@ class AccountingReportRepo {
|
|
|
49
49
|
$match: { 'mainEntity.orderDate': { $lte: orderDateLte } }
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
52
|
+
// discontinue(2026-05-01~)
|
|
53
|
+
// const reservationForStartDateGte = params.order?.acceptedOffers?.itemOffered?.reservationFor?.startDate?.$gte;
|
|
54
|
+
// if (reservationForStartDateGte instanceof Date) {
|
|
55
|
+
// matchStages.push({
|
|
56
|
+
// $match: {
|
|
57
|
+
// 'mainEntity.acceptedOffers.itemOffered.reservationFor.startDate': {
|
|
58
|
+
// $exists: true,
|
|
59
|
+
// $gte: reservationForStartDateGte
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
// });
|
|
63
|
+
// }
|
|
64
|
+
// discontinue(2026-05-01~)
|
|
65
|
+
// const reservationForStartDateLte = params.order?.acceptedOffers?.itemOffered?.reservationFor?.startDate?.$lte;
|
|
66
|
+
// if (reservationForStartDateLte instanceof Date) {
|
|
67
|
+
// matchStages.push({
|
|
68
|
+
// $match: {
|
|
69
|
+
// 'mainEntity.acceptedOffers.itemOffered.reservationFor.startDate': {
|
|
70
|
+
// $exists: true,
|
|
71
|
+
// $lte: reservationForStartDateLte
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
// });
|
|
75
|
+
// }
|
|
74
76
|
return matchStages;
|
|
75
77
|
}
|
|
76
78
|
async syncMainEntity(params) {
|
|
@@ -117,15 +117,16 @@ const indexes = [
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
],
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
// discontinue(2026-05-01~)
|
|
121
|
+
// [
|
|
122
|
+
// { 'mainEntity.acceptedOffers.itemOffered.reservationFor.startDate': 1, 'mainEntity.orderDate': -1 },
|
|
123
|
+
// {
|
|
124
|
+
// name: 'searchByItemOfferedReservationForStartDate',
|
|
125
|
+
// partialFilterExpression: {
|
|
126
|
+
// 'mainEntity.acceptedOffers.itemOffered.reservationFor.startDate': { $exists: true }
|
|
127
|
+
// }
|
|
128
|
+
// }
|
|
129
|
+
// ]
|
|
129
130
|
];
|
|
130
131
|
exports.indexes = indexes;
|
|
131
132
|
/**
|
|
@@ -40,9 +40,6 @@ export declare class ProjectRepo {
|
|
|
40
40
|
id: string;
|
|
41
41
|
makesOffer: factory.project.IMakesOffer[];
|
|
42
42
|
}): Promise<void>;
|
|
43
|
-
activateOptionalAggregationSettings(params: {
|
|
44
|
-
id: string;
|
|
45
|
-
}): Promise<void>;
|
|
46
43
|
updateAggregateReservation(params: {
|
|
47
44
|
id: string;
|
|
48
45
|
aggregateReservation?: any;
|
|
@@ -157,16 +157,6 @@ class ProjectRepo {
|
|
|
157
157
|
}, { projection: { _id: 1 } })
|
|
158
158
|
.exec();
|
|
159
159
|
}
|
|
160
|
-
async activateOptionalAggregationSettings(params) {
|
|
161
|
-
await this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
162
|
-
$set: {
|
|
163
|
-
'settings.useAggregateEntranceGate': true,
|
|
164
|
-
'settings.useAggregateOffer': true,
|
|
165
|
-
'settings.useOfferRateLimit': true
|
|
166
|
-
}
|
|
167
|
-
}, { projection: { _id: 1 } })
|
|
168
|
-
.exec();
|
|
169
|
-
}
|
|
170
160
|
async updateAggregateReservation(params) {
|
|
171
161
|
await this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
172
162
|
$set: {
|
|
@@ -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
|
@@ -11,7 +11,7 @@
|
|
|
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": "8.0.0",
|
|
14
|
+
"@chevre/factory": "8.1.0-alpha.0",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "24.1.0-alpha.
|
|
94
|
+
"version": "24.1.0-alpha.2"
|
|
95
95
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
-
import { IVirtuals } from '../virtuals';
|
|
3
|
-
import { factory } from '../../../factory';
|
|
4
|
-
export interface IProductModel {
|
|
5
|
-
id: string;
|
|
6
|
-
project: {
|
|
7
|
-
id: string;
|
|
8
|
-
typeOf: factory.organizationType.Project;
|
|
9
|
-
};
|
|
10
|
-
typeOf: 'ProductModel';
|
|
11
|
-
category: Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'inCodeSet'> & {
|
|
12
|
-
/**
|
|
13
|
-
* 区分ID
|
|
14
|
-
* 削除時同期に必要
|
|
15
|
-
*/
|
|
16
|
-
id: string;
|
|
17
|
-
};
|
|
18
|
-
name: factory.multilingualString;
|
|
19
|
-
offers: {
|
|
20
|
-
typeOf: factory.offerType.Offer;
|
|
21
|
-
eligibleCustomerType?: {
|
|
22
|
-
codeValue: string;
|
|
23
|
-
}[];
|
|
24
|
-
}[];
|
|
25
|
-
}
|
|
26
|
-
type IDocType = Omit<IProductModel, 'id'>;
|
|
27
|
-
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
28
|
-
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
29
|
-
type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
|
|
30
|
-
declare const modelName = "ProductModel";
|
|
31
|
-
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
32
|
-
declare function createSchema(): ISchema;
|
|
33
|
-
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.modelName = exports.indexes = void 0;
|
|
4
|
-
exports.createSchema = createSchema;
|
|
5
|
-
const mongoose_1 = require("mongoose");
|
|
6
|
-
const writeConcern_1 = require("../writeConcern");
|
|
7
|
-
const settings_1 = require("../../../settings");
|
|
8
|
-
const modelName = 'ProductModel';
|
|
9
|
-
exports.modelName = modelName;
|
|
10
|
-
const schemaDefinition = {
|
|
11
|
-
project: mongoose_1.SchemaTypes.Mixed,
|
|
12
|
-
typeOf: { type: String, required: true },
|
|
13
|
-
category: mongoose_1.SchemaTypes.Mixed,
|
|
14
|
-
name: mongoose_1.SchemaTypes.Mixed,
|
|
15
|
-
offers: mongoose_1.SchemaTypes.Mixed
|
|
16
|
-
};
|
|
17
|
-
const schemaOptions = {
|
|
18
|
-
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
19
|
-
autoCreate: false,
|
|
20
|
-
collection: 'productModels',
|
|
21
|
-
id: true,
|
|
22
|
-
read: settings_1.MONGO_READ_PREFERENCE,
|
|
23
|
-
writeConcern: writeConcern_1.writeConcern,
|
|
24
|
-
strict: true,
|
|
25
|
-
strictQuery: false,
|
|
26
|
-
timestamps: false, // 2024-09-03~
|
|
27
|
-
versionKey: false, // 2024-09-03~
|
|
28
|
-
toJSON: {
|
|
29
|
-
getters: false,
|
|
30
|
-
virtuals: false,
|
|
31
|
-
minimize: false,
|
|
32
|
-
versionKey: false
|
|
33
|
-
},
|
|
34
|
-
toObject: {
|
|
35
|
-
getters: false,
|
|
36
|
-
virtuals: true,
|
|
37
|
-
minimize: false,
|
|
38
|
-
versionKey: false
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const indexes = [];
|
|
42
|
-
exports.indexes = indexes;
|
|
43
|
-
/**
|
|
44
|
-
* プロダクトモデルスキーマ
|
|
45
|
-
*/
|
|
46
|
-
let schema;
|
|
47
|
-
function createSchema() {
|
|
48
|
-
if (schema === undefined) {
|
|
49
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
50
|
-
if (settings_1.MONGO_AUTO_INDEX) {
|
|
51
|
-
indexes.forEach((indexParams) => {
|
|
52
|
-
schema?.index(...indexParams);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return schema;
|
|
57
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
2
|
-
import { factory } from '../factory';
|
|
3
|
-
/**
|
|
4
|
-
* プロダクトモデルリポジトリ
|
|
5
|
-
*/
|
|
6
|
-
export declare class ProductModelRepo {
|
|
7
|
-
private readonly productModelModel;
|
|
8
|
-
constructor(connection: Connection);
|
|
9
|
-
/**
|
|
10
|
-
* 区分から同期する
|
|
11
|
-
*/
|
|
12
|
-
upsertByCategory(params: {
|
|
13
|
-
category: Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'inCodeSet' | 'name' | 'project'> & {
|
|
14
|
-
id: string;
|
|
15
|
-
};
|
|
16
|
-
}): Promise<{
|
|
17
|
-
id: string;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* 区分から削除する
|
|
21
|
-
*/
|
|
22
|
-
deleteByCategory(params: {
|
|
23
|
-
category: Pick<factory.categoryCode.ICategoryCode, 'project'> & {
|
|
24
|
-
id: string;
|
|
25
|
-
};
|
|
26
|
-
}): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductModelRepo = void 0;
|
|
4
|
-
const factory_1 = require("../factory");
|
|
5
|
-
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
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
|
-
// };
|
|
14
|
-
/**
|
|
15
|
-
* プロダクトモデルリポジトリ
|
|
16
|
-
*/
|
|
17
|
-
class ProductModelRepo {
|
|
18
|
-
productModelModel;
|
|
19
|
-
constructor(connection) {
|
|
20
|
-
this.productModelModel = connection.model(productModel_1.modelName, (0, productModel_1.createSchema)());
|
|
21
|
-
}
|
|
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
|
-
// }
|
|
128
|
-
/**
|
|
129
|
-
* 区分から同期する
|
|
130
|
-
*/
|
|
131
|
-
async upsertByCategory(params) {
|
|
132
|
-
const upsertingProductModel = {
|
|
133
|
-
project: { id: params.category.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
134
|
-
typeOf: 'ProductModel',
|
|
135
|
-
category: {
|
|
136
|
-
codeValue: params.category.codeValue,
|
|
137
|
-
inCodeSet: params.category.inCodeSet,
|
|
138
|
-
id: params.category.id
|
|
139
|
-
},
|
|
140
|
-
name: params.category.name,
|
|
141
|
-
offers: [{
|
|
142
|
-
typeOf: factory_1.factory.offerType.Offer
|
|
143
|
-
}]
|
|
144
|
-
};
|
|
145
|
-
const { project, typeOf, offers, category, ...setFields } = upsertingProductModel;
|
|
146
|
-
const doc = await this.productModelModel.findOneAndUpdate({
|
|
147
|
-
'project.id': { $eq: upsertingProductModel.project.id },
|
|
148
|
-
'category.id': { $exists: true, $eq: upsertingProductModel.category.id }
|
|
149
|
-
}, {
|
|
150
|
-
$setOnInsert: { project, typeOf, offers, category },
|
|
151
|
-
$set: setFields
|
|
152
|
-
}, { new: true, upsert: true, projection: { _id: 1 } })
|
|
153
|
-
.exec();
|
|
154
|
-
if (doc === null) {
|
|
155
|
-
throw new factory_1.factory.errors.NotFound(this.productModelModel.modelName);
|
|
156
|
-
}
|
|
157
|
-
return doc.toObject({ virtuals: true });
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* 区分から削除する
|
|
161
|
-
*/
|
|
162
|
-
async deleteByCategory(params) {
|
|
163
|
-
await this.productModelModel.deleteMany({
|
|
164
|
-
'project.id': { $eq: params.category.project.id },
|
|
165
|
-
'category.id': { $exists: true, $eq: params.category.id }
|
|
166
|
-
})
|
|
167
|
-
.exec();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
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
|
-
}
|