@chevre/domain 24.1.0-alpha.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.
@@ -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
- const syncCategoryCode_1 = require("./onResourceUpdated/syncCategoryCode");
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
- await (0, syncCategoryCode_1.syncCategoryCode)({
140
- project: { id: params.project.id },
141
- ids: params.id,
142
- isDeleted: true
143
- })(repos);
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
- const onCategoryCodeUpdated_1 = require("./onResourceUpdated/onCategoryCodeUpdated");
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
- await (0, onCategoryCodeUpdated_1.onCategoryCodeUpdated)({
174
- project: { id: params.project.id },
175
- ids: params.id,
176
- isDeleted: false
177
- })(repos);
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
@@ -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.0"
94
+ "version": "24.1.0-alpha.1"
95
95
  }
@@ -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
- }