@chevre/domain 28.0.0-alpha.30 → 28.0.0-alpha.32

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.
@@ -3,7 +3,6 @@ import { IVirtuals } from '../virtuals';
3
3
  import { factory } from '../../../factory';
4
4
  export type IDocType = Omit<factory.offerCatalog.IOfferCatalog, 'id'> & {
5
5
  _id: string;
6
- alternateName?: any;
7
6
  dateSynced?: Date;
8
7
  };
9
8
  type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
@@ -10,24 +10,15 @@ exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
12
  _id: String,
13
- identifier: {
14
- type: String,
15
- required: true
16
- },
13
+ identifier: { type: String, required: true },
17
14
  name: mongoose_1.SchemaTypes.Mixed,
18
15
  description: mongoose_1.SchemaTypes.Mixed,
19
- alternateName: mongoose_1.SchemaTypes.Mixed,
20
- typeOf: {
21
- type: String,
22
- required: true
23
- },
16
+ // alternateName: SchemaTypes.Mixed,
17
+ typeOf: { type: String, required: true },
24
18
  itemListElement: [mongoose_1.SchemaTypes.Mixed],
25
19
  itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
26
20
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
27
21
  dateSynced: Date // 追加(2023-09-13~)
28
- // createdAt: SchemaTypes.Mixed,
29
- // updatedAt: SchemaTypes.Mixed,
30
- // __v: SchemaTypes.Mixed
31
22
  };
32
23
  const schemaOptions = {
33
24
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -1,9 +1,8 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import { IVirtuals } from '../virtuals';
3
3
  import { factory } from '../../../factory';
4
- export type IDocType = Omit<factory.offerCatalog.IOfferCatalog, 'id'> & {
4
+ export type IDocType = Pick<factory.offerCatalog.IOfferCatalog, 'description' | 'identifier' | 'itemListElement' | 'itemOffered' | 'name' | 'project' | 'relatedOffer' | 'typeOf'> & {
5
5
  _id: string;
6
- alternateName?: any;
7
6
  dateSynced?: Date;
8
7
  };
9
8
  type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
@@ -9,25 +9,16 @@ const modelName = 'OfferCatalogItem';
9
9
  exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
- identifier: {
13
- type: String,
14
- required: true
15
- },
16
- name: mongoose_1.SchemaTypes.Mixed,
17
- description: mongoose_1.SchemaTypes.Mixed,
18
- alternateName: mongoose_1.SchemaTypes.Mixed,
19
- typeOf: {
20
- type: String,
21
- required: true
22
- },
12
+ identifier: { type: String, required: true },
13
+ typeOf: { type: String, required: true },
23
14
  itemListElement: [mongoose_1.SchemaTypes.Mixed],
24
15
  itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
25
- additionalProperty: [mongoose_1.SchemaTypes.Mixed],
16
+ name: mongoose_1.SchemaTypes.Mixed,
17
+ description: mongoose_1.SchemaTypes.Mixed,
18
+ // alternateName: SchemaTypes.Mixed,
19
+ // additionalProperty: [SchemaTypes.Mixed], // discontinue(2026-10-15~)
26
20
  dateSynced: Date,
27
21
  relatedOffer: mongoose_1.SchemaTypes.Mixed
28
- // createdAt: SchemaTypes.Mixed,
29
- // updatedAt: SchemaTypes.Mixed,
30
- // __v: SchemaTypes.Mixed
31
22
  };
32
23
  const schemaOptions = {
33
24
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -170,7 +170,6 @@ export declare class OfferCatalogRepo {
170
170
  }): Promise<void>;
171
171
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.offerCatalog.IOfferCatalog, "id"> & {
172
172
  _id: string;
173
- alternateName?: any;
174
173
  dateSynced?: Date;
175
174
  } & Required<{
176
175
  _id: string;
@@ -178,7 +177,6 @@ export declare class OfferCatalogRepo {
178
177
  __v: number;
179
178
  }, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<factory.offerCatalog.IOfferCatalog, "id"> & {
180
179
  _id: string;
181
- alternateName?: any;
182
180
  dateSynced?: Date;
183
181
  } & Required<{
184
182
  _id: string;
@@ -1,6 +1,8 @@
1
1
  import { Connection, FilterQuery, mongo } from 'mongoose';
2
2
  import { factory } from '../factory';
3
- export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty' | 'relatedOffer'> & {
3
+ import { IDocType } from './mongoose/schemas/offerCatalogItem';
4
+ type IOfferCatalogItem = Pick<factory.offerCatalog.IOfferCatalog, 'description' | 'identifier' | 'itemListElement' | 'itemOffered' | 'name' | 'project' | 'relatedOffer' | 'typeOf' | 'id'>;
5
+ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'relatedOffer'> & {
4
6
  numberOfItems?: number;
5
7
  itemListElementTypeOf: factory.offerType.Offer;
6
8
  };
@@ -11,25 +13,25 @@ type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | '
11
13
  export declare class OfferCatalogItemRepo {
12
14
  private readonly offerCatalogItemModel;
13
15
  constructor(connection: Connection);
14
- static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[];
15
- save(params: factory.offerCatalog.IOfferCatalog & {
16
- $unset?: any;
16
+ static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): FilterQuery<IDocType>[];
17
+ save(params: IOfferCatalogItem & {
18
+ $unset?: Partial<Record<keyof IDocType, 1>>;
17
19
  }): Promise<{
18
20
  id: string;
19
21
  }>;
20
22
  /**
21
23
  * プロジェクトとコードから冪等保管
22
24
  */
23
- saveByIdentifier(params: factory.offerCatalog.IOfferCatalog): Promise<{
25
+ saveByIdentifier(params: IOfferCatalogItem): Promise<{
24
26
  id: string;
25
27
  }>;
26
28
  /**
27
29
  * コードをキーにして冪等置換(2023-12-14~)
28
30
  */
29
31
  upsertManyByIdentifier(params: {
30
- $set: factory.offerCatalog.IOfferCatalog;
32
+ $set: IOfferCatalogItem;
31
33
  $unset?: {
32
- [key in keyof factory.offerCatalog.IOfferCatalog]?: 1;
34
+ [key in keyof IDocType]?: 1;
33
35
  };
34
36
  }[], options: {
35
37
  /**
@@ -73,8 +75,8 @@ export declare class OfferCatalogItemRepo {
73
75
  };
74
76
  };
75
77
  }): Promise<void>;
76
- count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
77
- projectFields(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>;
78
+ countOfferCatalogItems(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
79
+ findOfferCatalogItems(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>;
78
80
  findItemListElementById(params: {
79
81
  id: string;
80
82
  project: {
@@ -118,17 +120,8 @@ export declare class OfferCatalogItemRepo {
118
120
  };
119
121
  }): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
120
122
  unsetUnnecessaryFields(params: {
121
- filter: FilterQuery<factory.offerCatalog.IOfferCatalog>;
122
- $unset: any;
123
+ filter: FilterQuery<IDocType>;
124
+ $unset: Partial<Record<keyof IDocType, 1>>;
123
125
  }): Promise<import("mongoose").UpdateWriteOpResult>;
124
- aggregateItemList(params: {
125
- itemListElement: {
126
- typeOf: {
127
- $eq: factory.offerType.Offer | 'OfferCatalog';
128
- };
129
- };
130
- }): Promise<{
131
- aggregation: any;
132
- }>;
133
126
  }
134
127
  export {};
@@ -28,7 +28,7 @@ class OfferCatalogItemRepo {
28
28
  }
29
29
  static CREATE_MONGO_CONDITIONS(params) {
30
30
  // MongoDB検索条件
31
- const andConditions = []; // eslint-disable-line @typescript-eslint/no-explicit-any
31
+ const andConditions = [];
32
32
  const projectIdEq = params.project?.id?.$eq;
33
33
  if (typeof projectIdEq === 'string') {
34
34
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
@@ -247,7 +247,7 @@ class OfferCatalogItemRepo {
247
247
  })
248
248
  .exec();
249
249
  }
250
- async count(params) {
250
+ async countOfferCatalogItems(params) {
251
251
  const conditions = OfferCatalogItemRepo.CREATE_MONGO_CONDITIONS(params);
252
252
  const matchStages = conditions.map((condition) => {
253
253
  return { $match: condition };
@@ -261,18 +261,15 @@ class OfferCatalogItemRepo {
261
261
  .exec();
262
262
  return (result.length > 0) ? result[0].numItems : 0;
263
263
  }
264
- async projectFields(params, inclusion) {
264
+ async findOfferCatalogItems(params, inclusion) {
265
265
  const conditions = OfferCatalogItemRepo.CREATE_MONGO_CONDITIONS(params);
266
266
  const matchStages = conditions.map((condition) => {
267
267
  return { $match: condition };
268
268
  });
269
269
  let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
270
- if (Array.isArray(inclusion) && inclusion.length > 0) {
270
+ if (Array.isArray(inclusion)) {
271
271
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
272
272
  }
273
- else {
274
- // throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
275
- }
276
273
  const projection = {
277
274
  _id: 0,
278
275
  id: { $toString: '$_id' },
@@ -297,49 +294,6 @@ class OfferCatalogItemRepo {
297
294
  return [key, value];
298
295
  }))
299
296
  };
300
- // let projectStage: { [field: string]: AnyExpression } = {
301
- // _id: 0,
302
- // name: '$name',
303
- // description: '$description',
304
- // project: '$project',
305
- // typeOf: '$typeOf',
306
- // id: { $toString: '$_id' },
307
- // identifier: '$identifier',
308
- // itemOffered: '$itemOffered',
309
- // additionalProperty: '$additionalProperty',
310
- // relatedOffer: '$relatedOffer',
311
- // numberOfItems: {
312
- // $cond: {
313
- // if: { $isArray: '$itemListElement' },
314
- // then: { $size: '$itemListElement' },
315
- // else: 0
316
- // }
317
- // },
318
- // itemListElementTypeOf: { $first: '$itemListElement.typeOf' },
319
- // dateSynced: '$dateSynced'
320
- // };
321
- // const positiveProjectionFields: string[] = Object.keys(projection)
322
- // .filter((key) => projection[<KeyOfOfferCatalogItem>key] !== 0);
323
- // const negativeProjectionFields: string[] = Object.keys(projection)
324
- // .filter((key) => projection[<KeyOfOfferCatalogItem>key] === 0);
325
- // if (positiveProjectionFields.length > 0) {
326
- // projectStage = {
327
- // _id: 0,
328
- // id: { $toString: '$_id' }
329
- // };
330
- // positiveProjectionFields.forEach((field) => {
331
- // if (field !== '_id' && field !== 'id') {
332
- // projectStage[field] = `$${field}`;
333
- // }
334
- // });
335
- // } else if (negativeProjectionFields.length > 0) {
336
- // negativeProjectionFields.forEach((field) => {
337
- // if (projectStage[field] !== undefined && projectStage[field] !== null) {
338
- // // tslint:disable-next-line:no-dynamic-delete
339
- // delete projectStage[field];
340
- // }
341
- // });
342
- // }
343
297
  const aggregate = this.offerCatalogItemModel.aggregate([
344
298
  ...(params.sort?.identifier !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
345
299
  ...matchStages,
@@ -347,8 +301,10 @@ class OfferCatalogItemRepo {
347
301
  ]);
348
302
  if (typeof params.limit === 'number' && params.limit > 0) {
349
303
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
350
- aggregate.limit(params.limit * page)
351
- .skip(params.limit * (page - 1));
304
+ // aggregate.limit(params.limit * page)
305
+ // .skip(params.limit * (page - 1));
306
+ aggregate.skip(params.limit * (page - 1))
307
+ .limit(params.limit);
352
308
  }
353
309
  return aggregate.exec();
354
310
  }
@@ -413,39 +369,5 @@ class OfferCatalogItemRepo {
413
369
  return this.offerCatalogItemModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
414
370
  .exec();
415
371
  }
416
- async aggregateItemList(params) {
417
- const matchConditions = {
418
- 'itemListElement.typeOf': { $eq: params.itemListElement.typeOf.$eq }
419
- };
420
- const aggregations = await this.offerCatalogItemModel.aggregate([
421
- { $match: matchConditions },
422
- {
423
- $project: {
424
- numItemListElement: { $size: '$itemListElement' }
425
- }
426
- },
427
- {
428
- $group: {
429
- _id: '$typeOf',
430
- maxNumItemListElement: { $max: '$numItemListElement' },
431
- minNumItemListElement: { $min: '$numItemListElement' }
432
- }
433
- },
434
- {
435
- $project: {
436
- _id: 0,
437
- maxNumItemListElement: '$maxNumItemListElement',
438
- minNumItemListElement: '$minNumItemListElement'
439
- }
440
- }
441
- ])
442
- .exec();
443
- if (aggregations.length === 0) {
444
- return {
445
- aggregation: {}
446
- };
447
- }
448
- return { aggregation: aggregations[0] };
449
- }
450
372
  }
451
373
  exports.OfferCatalogItemRepo = OfferCatalogItemRepo;
@@ -59,7 +59,7 @@ export declare class RoleRepo {
59
59
  } & {
60
60
  __v: number;
61
61
  }) | null>;
62
- create(params: Pick<IRole, 'member' | 'memberOf' | 'permissions' | 'roleName'>): Promise<{
62
+ addRole(params: Pick<IRole, 'member' | 'memberOf' | 'permissions' | 'roleName'>): Promise<{
63
63
  id: string;
64
64
  }>;
65
65
  deleteByRoleName(params: Pick<IRole, 'roleName'>): Promise<import("mongodb").DeleteResult>;
@@ -69,35 +69,6 @@ class RoleRepo {
69
69
  .lean() // 2024-08-23~
70
70
  .exec();
71
71
  }
72
- // migrate to findDistinctPermissionsByRoleName(2025-07-21~)
73
- // public async aggregatePermissions(params: {
74
- // roleName: { $in: string[] };
75
- // }): Promise<{ _id: string }[]> {
76
- // const matchStages: IMatchStage[] = [
77
- // { $match: { roleName: { $in: params.roleName.$in } } }
78
- // ];
79
- // const aggregate = this.roleModel.aggregate([
80
- // ...matchStages,
81
- // {
82
- // $unwind: {
83
- // path: '$permissions'
84
- // }
85
- // },
86
- // {
87
- // $project: {
88
- // _id: 0,
89
- // permission: '$permissions'
90
- // }
91
- // },
92
- // {
93
- // $group: {
94
- // _id: '$permission'
95
- // }
96
- // }
97
- // ]);
98
- // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
99
- // .exec();
100
- // }
101
72
  /**
102
73
  * distinctコマンドを使用して、ロールから権限を検索する
103
74
  */
@@ -139,7 +110,7 @@ class RoleRepo {
139
110
  .lean()
140
111
  .exec();
141
112
  }
142
- async create(params) {
113
+ async addRole(params) {
143
114
  const { member, memberOf, permissions, roleName } = params;
144
115
  const creatingRole = {
145
116
  member, memberOf, permissions, roleName,
@@ -65,7 +65,7 @@ function searchTicketOffersByItemOffered(params) {
65
65
  // サブカタログの適用決済カード条件を考慮
66
66
  if (isOfferCatalogItem) {
67
67
  // サブカタログ参照
68
- const offerCatalogItem = (await repos.offerCatalogItem.projectFields({ id: { $in: [subOfferCatalogId] } }, ['relatedOffer']
68
+ const offerCatalogItem = (await repos.offerCatalogItem.findOfferCatalogItems({ id: { $in: [subOfferCatalogId] } }, ['relatedOffer']
69
69
  // { relatedOffer: 1 }
70
70
  )).shift();
71
71
  if (offerCatalogItem === undefined) {
@@ -63,9 +63,9 @@ function searchOfferCatalogItems(params) {
63
63
  });
64
64
  if (catalogItemListElements.length > 0) {
65
65
  // サブカタログ検索
66
- const searchOfferCatalogItemsResult = await repos.offerCatalogItem.projectFields({
66
+ const searchOfferCatalogItemsResult = await repos.offerCatalogItem.findOfferCatalogItems({
67
67
  id: { $in: catalogItemListElements.map((element) => element.id) }
68
- }, ['description', 'name', 'additionalProperty', 'relatedOffer']);
68
+ }, ['description', 'name', 'relatedOffer']);
69
69
  offerCatalogItems = catalogItemListElements.map((element) => {
70
70
  const offerCatalogItem = searchOfferCatalogItemsResult.find((item) => item.id === element.id);
71
71
  if (offerCatalogItem === undefined) {
@@ -13,7 +13,7 @@ function createInformOfferCatalogTasks(params, setting) {
13
13
  }
14
14
  let offerCatalogs;
15
15
  if (params.isOfferCatalogItem) {
16
- offerCatalogs = await repos.offerCatalogItem.projectFields({ id: { $in: params.ids } }, ['identifier', 'name', 'numberOfItems', 'project', 'typeOf']);
16
+ offerCatalogs = await repos.offerCatalogItem.findOfferCatalogItems({ id: { $in: params.ids } }, ['identifier', 'name', 'numberOfItems', 'project', 'typeOf']);
17
17
  }
18
18
  else {
19
19
  offerCatalogs = await repos.offerCatalog.projectFields({ id: { $in: params.ids } }, ['identifier', 'name', 'numberOfItems', 'project', 'typeOf']);
@@ -25,7 +25,7 @@ function syncOfferCatalog(params) {
25
25
  for (const offerCatalogId of params.ids) {
26
26
  let offerCatalogs;
27
27
  if (params.isOfferCatalogItem) {
28
- offerCatalogs = await repos.offerCatalogItem.projectFields({ id: { $in: [offerCatalogId] } }, ['id', 'itemListElementTypeOf']);
28
+ offerCatalogs = await repos.offerCatalogItem.findOfferCatalogItems({ id: { $in: [offerCatalogId] } }, ['id', 'itemListElementTypeOf']);
29
29
  }
30
30
  else {
31
31
  offerCatalogs = await repos.offerCatalog.projectFields({ id: { $in: [offerCatalogId] } }, ['id', 'itemListElementTypeOf']);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.1090.0",
13
13
  "@aws-sdk/credential-providers": "3.1090.0",
14
- "@chevre/factory": "11.1.0-alpha.6",
14
+ "@chevre/factory": "11.1.0-alpha.7",
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",
@@ -88,5 +88,5 @@
88
88
  "postversion": "git push origin --tags",
89
89
  "prepublishOnly": "npm run clean && npm run build"
90
90
  },
91
- "version": "28.0.0-alpha.30"
91
+ "version": "28.0.0-alpha.32"
92
92
  }