@chevre/domain 23.2.0-alpha.22 → 23.2.0-alpha.24

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.
@@ -0,0 +1,43 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import { chevre } from '../../../../lib/index';
4
+
5
+ const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
11
+
12
+ const result = await movieTheaterRepo.upsertMovieTheatersByBranchCode(
13
+ [
14
+ {
15
+ $set: {
16
+ branchCode: 'SAMPLE',
17
+ name: { ja: 'sampleNameJa', en: 'from samples' },
18
+ additionalProperty: [],
19
+ kanaName: '',
20
+ telephone: '',
21
+ offers: {
22
+ typeOf: chevre.factory.offerType.Offer,
23
+ eligibleQuantity: { maxValue: 6, unitCode: chevre.factory.unitCode.C62, typeOf: 'QuantitativeValue' },
24
+ availabilityEndsGraceTime: { value: 6, unitCode: chevre.factory.unitCode.Sec, typeOf: 'QuantitativeValue' },
25
+ availabilityStartsGraceTime: { value: 6, unitCode: chevre.factory.unitCode.Day, typeOf: 'QuantitativeValue' },
26
+ availabilityEndsGraceTimeOnPOS: { value: 6, unitCode: chevre.factory.unitCode.Sec, typeOf: 'QuantitativeValue' },
27
+ availabilityStartsGraceTimeOnPOS: { value: 6, unitCode: chevre.factory.unitCode.Day, typeOf: 'QuantitativeValue' }
28
+ }
29
+
30
+ }
31
+ }
32
+ ],
33
+ {
34
+ project: { id: project.id },
35
+ sellerId: '59d20831e53ebc2b4e774466'
36
+ }
37
+ );
38
+ console.log(result);
39
+ }
40
+
41
+ main()
42
+ .then(console.log)
43
+ .catch(console.error);
@@ -0,0 +1,56 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import { chevre } from '../../../../lib/index';
4
+
5
+ const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
6
+ const movieTheaterId = '5bfb841d5a78d7948369979a';
7
+ const sellerId = '59d20831e53ebc2b4e774466';
8
+ const roomCode = '10';
9
+
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
14
+
15
+ let result = await sectionRepo.addSeatSectionsByBranchCodeIfNotExist(
16
+ [
17
+ {
18
+ $set: {
19
+ branchCode: 'SAMPLE',
20
+ name: { ja: 'sampleNameJa', en: 'from samples' },
21
+ additionalProperty: []
22
+ }
23
+ }
24
+ ],
25
+ {
26
+ project: { id: project.id },
27
+ movieTheaterId,
28
+ parentOrganization: { id: sellerId },
29
+ roomCode
30
+ }
31
+ );
32
+ console.log(result);
33
+
34
+ result = await sectionRepo.updateSeatSectionsByBranchCode(
35
+ [
36
+ {
37
+ $set: {
38
+ branchCode: 'SAMPLE',
39
+ name: { ja: 'sampleNameJaxxx', en: 'from samples' },
40
+ additionalProperty: []
41
+ }
42
+ }
43
+ ],
44
+ {
45
+ project: { id: project.id },
46
+ movieTheaterId,
47
+ parentOrganization: { id: sellerId },
48
+ roomCode
49
+ }
50
+ );
51
+ console.log(result);
52
+ }
53
+
54
+ main()
55
+ .then(console.log)
56
+ .catch(console.error);
@@ -1,9 +1,13 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocType = factory.place.screeningRoom.IPlace & {
3
+ type ISeatSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name' | 'typeOf'> & {
4
+ containsPlace?: factory.place.seat.IPlace[];
5
+ };
6
+ type IDocType = Omit<factory.place.screeningRoom.IPlace, 'containsPlace'> & {
4
7
  description?: any;
5
8
  openingHoursSpecification?: any;
6
9
  smokingAllowed?: boolean;
10
+ containsPlace: ISeatSection[];
7
11
  };
8
12
  type IModel = Model<IDocType>;
9
13
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -1,3 +1,4 @@
1
+ import type { BulkWriteResult } from 'mongodb';
1
2
  import type { Connection, FilterQuery } from 'mongoose';
2
3
  import * as factory from '../../factory';
3
4
  import { IDocType } from '../mongoose/schemas/civicStructure';
@@ -5,10 +6,23 @@ export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.I
5
6
  export type IMovieTheaterIncludingScreeningRooms = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf'> & {
6
7
  containsPlace: factory.place.screeningRoom.IPlace[];
7
8
  };
8
- type IKeyOfProjection = keyof factory.place.movieTheater.IPlace | 'offers.availabilityStartsGraceTime' | 'offers.availabilityEndsGraceTime';
9
+ type IKeyOfProjection = keyof factory.place.movieTheater.IPlace | 'offers.typeOf' | 'offers.eligibleQuantity' | 'offers.availabilityStartsGraceTime' | 'offers.availabilityEndsGraceTime';
9
10
  type IMovieTheaterPublicAttributes = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'id' | 'kanaName' | 'name' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf' | 'url'> & {
10
11
  offers?: Pick<factory.place.movieTheater.IOffer, 'availabilityEndsGraceTime' | 'availabilityStartsGraceTime'>;
11
12
  };
13
+ type IUpsertingMovieTheater = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'kanaName' | 'name' | 'offers' | 'telephone' | 'url'> & {
14
+ hasEntranceGate?: never;
15
+ hasPOS?: never;
16
+ };
17
+ interface IUpsertOptions {
18
+ project: {
19
+ id: string;
20
+ };
21
+ /**
22
+ * 施設の所属販売者ID
23
+ */
24
+ sellerId: string;
25
+ }
12
26
  /**
13
27
  * 施設リポジトリ
14
28
  */
@@ -25,6 +39,18 @@ export declare class MovieTheaterRepo {
25
39
  id: string;
26
40
  }>;
27
41
  saveMovieTheaterByBranchCode4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
42
+ /**
43
+ * コードをキーにして冪等作成
44
+ * 2026-01-13~
45
+ */
46
+ upsertMovieTheatersByBranchCode(params: {
47
+ $set: IUpsertingMovieTheater;
48
+ $unset?: {
49
+ [key in keyof IUpsertingMovieTheater]?: 1;
50
+ };
51
+ }[], options: IUpsertOptions): Promise<{
52
+ bulkWriteResult?: BulkWriteResult;
53
+ }>;
28
54
  /**
29
55
  * 施設のpublic属性検索
30
56
  * 2024-09-18~
@@ -27,6 +27,8 @@ const civicStructure_1 = require("../mongoose/schemas/civicStructure");
27
27
  const AVAILABLE_PROJECT_FIELDS = [
28
28
  'additionalProperty', 'branchCode', 'hasEntranceGate', 'kanaName', 'name',
29
29
  'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url',
30
+ 'offers.typeOf',
31
+ 'offers.eligibleQuantity',
30
32
  'offers.availabilityStartsGraceTime',
31
33
  'offers.availabilityEndsGraceTime'
32
34
  ];
@@ -39,7 +41,7 @@ class MovieTheaterRepo {
39
41
  }
40
42
  // tslint:disable-next-line:max-func-body-length
41
43
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
42
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
44
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
43
45
  const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
44
46
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
45
47
  if (typeof projectIdEq === 'string') {
@@ -73,11 +75,15 @@ class MovieTheaterRepo {
73
75
  ]
74
76
  });
75
77
  }
76
- const parentOrganizationIdEq = (_h = (_g = params.parentOrganization) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
78
+ const sellerIdEq = (_h = (_g = params.seller) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
79
+ if (typeof sellerIdEq === 'string') {
80
+ andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: sellerIdEq } });
81
+ }
82
+ const parentOrganizationIdEq = (_k = (_j = params.parentOrganization) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
77
83
  if (typeof parentOrganizationIdEq === 'string') {
78
84
  andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } });
79
85
  }
80
- const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
86
+ const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
81
87
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
82
88
  andConditions.push({
83
89
  additionalProperty: {
@@ -132,6 +138,50 @@ class MovieTheaterRepo {
132
138
  }
133
139
  });
134
140
  }
141
+ /**
142
+ * コードをキーにして冪等作成
143
+ * 2026-01-13~
144
+ */
145
+ upsertMovieTheatersByBranchCode(params, options) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const { project, sellerId } = options;
148
+ const bulkWriteOps = [];
149
+ if (Array.isArray(params)) {
150
+ params.forEach(({ $set, $unset }) => {
151
+ const { branchCode, hasEntranceGate, hasPOS } = $set, // 入場ゲート,POSを決して編集しないように
152
+ setFields = __rest($set, ["branchCode", "hasEntranceGate", "hasPOS"]);
153
+ if (typeof branchCode !== 'string' || branchCode === '') {
154
+ throw new factory.errors.ArgumentNull('branchCode');
155
+ }
156
+ // リソースのユニークネスを保証するfilter
157
+ const filter = {
158
+ typeOf: { $eq: factory.placeType.MovieTheater },
159
+ 'project.id': { $eq: project.id },
160
+ branchCode: { $eq: branchCode }
161
+ };
162
+ const initialMovieTheater = {
163
+ typeOf: factory.placeType.MovieTheater,
164
+ project: { id: project.id, typeOf: factory.organizationType.Project },
165
+ branchCode,
166
+ parentOrganization: { id: sellerId, typeOf: factory.organizationType.Corporation }
167
+ };
168
+ const setOnInsert = initialMovieTheater;
169
+ const update = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
170
+ const updateOne = {
171
+ filter,
172
+ update,
173
+ upsert: true
174
+ };
175
+ bulkWriteOps.push({ updateOne });
176
+ });
177
+ }
178
+ if (bulkWriteOps.length > 0) {
179
+ const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
180
+ return { bulkWriteResult };
181
+ }
182
+ return {};
183
+ });
184
+ }
135
185
  /**
136
186
  * 施設のpublic属性検索
137
187
  * 2024-09-18~
@@ -124,16 +124,22 @@ export declare class ScreeningRoomRepo {
124
124
  id: string;
125
125
  };
126
126
  }): Promise<void>;
127
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & import("@chevre/factory/lib/place/screeningRoom").IPlace & {
127
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/screeningRoom").IPlace, "containsPlace"> & {
128
128
  description?: any;
129
129
  openingHoursSpecification?: any;
130
130
  smokingAllowed?: boolean;
131
+ containsPlace: (Pick<import("@chevre/factory/lib/place/screeningRoomSection").IPlace, "name" | "typeOf" | "additionalProperty" | "branchCode"> & {
132
+ containsPlace?: factory.place.seat.IPlace[];
133
+ })[];
131
134
  } & {
132
135
  _id: import("mongoose").Types.ObjectId;
133
- }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & import("@chevre/factory/lib/place/screeningRoom").IPlace & {
136
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/screeningRoom").IPlace, "containsPlace"> & {
134
137
  description?: any;
135
138
  openingHoursSpecification?: any;
136
139
  smokingAllowed?: boolean;
140
+ containsPlace: (Pick<import("@chevre/factory/lib/place/screeningRoomSection").IPlace, "name" | "typeOf" | "additionalProperty" | "branchCode"> & {
141
+ containsPlace?: factory.place.seat.IPlace[];
142
+ })[];
137
143
  } & {
138
144
  _id: import("mongoose").Types.ObjectId;
139
145
  }>>;
@@ -1,3 +1,4 @@
1
+ import type { BulkWriteResult } from 'mongodb';
1
2
  import type { Connection, PipelineStage } from 'mongoose';
2
3
  import * as factory from '../../factory';
3
4
  type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
@@ -25,6 +26,17 @@ interface IUpdateSectionResult {
25
26
  };
26
27
  typeOf: factory.placeType.ScreeningRoom;
27
28
  }
29
+ type IUpsertingSeatSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>;
30
+ interface IUpsertOptions {
31
+ project: {
32
+ id: string;
33
+ };
34
+ parentOrganization?: {
35
+ id?: string;
36
+ };
37
+ movieTheaterId: string;
38
+ roomCode: string;
39
+ }
28
40
  /**
29
41
  * セクションリポジトリ
30
42
  */
@@ -39,9 +51,21 @@ export declare class SectionRepo {
39
51
  */
40
52
  updateSectionByBranchCode(screeningRoomSection: ICreatingSection, $unset: any, options: IUpdateOptions): Promise<IUpdateSectionResult>;
41
53
  /**
42
- * セクションの座席を上書きする
54
+ * コードをキーにして冪等追加
55
+ */
56
+ addSeatSectionsByBranchCodeIfNotExist(params: {
57
+ $set: IUpsertingSeatSection;
58
+ }[], options: IUpsertOptions): Promise<{
59
+ bulkWriteResult?: BulkWriteResult;
60
+ }>;
61
+ /**
62
+ * コードをキーにして冪等編集
43
63
  */
44
- overwriteSeats(screeningRoomSection: Pick<factory.place.screeningRoomSection.IPlace, 'branchCode' | 'containsPlace'>, options: IUpdateOptions): Promise<IUpdateSectionResult>;
64
+ updateSeatSectionsByBranchCode(params: {
65
+ $set: IUpsertingSeatSection;
66
+ }[], options: IUpsertOptions): Promise<{
67
+ bulkWriteResult?: BulkWriteResult;
68
+ }>;
45
69
  migrateSectionIdentifier(screeningRoomSection: {
46
70
  project: {
47
71
  id: string;
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
23
  exports.SectionRepo = void 0;
13
24
  const factory = require("../../factory");
@@ -192,38 +203,153 @@ class SectionRepo {
192
203
  });
193
204
  }
194
205
  /**
195
- * セクションの座席を上書きする
206
+ * コードをキーにして冪等追加
196
207
  */
197
- // tslint:disable-next-line:max-func-body-length
198
- overwriteSeats(screeningRoomSection, options) {
208
+ addSeatSectionsByBranchCodeIfNotExist(params, options) {
199
209
  return __awaiter(this, void 0, void 0, function* () {
200
- const { project, parentOrganization, movieTheaterCode, roomCode } = options;
201
- const { containsPlace } = screeningRoomSection;
202
- if (!Array.isArray(containsPlace)) {
203
- throw new factory.errors.ArgumentNull('containsPlace');
210
+ const { project, parentOrganization, movieTheaterId, roomCode } = options;
211
+ // ルーム存在確認
212
+ const roomDoc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.id': { $eq: movieTheaterId }, branchCode: { $eq: roomCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
213
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
214
+ : undefined), { _id: 1 })
215
+ .lean()
216
+ .exec();
217
+ if (roomDoc === null) {
218
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
204
219
  }
205
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
220
+ // console.log('roomDoc:', roomDoc);
221
+ const bulkWriteOps = [];
222
+ if (Array.isArray(params)) {
223
+ params.forEach(({ $set }) => {
224
+ var _a, _b;
225
+ const { branchCode } = $set, setFields = __rest($set, ["branchCode"]);
226
+ const filter = {
227
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
228
+ 'project.id': { $eq: project.id },
229
+ _id: { $eq: roomDoc._id },
230
+ 'containsPlace.branchCode': { $ne: branchCode } // セクションコードが存在しなければ追加する
231
+ };
232
+ const pushingSeatSection = Object.assign(Object.assign({ typeOf: factory.placeType.ScreeningRoomSection, branchCode }, (typeof ((_a = setFields.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = setFields.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
233
+ ? { name: setFields.name }
234
+ : undefined), (Array.isArray(setFields.additionalProperty)) ? { additionalProperty: setFields.additionalProperty } : undefined);
235
+ const update = {
236
+ $push: { containsPlace: pushingSeatSection }
237
+ };
238
+ const updateOne = { filter, update };
239
+ bulkWriteOps.push({ updateOne });
240
+ });
241
+ }
242
+ if (bulkWriteOps.length > 0) {
243
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
244
+ return { bulkWriteResult };
245
+ }
246
+ return {};
247
+ });
248
+ }
249
+ /**
250
+ * コードをキーにして冪等編集
251
+ */
252
+ updateSeatSectionsByBranchCode(params, options) {
253
+ return __awaiter(this, void 0, void 0, function* () {
254
+ const { project, parentOrganization, movieTheaterId, roomCode } = options;
255
+ // ルーム存在確認
256
+ const roomDoc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.id': { $eq: movieTheaterId }, branchCode: { $eq: roomCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
206
257
  ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
207
- : undefined), Object.assign({}, (containsPlace.length > 0)
208
- ? {
209
- 'containsPlace.$[screeningRoomSection].containsPlace': containsPlace.map((p) => {
210
- return Object.assign(Object.assign(Object.assign({ typeOf: p.typeOf, branchCode: p.branchCode }, (p.name !== undefined && p.name !== null) ? { name: p.name } : undefined), (Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined), (Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined);
211
- })
212
- }
213
- : undefined), {
214
- new: true,
215
- arrayFilters: [
216
- { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
217
- ],
218
- projection: { 'containedInPlace.id': 1, typeOf: 1 }
219
- })
258
+ : undefined), { _id: 1 })
259
+ .lean()
220
260
  .exec();
221
- if (doc === null) {
222
- throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
261
+ if (roomDoc === null) {
262
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
223
263
  }
224
- return doc.toObject();
264
+ const bulkWriteOps = [];
265
+ if (Array.isArray(params)) {
266
+ params.forEach(({ $set }) => {
267
+ const { branchCode } = $set, setFields = __rest($set, ["branchCode"]);
268
+ // セクションの存在するドキュメントでフィルター
269
+ const filter = {
270
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
271
+ 'project.id': { $eq: project.id },
272
+ _id: { $eq: roomDoc._id },
273
+ 'containsPlace.branchCode': { $eq: branchCode }
274
+ };
275
+ const update = {
276
+ // 限られた属性のみ更新する
277
+ $set: Object.assign(Object.assign({}, (setFields.name !== undefined && setFields.name !== null)
278
+ ? { 'containsPlace.$[seatSection].name': setFields.name }
279
+ : undefined), (Array.isArray(setFields.additionalProperty))
280
+ ? { 'containsPlace.$[seatSection].additionalProperty': setFields.additionalProperty }
281
+ : undefined)
282
+ // $unset: {}
283
+ };
284
+ const arrayFilters = [
285
+ { 'seatSection.branchCode': branchCode }
286
+ ];
287
+ const updateOne = { filter, update, arrayFilters };
288
+ bulkWriteOps.push({ updateOne });
289
+ });
290
+ }
291
+ if (bulkWriteOps.length > 0) {
292
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
293
+ return { bulkWriteResult };
294
+ }
295
+ return {};
225
296
  });
226
297
  }
298
+ // /**
299
+ // * セクションの座席を上書きする
300
+ // */
301
+ // // tslint:disable-next-line:max-func-body-length
302
+ // public async overwriteSeats(
303
+ // screeningRoomSection: Pick<factory.place.screeningRoomSection.IPlace, 'branchCode' | 'containsPlace'>,
304
+ // options: IUpdateOptions
305
+ // ): Promise<IUpdateSectionResult> {
306
+ // const { project, parentOrganization, movieTheaterCode, roomCode } = options;
307
+ // const { containsPlace } = screeningRoomSection;
308
+ // if (!Array.isArray(containsPlace)) {
309
+ // throw new factory.errors.ArgumentNull('containsPlace');
310
+ // }
311
+ // const doc = await this.placeModel.findOneAndUpdate<HydratedDocument<IUpdateSectionResult>>(
312
+ // {
313
+ // typeOf: { $eq: factory.placeType.ScreeningRoom },
314
+ // 'project.id': { $eq: project.id },
315
+ // 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
316
+ // branchCode: { $eq: roomCode },
317
+ // 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode },
318
+ // ...(typeof parentOrganization?.id === 'string')
319
+ // ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
320
+ // : undefined
321
+ // },
322
+ // {
323
+ // // 座席リストが1つ以上指定された場合のみ、上書きする
324
+ // ...(containsPlace.length > 0)
325
+ // ? {
326
+ // 'containsPlace.$[screeningRoomSection].containsPlace':
327
+ // containsPlace.map((p) => {
328
+ // return {
329
+ // typeOf: p.typeOf,
330
+ // branchCode: p.branchCode,
331
+ // ...(p.name !== undefined && p.name !== null) ? { name: p.name } : undefined,
332
+ // ...(Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined,
333
+ // ...(Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined
334
+ // };
335
+ // })
336
+ // }
337
+ // : undefined
338
+ // },
339
+ // {
340
+ // new: true,
341
+ // arrayFilters: [
342
+ // { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
343
+ // ],
344
+ // projection: { 'containedInPlace.id': 1, typeOf: 1 }
345
+ // }
346
+ // )
347
+ // .exec();
348
+ // if (doc === null) {
349
+ // throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
350
+ // }
351
+ // return doc.toObject();
352
+ // }
227
353
  // tslint:disable-next-line:max-func-body-length
228
354
  migrateSectionIdentifier(screeningRoomSection) {
229
355
  return __awaiter(this, void 0, void 0, function* () {
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": "5.4.0-alpha.13",
14
+ "@chevre/factory": "5.4.0-alpha.14",
15
15
  "@cinerino/sdk": "12.12.1",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
@@ -116,5 +116,5 @@
116
116
  "postversion": "git push origin --tags",
117
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
118
118
  },
119
- "version": "23.2.0-alpha.22"
119
+ "version": "23.2.0-alpha.24"
120
120
  }