@chevre/domain 28.0.0-alpha.11 → 28.0.0-alpha.13

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,6 +3,7 @@ import { IVirtuals } from '../virtuals';
3
3
  import { factory } from '../../../factory';
4
4
  export type IDocType = Omit<factory.place.movieTheater.IPlace, 'id'> & {
5
5
  hasPOS?: factory.place.movieTheater.IPOS[];
6
+ hasEntranceGate?: factory.place.movieTheater.IEntranceGate[];
6
7
  };
7
8
  type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
8
9
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -34,15 +34,6 @@ const schemaDefinition = {
34
34
  // ↓ルームの施設からの分離に伴い属性追加(2023-06-22~)
35
35
  openSeatingAllowed: mongoose_1.SchemaTypes.Mixed,
36
36
  amenityFeature: mongoose_1.SchemaTypes.Mixed
37
- // ↓migrated to civicStructures(2024-09-19~)
38
- // alternateName: SchemaTypes.Mixed,
39
- // hasEntranceGate: [SchemaTypes.Mixed],
40
- // hasPOS: [SchemaTypes.Mixed],
41
- // sameAs: String,
42
- // telephone: String,
43
- // url: String,
44
- // kanaName: String,
45
- // offers: SchemaTypes.Mixed,
46
37
  };
47
38
  const schemaOptions = {
48
39
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -32,7 +32,7 @@ export declare class MovieTheaterRepo {
32
32
  /**
33
33
  * 施設を保管する
34
34
  */
35
- saveMovieTheater(params: Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'hasEntranceGate' | 'id' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'typeOf' | 'url'> & {
35
+ saveMovieTheater(params: Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'id' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'typeOf' | 'url'> & {
36
36
  hasEntranceGate?: never;
37
37
  }): Promise<{
38
38
  id: string;
@@ -96,12 +96,14 @@ export declare class MovieTheaterRepo {
96
96
  }): Promise<void>;
97
97
  getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("../mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/place/movieTheater").IPlace, "id"> & {
98
98
  hasPOS?: factory.place.movieTheater.IPOS[];
99
+ hasEntranceGate?: factory.place.movieTheater.IEntranceGate[];
99
100
  } & {
100
101
  _id: import("mongoose").Types.ObjectId;
101
102
  } & {
102
103
  __v: number;
103
104
  }, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("../mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/place/movieTheater").IPlace, "id"> & {
104
105
  hasPOS?: factory.place.movieTheater.IPOS[];
106
+ hasEntranceGate?: factory.place.movieTheater.IEntranceGate[];
105
107
  } & {
106
108
  _id: import("mongoose").Types.ObjectId;
107
109
  } & {
@@ -5,7 +5,9 @@ const factory_1 = require("../../factory");
5
5
  const settings_1 = require("../../settings");
6
6
  const civicStructure_1 = require("../mongoose/schemas/civicStructure");
7
7
  const AVAILABLE_PROJECT_FIELDS = [
8
- 'additionalProperty', 'branchCode', 'hasEntranceGate', 'kanaName', 'name',
8
+ 'additionalProperty', 'branchCode',
9
+ // 'hasEntranceGate',
10
+ 'kanaName', 'name',
9
11
  'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url',
10
12
  'offers.typeOf',
11
13
  'offers.eligibleQuantity',
@@ -29,11 +29,14 @@ export declare class POSRepo {
29
29
  * 2026-09-18~
30
30
  */
31
31
  excludePOSId: boolean;
32
- }): Promise<Pick<factory.place.movieTheater.IPOS, 'branchCode' | 'name' | 'id'>[]>;
33
- createByBranchCode(params: Pick<factory.place.movieTheater.IPOS, 'branchCode' | 'name'> & {
32
+ }): Promise<Pick<factory.place.movieTheater.IPOS, 'branchCode' | 'name'>[]>;
33
+ private countPOS;
34
+ addPOSByBranchCode(params: Pick<factory.place.movieTheater.IPOS, 'branchCode' | 'name'> & {
34
35
  project: {
35
36
  id: string;
36
37
  };
38
+ }, options: {
39
+ maxNumPOS: number;
37
40
  }): Promise<{
38
41
  id: string;
39
42
  }>;
@@ -58,7 +58,32 @@ class POSRepo {
58
58
  return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
59
59
  .exec();
60
60
  }
61
- async createByBranchCode(params) {
61
+ async countPOS() {
62
+ const posCount = (await this.civicStructureModel.aggregate([
63
+ {
64
+ $match: {
65
+ _id: { $eq: new mongoose_1.Types.ObjectId(this.operator.id) },
66
+ }
67
+ },
68
+ {
69
+ $project: {
70
+ posCount: {
71
+ $cond: {
72
+ if: { $isArray: '$hasPOS' },
73
+ then: { $size: '$hasPOS' },
74
+ else: 0
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ]).option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
80
+ .exec()).at(0)?.posCount;
81
+ if (typeof posCount !== 'number') {
82
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.placeType.MovieTheater);
83
+ }
84
+ return { posCount };
85
+ }
86
+ async addPOSByBranchCode(params, options) {
62
87
  // 施設存在確認
63
88
  let doc = await this.civicStructureModel.findOne({
64
89
  'project.id': { $eq: params.project.id },
@@ -68,6 +93,12 @@ class POSRepo {
68
93
  if (doc === null) {
69
94
  throw new factory_1.factory.errors.NotFound(factory_1.factory.placeType.MovieTheater);
70
95
  }
96
+ // 最大数検証(2026-09-20~)
97
+ const { maxNumPOS } = options;
98
+ const { posCount } = await this.countPOS();
99
+ if (posCount >= maxNumPOS) {
100
+ throw new factory_1.factory.errors.Argument('operator.id', 'maxNumPOS exceeded');
101
+ }
71
102
  const creatingPOS = {
72
103
  // 互換性維持対応としてidを保管
73
104
  id: params.branchCode, // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -79,7 +110,12 @@ class POSRepo {
79
110
  _id: { $eq: this.operator.id },
80
111
  'hasPOS.branchCode': { $ne: params.branchCode }
81
112
  }, {
82
- $push: { hasPOS: creatingPOS }
113
+ $push: {
114
+ hasPOS: {
115
+ $each: [creatingPOS],
116
+ $slice: maxNumPOS // 最大数担保(2026-09-20~)
117
+ },
118
+ }
83
119
  }, {
84
120
  new: true,
85
121
  projection: { _id: 1 }
@@ -28,7 +28,7 @@ function createInformHasPOSTasks(params) {
28
28
  repos.pos.operator.id = movieTheater.id;
29
29
  const hasPOS = await repos.pos.findPOS({
30
30
  projectId: params.project.id
31
- }, { excludePOSId: false });
31
+ }, { excludePOSId: true }); // pos.idを除外(2026-09-18~)
32
32
  const movieTheaters4inform = [{
33
33
  hasPOS: (Array.isArray(hasPOS)) ? hasPOS : [],
34
34
  id: movieTheater.id,
@@ -401,32 +401,11 @@ function createInformMovieTheaterTasks(params, setting) {
401
401
  ]
402
402
  // []
403
403
  );
404
- // const movieTheater = movieTheaters.shift();
405
- // if (movieTheater === undefined) {
406
- // throw new factory.errors.NotFound(factory.placeType.MovieTheater);
407
- // }
408
- // // ルームを検索
409
- // const screeningRooms = await repos.screeningRoom.findRooms(
410
- // {
411
- // containedInPlace: { id: { $eq: movieTheater.id } }
412
- // }
413
- // );
414
404
  // 入場ゲートを廃止(2026-01-17~)
415
405
  const movieTheaters4inform = movieTheaters.map((movieTheater) => {
416
406
  const { hasEntranceGate, ...movieTheaterWithoutEntranceGates } = movieTheater; // eslint-disable-line @typescript-eslint/no-unused-vars
417
407
  return {
418
408
  ...movieTheaterWithoutEntranceGates
419
- // ...movieTheater
420
- // migrate to IRoomAsNotification(2026-01-16~)
421
- // containsPlace: screeningRooms.map((room) => {
422
- // return {
423
- // branchCode: room.branchCode,
424
- // name: room.name,
425
- // typeOf: factory.placeType.ScreeningRoom,
426
- // additionalProperty: room.additionalProperty,
427
- // address: room.address
428
- // };
429
- // })
430
409
  };
431
410
  });
432
411
  if (movieTheaters4inform.length > 0) {
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.0.0-alpha.3",
14
+ "@chevre/factory": "11.0.0-alpha.4",
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.11"
91
+ "version": "28.0.0-alpha.13"
92
92
  }