@chevre/domain 23.2.0-alpha.3 → 23.2.0-alpha.31

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.
Files changed (80) hide show
  1. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  2. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  3. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
  4. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  5. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  6. package/example/src/chevre/place/findRooms.ts +24 -0
  7. package/example/src/chevre/place/findSections.ts +28 -0
  8. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  9. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  10. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  11. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  12. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  13. package/example/src/chevre/reIndex.ts +1 -1
  14. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  15. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  16. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
  17. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
  18. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  19. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  20. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  21. package/lib/chevre/factory/event.js +5 -5
  22. package/lib/chevre/repo/aggregateOrder.js +0 -93
  23. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  24. package/lib/chevre/repo/aggregateReservation.js +0 -2
  25. package/lib/chevre/repo/creativeWork.js +9 -5
  26. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  27. package/lib/chevre/repo/eventOffer.js +11 -0
  28. package/lib/chevre/repo/eventSeries.js +16 -12
  29. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  30. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  31. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
  32. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  33. package/lib/chevre/repo/place/entranceGate.d.ts +48 -0
  34. package/lib/chevre/repo/place/entranceGate.js +166 -0
  35. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  36. package/lib/chevre/repo/place/movieTheater.js +77 -6
  37. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  38. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  39. package/lib/chevre/repo/place/seat.d.ts +47 -45
  40. package/lib/chevre/repo/place/seat.js +175 -45
  41. package/lib/chevre/repo/place/section.d.ts +60 -30
  42. package/lib/chevre/repo/place/section.js +337 -127
  43. package/lib/chevre/repo/task.d.ts +1 -1
  44. package/lib/chevre/repository.d.ts +8 -0
  45. package/lib/chevre/repository.js +16 -0
  46. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +6 -3
  47. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  48. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  49. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  50. package/lib/chevre/service/event/saveScreeningEvents.js +6 -5
  51. package/lib/chevre/service/offer/event/authorize/factory.js +4 -1
  52. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  53. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  54. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  55. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +4 -13
  56. package/lib/chevre/service/offer/onEventChanged.js +7 -5
  57. package/lib/chevre/service/offer.d.ts +5 -0
  58. package/lib/chevre/service/offer.js +34 -9
  59. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  60. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  61. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  62. package/lib/chevre/service/payment/any/factory.d.ts +4 -0
  63. package/lib/chevre/service/payment/any/factory.js +2 -1
  64. package/lib/chevre/service/payment/any.d.ts +4 -0
  65. package/lib/chevre/service/payment/any.js +2 -1
  66. package/lib/chevre/service/task/authorizePayment.js +1 -1
  67. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  68. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  69. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  70. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  71. package/lib/chevre/service/task/onResourceDeleted.js +60 -0
  72. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -7
  73. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +19 -7
  74. package/lib/chevre/service/task/onResourceUpdated.js +93 -15
  75. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  76. package/lib/chevre/service/taskHandler.js +1 -0
  77. package/package.json +4 -3
  78. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  79. package/lib/chevre/service/eventOld.d.ts +0 -60
  80. package/lib/chevre/service/eventOld.js +0 -864
@@ -0,0 +1,48 @@
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection } from 'mongoose';
3
+ import * as factory from '../../factory';
4
+ /**
5
+ * ゲートを操作する組織
6
+ */
7
+ interface IOperator {
8
+ /**
9
+ * 施設ID
10
+ */
11
+ id: string;
12
+ }
13
+ type IEntranceGate = Pick<factory.place.entranceGate.IEntranceGate, 'identifier' | 'name'>;
14
+ type ICreatingEntranceGate = Pick<factory.place.entranceGate.IEntranceGate, 'identifier' | 'name'>;
15
+ interface IUpdateOptions {
16
+ project: {
17
+ id: string;
18
+ };
19
+ }
20
+ /**
21
+ * 施設の入場ゲートリポジトリ
22
+ */
23
+ export declare class EntranceGateRepo {
24
+ private readonly operator;
25
+ private readonly civicStructureModel;
26
+ constructor(connection: Connection, operater: IOperator);
27
+ findEntranceGates(params: factory.place.entranceGate.ISearchConditions): Promise<IEntranceGate[]>;
28
+ addEntranceGatesByIdentifierIfNotExist(params: {
29
+ $set: ICreatingEntranceGate;
30
+ }[], options: IUpdateOptions): Promise<{
31
+ bulkWriteResult?: BulkWriteResult;
32
+ }>;
33
+ updateEntranceGatesByIdentifier(params: {
34
+ $set: ICreatingEntranceGate;
35
+ }[], options: IUpdateOptions): Promise<{
36
+ bulkWriteResult?: BulkWriteResult;
37
+ }>;
38
+ deleteEntranceGatesByIdentifier(params: {
39
+ /**
40
+ * ゲートコード
41
+ */
42
+ identifier: string;
43
+ }[], options: IUpdateOptions): Promise<{
44
+ bulkWriteResult?: BulkWriteResult;
45
+ }>;
46
+ private createMatchStages;
47
+ }
48
+ export {};
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntranceGateRepo = void 0;
13
+ const mongoose_1 = require("mongoose");
14
+ const factory = require("../../factory");
15
+ const settings_1 = require("../../settings");
16
+ const civicStructure_1 = require("../mongoose/schemas/civicStructure");
17
+ /**
18
+ * 施設の入場ゲートリポジトリ
19
+ */
20
+ class EntranceGateRepo {
21
+ constructor(connection, operater) {
22
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
23
+ this.operator = operater;
24
+ }
25
+ findEntranceGates(params) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const aggregate = this.civicStructureModel.aggregate([
28
+ {
29
+ $unwind: {
30
+ path: '$hasEntranceGate'
31
+ }
32
+ },
33
+ ...this.createMatchStages(params),
34
+ { $sort: { 'hasEntranceGate.identifier': factory.sortType.Ascending } },
35
+ {
36
+ $project: {
37
+ _id: 0,
38
+ identifier: '$hasEntranceGate.identifier',
39
+ name: '$hasEntranceGate.name'
40
+ }
41
+ }
42
+ ]);
43
+ const { limit, page } = params;
44
+ if (typeof limit === 'number' && limit > 0) {
45
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
46
+ aggregate.skip(limit * (pageMustBePositive - 1))
47
+ .limit(limit);
48
+ }
49
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
50
+ .exec();
51
+ });
52
+ }
53
+ addEntranceGatesByIdentifierIfNotExist(params, options) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const { project } = options;
56
+ const movieTheaterId = new mongoose_1.Types.ObjectId(this.operator.id);
57
+ const bulkWriteOps = [];
58
+ if (Array.isArray(params)) {
59
+ params.forEach(({ $set }) => {
60
+ const { identifier, name } = $set;
61
+ // ゲートを含まない施設があれば
62
+ const filter = {
63
+ 'project.id': { $eq: project.id },
64
+ _id: { $eq: movieTheaterId },
65
+ 'hasEntranceGate.identifier': { $ne: identifier }
66
+ };
67
+ const creatingEntranceGate = Object.assign({ identifier, typeOf: factory.placeType.Place }, (typeof (name === null || name === void 0 ? void 0 : name.ja) === 'string' || typeof (name === null || name === void 0 ? void 0 : name.en) === 'string') ? { name } : undefined);
68
+ // ゲートをpush
69
+ const update = {
70
+ $push: { hasEntranceGate: creatingEntranceGate }
71
+ };
72
+ const updateOne = { filter, update };
73
+ bulkWriteOps.push({ updateOne });
74
+ });
75
+ }
76
+ if (bulkWriteOps.length > 0) {
77
+ const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
78
+ return { bulkWriteResult };
79
+ }
80
+ return {};
81
+ });
82
+ }
83
+ updateEntranceGatesByIdentifier(params, options) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const { project } = options;
86
+ const movieTheaterId = new mongoose_1.Types.ObjectId(this.operator.id);
87
+ const bulkWriteOps = [];
88
+ if (Array.isArray(params)) {
89
+ params.forEach(({ $set }) => {
90
+ const { identifier, name } = $set;
91
+ // ゲートを含む施設があれば
92
+ const filter = {
93
+ 'project.id': { $eq: project.id },
94
+ _id: { $eq: movieTheaterId },
95
+ 'hasEntranceGate.identifier': { $eq: identifier }
96
+ };
97
+ const updatingEntranceGate = Object.assign({ identifier, typeOf: factory.placeType.Place }, (typeof (name === null || name === void 0 ? void 0 : name.ja) === 'string' || typeof (name === null || name === void 0 ? void 0 : name.en) === 'string') ? { name } : undefined);
98
+ const update = {
99
+ $set: {
100
+ 'hasEntranceGate.$[entranceGate]': updatingEntranceGate
101
+ }
102
+ };
103
+ // ゲートコードで$set
104
+ const arrayFilters = [
105
+ { 'entranceGate.identifier': { $eq: identifier } }
106
+ ];
107
+ const updateOne = { filter, update, arrayFilters };
108
+ bulkWriteOps.push({ updateOne });
109
+ });
110
+ }
111
+ if (bulkWriteOps.length > 0) {
112
+ const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
113
+ return { bulkWriteResult };
114
+ }
115
+ return {};
116
+ });
117
+ }
118
+ deleteEntranceGatesByIdentifier(params, options) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const { project } = options;
121
+ const movieTheaterId = new mongoose_1.Types.ObjectId(this.operator.id);
122
+ const bulkWriteOps = [];
123
+ if (Array.isArray(params)) {
124
+ params.forEach(({ identifier }) => {
125
+ // ゲートを含む施設があれば
126
+ const filter = {
127
+ 'project.id': { $eq: project.id },
128
+ _id: { $eq: movieTheaterId },
129
+ 'hasEntranceGate.identifier': { $eq: identifier }
130
+ };
131
+ // ゲートをpull
132
+ const update = {
133
+ $pull: { hasEntranceGate: { identifier: { $eq: identifier } } }
134
+ };
135
+ const updateOne = { filter, update };
136
+ bulkWriteOps.push({ updateOne });
137
+ });
138
+ }
139
+ if (bulkWriteOps.length > 0) {
140
+ const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
141
+ return { bulkWriteResult };
142
+ }
143
+ return {};
144
+ });
145
+ }
146
+ createMatchStages(params) {
147
+ var _a, _b, _c, _d;
148
+ const matchStages = [
149
+ { $match: { _id: { $eq: new mongoose_1.Types.ObjectId(this.operator.id) } } }
150
+ ];
151
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
152
+ if (typeof projectIdEq === 'string') {
153
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
154
+ }
155
+ const identifierEq = (_c = params.identifier) === null || _c === void 0 ? void 0 : _c.$eq;
156
+ if (typeof identifierEq === 'string') {
157
+ matchStages.push({ $match: { 'hasEntranceGate.identifier': { $eq: identifierEq } } });
158
+ }
159
+ const identifierIn = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$in;
160
+ if (Array.isArray(identifierIn)) {
161
+ matchStages.push({ $match: { 'hasEntranceGate.identifier': { $in: identifierIn } } });
162
+ }
163
+ return matchStages;
164
+ }
165
+ }
166
+ exports.EntranceGateRepo = EntranceGateRepo;
@@ -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,7 +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;
9
+ type IKeyOfProjection = keyof factory.place.movieTheater.IPlace | 'offers.typeOf' | 'offers.eligibleQuantity' | 'offers.availabilityStartsGraceTime' | 'offers.availabilityEndsGraceTime';
10
+ type IMovieTheaterPublicAttributes = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'id' | 'kanaName' | 'name' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf' | 'url'> & {
11
+ offers?: Pick<factory.place.movieTheater.IOffer, 'availabilityEndsGraceTime' | 'availabilityStartsGraceTime'>;
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
+ }
9
26
  /**
10
27
  * 施設リポジトリ
11
28
  */
@@ -16,15 +33,35 @@ export declare class MovieTheaterRepo {
16
33
  /**
17
34
  * 施設を保管する
18
35
  */
19
- saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<{
36
+ saveMovieTheater(params: Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'hasEntranceGate' | 'id' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'typeOf' | 'url'> & {
37
+ hasEntranceGate?: never;
38
+ }): Promise<{
20
39
  id: string;
21
40
  }>;
22
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
+ /**
54
+ * 追加あるいは編集された施設
55
+ */
56
+ modifiedMovieTheaters: {
57
+ id: string;
58
+ }[];
59
+ }>;
23
60
  /**
24
61
  * 施設のpublic属性検索
25
62
  * 2024-09-18~
26
63
  */
27
- projectPublicFields(params: factory.place.movieTheater.ISearchConditions): Promise<Omit<factory.place.movieTheater.IPlace, 'screenCount'>[]>;
64
+ projectPublicFields(params: factory.place.movieTheater.ISearchConditions): Promise<IMovieTheaterPublicAttributes[]>;
28
65
  /**
29
66
  * 施設検索
30
67
  * redefine(2024-09-18~)
@@ -26,7 +26,11 @@ const settings_1 = require("../../settings");
26
26
  const civicStructure_1 = require("../mongoose/schemas/civicStructure");
27
27
  const AVAILABLE_PROJECT_FIELDS = [
28
28
  'additionalProperty', 'branchCode', 'hasEntranceGate', 'kanaName', 'name',
29
- 'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url'
29
+ 'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url',
30
+ 'offers.typeOf',
31
+ 'offers.eligibleQuantity',
32
+ 'offers.availabilityStartsGraceTime',
33
+ 'offers.availabilityEndsGraceTime'
30
34
  ];
31
35
  /**
32
36
  * 施設リポジトリ
@@ -37,7 +41,7 @@ class MovieTheaterRepo {
37
41
  }
38
42
  // tslint:disable-next-line:max-func-body-length
39
43
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
44
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
41
45
  const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
42
46
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
43
47
  if (typeof projectIdEq === 'string') {
@@ -71,11 +75,15 @@ class MovieTheaterRepo {
71
75
  ]
72
76
  });
73
77
  }
74
- 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;
75
83
  if (typeof parentOrganizationIdEq === 'string') {
76
84
  andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } });
77
85
  }
78
- 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;
79
87
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
80
88
  andConditions.push({
81
89
  additionalProperty: {
@@ -94,13 +102,15 @@ class MovieTheaterRepo {
94
102
  let savedId;
95
103
  let doc;
96
104
  if (params.id === '') {
97
- const { id } = params, creatingParams = __rest(params, ["id"]); // omit id(2024-09-12~)
105
+ const { id, hasEntranceGate } = params, // 入場ゲートを保管しない(2026-01-11~)
106
+ creatingParams = __rest(params, ["id", "hasEntranceGate"]); // omit id(2024-09-12~)
98
107
  doc = yield this.civicStructureModel.create(creatingParams);
99
108
  savedId = doc.id;
100
109
  }
101
110
  else {
102
111
  // 上書き禁止属性を除外(2022-08-24~)
103
- const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
112
+ const { id, branchCode, project, typeOf, hasEntranceGate } = params, // 入場ゲートを保管しない(2026-01-11~)
113
+ updateFields = __rest(params, ["id", "branchCode", "project", "typeOf", "hasEntranceGate"]);
104
114
  doc = yield this.civicStructureModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true, projection: { _id: 1 } })
105
115
  .exec();
106
116
  savedId = params.id;
@@ -128,6 +138,67 @@ class MovieTheaterRepo {
128
138
  }
129
139
  });
130
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
+ const queryFilters = [];
150
+ if (Array.isArray(params)) {
151
+ params.forEach(({ $set, $unset }) => {
152
+ const { branchCode, hasEntranceGate, hasPOS } = $set, // 入場ゲート,POSを決して編集しないように
153
+ setFields = __rest($set, ["branchCode", "hasEntranceGate", "hasPOS"]);
154
+ if (typeof branchCode !== 'string' || branchCode === '') {
155
+ throw new factory.errors.ArgumentNull('branchCode');
156
+ }
157
+ // リソースのユニークネスを保証するfilter
158
+ const filter = {
159
+ typeOf: { $eq: factory.placeType.MovieTheater },
160
+ 'project.id': { $eq: project.id },
161
+ branchCode: { $eq: branchCode },
162
+ // プロジェクトとコードでユニークな仕様だが、販売者も指定する -> 異なる販売者でコードが重複すればDuplicateErrorとなる
163
+ 'parentOrganization.id': { $exists: true, $eq: sellerId }
164
+ };
165
+ const initialMovieTheater = {
166
+ typeOf: factory.placeType.MovieTheater,
167
+ project: { id: project.id, typeOf: factory.organizationType.Project },
168
+ branchCode,
169
+ parentOrganization: { id: sellerId, typeOf: factory.organizationType.Corporation }
170
+ };
171
+ const setOnInsert = initialMovieTheater;
172
+ const update = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
173
+ const updateOne = {
174
+ filter,
175
+ update,
176
+ upsert: true
177
+ };
178
+ bulkWriteOps.push({ updateOne });
179
+ queryFilters.push({
180
+ typeOf: { $eq: factory.placeType.MovieTheater },
181
+ 'project.id': { $eq: project.id },
182
+ branchCode: { $eq: branchCode },
183
+ // プロジェクトとコードでユニークな仕様だが、販売者も指定する -> 異なる販売者でコードが重複すればDuplicateErrorとなる
184
+ 'parentOrganization.id': { $exists: true, $eq: sellerId }
185
+ });
186
+ });
187
+ }
188
+ if (bulkWriteOps.length > 0) {
189
+ const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
190
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
191
+ const modifiedMovieTheaters = yield this.civicStructureModel.find({ $or: queryFilters }, {
192
+ _id: 0,
193
+ id: { $toString: '$_id' }
194
+ })
195
+ .lean()
196
+ .exec();
197
+ return { bulkWriteResult, modifiedMovieTheaters };
198
+ }
199
+ return { modifiedMovieTheaters: [] };
200
+ });
201
+ }
131
202
  /**
132
203
  * 施設のpublic属性検索
133
204
  * 2024-09-18~
@@ -1,6 +1,28 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection, FilterQuery, PipelineStage } from 'mongoose';
2
3
  import * as factory from '../../factory';
4
+ import { IDocType } from '../mongoose/schemas/place';
3
5
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
6
+ type IMatchStage = PipelineStage.Match;
7
+ type IUpsertingRoom = Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>;
8
+ interface IUpdateOptions {
9
+ project: {
10
+ id: string;
11
+ };
12
+ parentOrganization?: {
13
+ id?: string;
14
+ };
15
+ movieTheaterCode: string;
16
+ }
17
+ interface IUpsertOptions {
18
+ project: {
19
+ id: string;
20
+ };
21
+ parentOrganization?: {
22
+ id?: string;
23
+ };
24
+ movieTheaterId: string;
25
+ }
4
26
  /**
5
27
  * ルーム編集時レスポンス
6
28
  */
@@ -23,47 +45,34 @@ export declare class ScreeningRoomRepo {
23
45
  private readonly civicStructureModel;
24
46
  private readonly placeModel;
25
47
  constructor(connection: Connection);
48
+ static CREATE_ROOM_MONGO_CONDITIONS(searchConditions: Omit<factory.place.screeningRoom.ISearchConditions, '$projection' | 'limit' | 'page'>): IMatchStage[];
26
49
  saveScreeningRooms4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
27
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
28
- containedInPlace: {
29
- branchCode: string;
30
- };
31
- parentOrganization?: {
32
- id?: string;
33
- };
34
- }): Promise<IUpdateScreeningRoomResult>;
35
- updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
36
- containedInPlace: {
37
- branchCode: string;
38
- };
39
- parentOrganization?: {
40
- id?: string;
41
- };
42
- }, $unset: any): Promise<IUpdateScreeningRoomResult>;
50
+ createRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
51
+ updateRoomByBranchCode(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, $unset: any, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
43
52
  updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
44
53
  project: {
45
54
  id: string;
46
55
  };
47
56
  containedInPlace: Pick<factory.place.screeningRoom.IContainedInPlace, 'id' | 'name'>;
48
57
  }): Promise<void>;
49
- deleteScreeningRoom(screeningRoom: {
50
- project: {
51
- id: string;
52
- };
53
- parentOrganization?: {
54
- id?: string;
55
- };
58
+ /**
59
+ * コードをキーにして冪等作成
60
+ * 2026-01-12~
61
+ */
62
+ upsertRoomsByBranchCode(params: {
63
+ $set: IUpsertingRoom;
64
+ $unset?: {
65
+ [key in keyof IUpsertingRoom]?: 1;
66
+ };
67
+ }[], options: IUpsertOptions): Promise<{
68
+ bulkWriteResult?: BulkWriteResult;
69
+ }>;
70
+ deleteRoomByBranchCode(screeningRoom: {
56
71
  /**
57
72
  * ルームコード
58
73
  */
59
74
  branchCode: string;
60
- containedInPlace: {
61
- /**
62
- * 施設コード
63
- */
64
- branchCode: string;
65
- };
66
- }): Promise<IUpdateScreeningRoomResult>;
75
+ }, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
67
76
  deleteScreeningRoomsByMovieTheaterId(params: {
68
77
  project: {
69
78
  id: string;
@@ -76,6 +85,7 @@ export declare class ScreeningRoomRepo {
76
85
  };
77
86
  }): Promise<import("mongodb").DeleteResult>;
78
87
  searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
88
+ findRooms(params: Omit<factory.place.screeningRoom.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed' | 'maximumAttendeeCapacity'>[]>;
79
89
  /**
80
90
  * セクションと座席も含めたひとつのルームを取得する
81
91
  */
@@ -114,5 +124,24 @@ export declare class ScreeningRoomRepo {
114
124
  id: string;
115
125
  };
116
126
  }): Promise<void>;
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
+ description?: any;
129
+ openingHoursSpecification?: any;
130
+ smokingAllowed?: boolean;
131
+ containsPlace: (Pick<import("@chevre/factory/lib/place/screeningRoomSection").IPlace, "name" | "typeOf" | "additionalProperty" | "branchCode"> & {
132
+ containsPlace?: factory.place.seat.IPlace[];
133
+ })[];
134
+ } & {
135
+ _id: import("mongoose").Types.ObjectId;
136
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/screeningRoom").IPlace, "containsPlace"> & {
137
+ description?: any;
138
+ openingHoursSpecification?: any;
139
+ smokingAllowed?: boolean;
140
+ containsPlace: (Pick<import("@chevre/factory/lib/place/screeningRoomSection").IPlace, "name" | "typeOf" | "additionalProperty" | "branchCode"> & {
141
+ containsPlace?: factory.place.seat.IPlace[];
142
+ })[];
143
+ } & {
144
+ _id: import("mongoose").Types.ObjectId;
145
+ }>>;
117
146
  }
118
147
  export {};