@chevre/domain 22.3.0-alpha.8 → 22.3.0

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 (134) hide show
  1. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +1 -1
  2. package/example/src/chevre/importEventsFromCOA.ts +6 -3
  3. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +9 -6
  4. package/example/src/chevre/migrateCustomerAdditionalProperties.ts +8 -6
  5. package/example/src/chevre/migrateEventSeries2secondary.ts +70 -0
  6. package/example/src/chevre/migrateRoomAdditionalProperties.ts +8 -6
  7. package/example/src/chevre/migrateRoomSectionAdditionalProperties.ts +8 -6
  8. package/example/src/chevre/projectFields.ts +6 -10
  9. package/example/src/chevre/unsetUnnecessaryFields.ts +15 -2
  10. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +180 -0
  11. package/lib/chevre/repo/account.d.ts +25 -1
  12. package/lib/chevre/repo/accountTitle.d.ts +4 -4
  13. package/lib/chevre/repo/accountingReport.d.ts +25 -1
  14. package/lib/chevre/repo/action.d.ts +11 -11
  15. package/lib/chevre/repo/action.js +4 -7
  16. package/lib/chevre/repo/additionalProperty.d.ts +33 -8
  17. package/lib/chevre/repo/additionalProperty.js +52 -106
  18. package/lib/chevre/repo/aggregateOffer.d.ts +26 -2
  19. package/lib/chevre/repo/aggregateReservation.d.ts +25 -1
  20. package/lib/chevre/repo/aggregation.d.ts +26 -2
  21. package/lib/chevre/repo/assetTransaction.d.ts +5 -5
  22. package/lib/chevre/repo/authorization.d.ts +25 -1
  23. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  24. package/lib/chevre/repo/comment.d.ts +3 -3
  25. package/lib/chevre/repo/creativeWork.d.ts +12 -10
  26. package/lib/chevre/repo/creativeWork.js +51 -23
  27. package/lib/chevre/repo/customer.d.ts +4 -4
  28. package/lib/chevre/repo/event.d.ts +55 -82
  29. package/lib/chevre/repo/event.js +130 -274
  30. package/lib/chevre/repo/eventSeries.d.ts +74 -11
  31. package/lib/chevre/repo/eventSeries.js +301 -45
  32. package/lib/chevre/repo/member.d.ts +4 -4
  33. package/lib/chevre/repo/member.js +0 -15
  34. package/lib/chevre/repo/merchantReturnPolicy.d.ts +3 -3
  35. package/lib/chevre/repo/message.d.ts +30 -6
  36. package/lib/chevre/repo/message.js +25 -22
  37. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +0 -3
  38. package/lib/chevre/repo/mongoose/schemas/civicStructure.d.ts +12 -0
  39. package/lib/chevre/repo/mongoose/schemas/civicStructure.js +131 -0
  40. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +1 -1
  41. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +21 -23
  42. package/lib/chevre/repo/mongoose/schemas/event.d.ts +1 -5
  43. package/lib/chevre/repo/mongoose/schemas/event.js +11 -78
  44. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +13 -0
  45. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +219 -0
  46. package/lib/chevre/repo/mongoose/schemas/message.js +0 -3
  47. package/lib/chevre/repo/mongoose/schemas/note.js +0 -3
  48. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +21 -23
  50. package/lib/chevre/repo/mongoose/schemas/place.d.ts +1 -5
  51. package/lib/chevre/repo/mongoose/schemas/place.js +38 -42
  52. package/lib/chevre/repo/note.d.ts +27 -6
  53. package/lib/chevre/repo/note.js +25 -22
  54. package/lib/chevre/repo/offer.d.ts +8 -8
  55. package/lib/chevre/repo/offer.js +0 -21
  56. package/lib/chevre/repo/offerCatalog.d.ts +4 -4
  57. package/lib/chevre/repo/offerCatalogItem.d.ts +25 -1
  58. package/lib/chevre/repo/offerItemCondition.d.ts +28 -0
  59. package/lib/chevre/repo/offerItemCondition.js +8 -1
  60. package/lib/chevre/repo/order.d.ts +5 -5
  61. package/lib/chevre/repo/order.js +0 -73
  62. package/lib/chevre/repo/orderInTransaction.d.ts +27 -3
  63. package/lib/chevre/repo/ownershipInfo.d.ts +5 -5
  64. package/lib/chevre/repo/paymentService.d.ts +25 -1
  65. package/lib/chevre/repo/paymentServiceProvider.d.ts +26 -2
  66. package/lib/chevre/repo/place/busStop.d.ts +1 -1
  67. package/lib/chevre/repo/place/busStop.js +11 -11
  68. package/lib/chevre/repo/place/hasPOS.d.ts +1 -1
  69. package/lib/chevre/repo/place/hasPOS.js +7 -7
  70. package/lib/chevre/repo/place/movieTheater.d.ts +24 -53
  71. package/lib/chevre/repo/place/movieTheater.js +115 -140
  72. package/lib/chevre/repo/place/screeningRoom.d.ts +5 -0
  73. package/lib/chevre/repo/place/screeningRoom.js +67 -3
  74. package/lib/chevre/repo/place/seat.d.ts +1 -0
  75. package/lib/chevre/repo/place/seat.js +4 -1
  76. package/lib/chevre/repo/place/section.d.ts +1 -0
  77. package/lib/chevre/repo/place/section.js +4 -1
  78. package/lib/chevre/repo/priceSpecification.d.ts +4 -4
  79. package/lib/chevre/repo/priceSpecification.js +0 -1
  80. package/lib/chevre/repo/product.d.ts +4 -4
  81. package/lib/chevre/repo/productModel.d.ts +25 -1
  82. package/lib/chevre/repo/productOffer.d.ts +25 -1
  83. package/lib/chevre/repo/project.d.ts +5 -5
  84. package/lib/chevre/repo/project.js +0 -2
  85. package/lib/chevre/repo/reservation.d.ts +5 -5
  86. package/lib/chevre/repo/reservation.js +6 -59
  87. package/lib/chevre/repo/seller.d.ts +5 -5
  88. package/lib/chevre/repo/serviceOutput.d.ts +25 -1
  89. package/lib/chevre/repo/task.d.ts +8 -8
  90. package/lib/chevre/repo/transaction.d.ts +4 -4
  91. package/lib/chevre/repo/trip.d.ts +25 -1
  92. package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -2
  93. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -3
  94. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -4
  95. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
  96. package/lib/chevre/service/assetTransaction/reserve/start.js +1 -1
  97. package/lib/chevre/service/event/createEvent.js +4 -2
  98. package/lib/chevre/service/event.d.ts +6 -0
  99. package/lib/chevre/service/event.js +134 -49
  100. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
  101. package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
  102. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
  103. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +10 -10
  104. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
  105. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -1
  106. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  107. package/lib/chevre/service/offer/onEventChanged.d.ts +2 -0
  108. package/lib/chevre/service/offer/onEventChanged.js +22 -6
  109. package/lib/chevre/service/offer.js +1 -1
  110. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
  111. package/lib/chevre/service/payment/movieTicket/factory.js +0 -6
  112. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +1 -1
  113. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +0 -6
  114. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  115. package/lib/chevre/service/report/telemetry.js +1 -1
  116. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -1
  117. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  118. package/lib/chevre/service/task/onEventChanged.js +2 -0
  119. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +4 -2
  120. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  121. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +12 -7
  122. package/lib/chevre/service/task/onResourceUpdated.js +13 -11
  123. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  124. package/package.json +6 -6
  125. package/example/src/chevre/createManyEvents.ts +0 -75
  126. package/example/src/chevre/migrateAccountTitleCategoryAdditionalProperties.ts +0 -113
  127. package/example/src/chevre/migrateAccountTitleSetAdditionalProperties.ts +0 -120
  128. package/example/src/chevre/migrateMembers2.ts +0 -74
  129. package/example/src/chevre/playAroundMessage.ts +0 -73
  130. package/example/src/chevre/playAroundNote.ts +0 -34
  131. package/example/src/chevre/projectEventFields.ts +0 -39
  132. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +0 -45
  133. package/example/src/chevre/searchEventIds.ts +0 -24
  134. package/example/src/chevre/searchScreeningEventSeries.ts +0 -34
@@ -22,29 +22,39 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import type { Connection, Document, FilterQuery } from 'mongoose';
25
+ import type { Connection, FilterQuery } from 'mongoose';
26
26
  import * as factory from '../../factory';
27
+ import { IDocType } from '../mongoose/schemas/civicStructure';
27
28
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
28
- export type IMovieTheaterIncludingScreeningRooms = factory.place.movieTheater.IPlace & {
29
+ export type IMovieTheaterIncludingScreeningRooms = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf'> & {
29
30
  containsPlace: factory.place.screeningRoom.IPlace[];
30
31
  };
31
- type IKeyOfProjectionMovieTheater = keyof factory.place.movieTheater.IPlace | '_id';
32
+ type IKeyOfProjection = keyof factory.place.movieTheater.IPlace;
32
33
  /**
33
34
  * 施設リポジトリ
34
35
  */
35
36
  export declare class MovieTheaterRepo {
37
+ private readonly civicStructureModel;
36
38
  private readonly placeModel;
37
39
  constructor(connection: Connection);
38
40
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/movieTheater").IPlace>[];
39
41
  /**
40
42
  * 施設を保管する
41
43
  */
42
- saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<factory.place.movieTheater.IPlace>;
44
+ saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<{
45
+ id: string;
46
+ }>;
43
47
  saveMovieTheaterByBranchCode4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
48
+ /**
49
+ * 施設のpublic属性検索
50
+ * 2024-09-18~
51
+ */
52
+ projectPublicFields(params: factory.place.movieTheater.ISearchConditions): Promise<Omit<factory.place.movieTheater.IPlace, 'screenCount'>[]>;
44
53
  /**
45
54
  * 施設検索
55
+ * redefine(2024-09-18~)
46
56
  */
47
- searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions, inclusion: IKeyOfProjectionMovieTheater[], exclusion: IKeyOfProjectionMovieTheater[]): Promise<factory.place.movieTheater.IPlace[]>;
57
+ projectFields(params: factory.place.movieTheater.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.place.movieTheater.IPlace, 'screenCount'>[]>;
48
58
  deleteMovieTheaterById(params: {
49
59
  project: {
50
60
  id: string;
@@ -73,62 +83,23 @@ export declare class MovieTheaterRepo {
73
83
  id: string;
74
84
  };
75
85
  }): Promise<void>;
76
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, ((import("@chevre/factory/lib/place/movieTheater").IPlace & {
77
- hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
78
- }) | import("@chevre/factory/lib/place/screeningRoom").IPlace) & {
79
- alternateName?: any;
80
- description?: any;
81
- openingHoursSpecification?: any;
82
- smokingAllowed?: boolean | undefined;
83
- sameAs?: any;
84
- }> & Omit<(import("@chevre/factory/lib/place/movieTheater").IPlace & {
86
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/movieTheater").IPlace, "id"> & {
85
87
  hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
86
- } & {
87
- alternateName?: any;
88
- description?: any;
89
- openingHoursSpecification?: any;
90
- smokingAllowed?: boolean | undefined;
91
- sameAs?: any;
92
- } & {
93
- _id: import("mongoose").Types.ObjectId;
94
- }) | (import("@chevre/factory/lib/place/screeningRoom").IPlace & {
95
- alternateName?: any;
96
- description?: any;
97
- openingHoursSpecification?: any;
98
- smokingAllowed?: boolean | undefined;
99
- sameAs?: any;
100
88
  } & {
101
89
  _id: import("mongoose").Types.ObjectId;
102
- }), never>, import("mongoose").QueryOptions<Document<unknown, {}, ((import("@chevre/factory/lib/place/movieTheater").IPlace & {
90
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/movieTheater").IPlace, "id"> & {
103
91
  hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
104
- }) | import("@chevre/factory/lib/place/screeningRoom").IPlace) & {
105
- alternateName?: any;
106
- description?: any;
107
- openingHoursSpecification?: any;
108
- smokingAllowed?: boolean | undefined;
109
- sameAs?: any;
110
- }> & Omit<(import("@chevre/factory/lib/place/movieTheater").IPlace & {
111
- hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
112
- } & {
113
- alternateName?: any;
114
- description?: any;
115
- openingHoursSpecification?: any;
116
- smokingAllowed?: boolean | undefined;
117
- sameAs?: any;
118
- } & {
119
- _id: import("mongoose").Types.ObjectId;
120
- }) | (import("@chevre/factory/lib/place/screeningRoom").IPlace & {
121
- alternateName?: any;
122
- description?: any;
123
- openingHoursSpecification?: any;
124
- smokingAllowed?: boolean | undefined;
125
- sameAs?: any;
126
92
  } & {
127
93
  _id: import("mongoose").Types.ObjectId;
128
- }), never>>>;
94
+ }>>;
129
95
  unsetUnnecessaryFields(params: {
130
96
  filter: any;
131
97
  $unset: any;
132
- }): Promise<import("mongodb").UpdateResult>;
98
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
99
+ /**
100
+ * 旧施設廃止専用メソッド
101
+ * 2024-09-17~
102
+ */
103
+ deleteOldMovieTheaters(): Promise<import("mongodb").DeleteResult>;
133
104
  }
134
105
  export {};
@@ -23,18 +23,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MovieTheaterRepo = void 0;
24
24
  const factory = require("../../factory");
25
25
  const settings_1 = require("../../settings");
26
+ const civicStructure_1 = require("../mongoose/schemas/civicStructure");
26
27
  const place_1 = require("../mongoose/schemas/place");
28
+ const AVAILABLE_PROJECT_FIELDS = [
29
+ 'additionalProperty', 'branchCode', 'hasEntranceGate', 'kanaName', 'name',
30
+ 'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url'
31
+ ];
27
32
  /**
28
33
  * 施設リポジトリ
29
34
  */
30
35
  class MovieTheaterRepo {
31
36
  constructor(connection) {
37
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
32
38
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
33
39
  }
34
40
  // tslint:disable-next-line:max-func-body-length
35
41
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
36
42
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
37
- // MongoDB検索条件
38
43
  const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
39
44
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
40
45
  if (typeof projectIdEq === 'string') {
@@ -42,84 +47,35 @@ class MovieTheaterRepo {
42
47
  }
43
48
  const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
44
49
  if (typeof branchCodeEq === 'string') {
45
- andConditions.push({
46
- branchCode: {
47
- $exists: true,
48
- $eq: branchCodeEq
49
- }
50
- });
50
+ andConditions.push({ branchCode: { $eq: branchCodeEq } });
51
51
  }
52
52
  const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
53
53
  if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
54
- andConditions.push({
55
- branchCode: {
56
- $exists: true,
57
- $regex: new RegExp(branchCodeRegex)
58
- }
59
- });
54
+ andConditions.push({ branchCode: { $regex: new RegExp(branchCodeRegex) } });
60
55
  }
61
- // tslint:disable-next-line:no-single-line-block-comment
62
- /* istanbul ignore else */
63
56
  if (Array.isArray(params.branchCodes)) {
64
- andConditions.push({
65
- branchCode: {
66
- $exists: true,
67
- $in: params.branchCodes
68
- }
69
- });
57
+ andConditions.push({ branchCode: { $in: params.branchCodes } });
70
58
  }
71
- // tslint:disable-next-line:no-single-line-block-comment
72
- /* istanbul ignore else */
73
59
  const idEq = (_e = params.id) === null || _e === void 0 ? void 0 : _e.$eq;
74
60
  if (typeof idEq === 'string') {
75
- andConditions.push({
76
- _id: {
77
- $eq: idEq
78
- }
79
- });
61
+ andConditions.push({ _id: { $eq: idEq } });
80
62
  }
81
63
  const idIn = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$in;
82
64
  if (Array.isArray(idIn)) {
83
- andConditions.push({
84
- _id: {
85
- $in: idIn
86
- }
87
- });
65
+ andConditions.push({ _id: { $in: idIn } });
88
66
  }
89
- // tslint:disable-next-line:no-single-line-block-comment
90
- /* istanbul ignore else */
91
67
  if (typeof params.name === 'string' && params.name.length > 0) {
92
68
  andConditions.push({
93
69
  $or: [
94
- {
95
- 'name.ja': {
96
- $exists: true,
97
- $regex: new RegExp(params.name)
98
- }
99
- },
100
- {
101
- 'name.en': {
102
- $exists: true,
103
- $regex: new RegExp(params.name)
104
- }
105
- },
106
- {
107
- kanaName: {
108
- $exists: true,
109
- $regex: new RegExp(params.name)
110
- }
111
- }
70
+ { 'name.ja': { $exists: true, $regex: new RegExp(params.name) } },
71
+ { 'name.en': { $exists: true, $regex: new RegExp(params.name) } },
72
+ { kanaName: { $exists: true, $regex: new RegExp(params.name) } }
112
73
  ]
113
74
  });
114
75
  }
115
76
  const parentOrganizationIdEq = (_h = (_g = params.parentOrganization) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
116
77
  if (typeof parentOrganizationIdEq === 'string') {
117
- andConditions.push({
118
- 'parentOrganization.id': {
119
- $exists: true,
120
- $eq: parentOrganizationIdEq
121
- }
122
- });
78
+ andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } });
123
79
  }
124
80
  const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
125
81
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
@@ -137,43 +93,34 @@ class MovieTheaterRepo {
137
93
  */
138
94
  saveMovieTheater(params) {
139
95
  return __awaiter(this, void 0, void 0, function* () {
96
+ let savedId;
140
97
  let doc;
141
98
  if (params.id === '') {
142
- doc = yield this.placeModel.create(params);
99
+ const { id } = params, creatingParams = __rest(params, ["id"]); // omit id(2024-09-12~)
100
+ doc = yield this.civicStructureModel.create(creatingParams);
101
+ savedId = doc.id;
143
102
  }
144
103
  else {
145
104
  // 上書き禁止属性を除外(2022-08-24~)
146
105
  const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
147
- doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, {
148
- upsert: false,
149
- new: true,
150
- projection: {
151
- __v: 0,
152
- createdAt: 0,
153
- updatedAt: 0,
154
- containsPlace: 0
155
- }
156
- })
106
+ doc = yield this.civicStructureModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true, projection: { _id: 1 } })
157
107
  .exec();
108
+ savedId = params.id;
158
109
  }
159
110
  if (doc === null) {
160
- throw new factory.errors.NotFound(this.placeModel.modelName);
111
+ throw new factory.errors.NotFound(this.civicStructureModel.modelName);
161
112
  }
162
- return doc.toObject();
113
+ return { id: savedId };
163
114
  });
164
115
  }
165
- // void化(2023-06-23~)
166
116
  saveMovieTheaterByBranchCode4coa(params) {
167
117
  return __awaiter(this, void 0, void 0, function* () {
168
118
  const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
169
- const movieTheaterDoc = yield this.placeModel.findOneAndUpdate({
119
+ const movieTheaterDoc = yield this.civicStructureModel.findOneAndUpdate({
170
120
  typeOf: { $eq: factory.placeType.MovieTheater },
171
121
  'project.id': { $eq: params.project.id },
172
122
  branchCode: { $eq: params.branchCode }
173
- },
174
- // containsPlaceの保管を廃止(2023-07-04~)
175
- // params,
176
- movieTheater4update, {
123
+ }, movieTheater4update, {
177
124
  new: true,
178
125
  projection: { _id: 1 }
179
126
  })
@@ -181,72 +128,88 @@ class MovieTheaterRepo {
181
128
  if (movieTheaterDoc === null) {
182
129
  throw new factory.errors.NotFound(factory.placeType.MovieTheater);
183
130
  }
184
- const movieTheater = movieTheaterDoc.toObject();
185
- // ScreeningRoomも保管する(2023-06-24~)
186
- const creatingScreeningRooms = params.containsPlace.map((place) => {
187
- return Object.assign(Object.assign({}, place), { containedInPlace: {
188
- id: movieTheater.id,
189
- typeOf: params.typeOf,
190
- branchCode: params.branchCode,
191
- name: params.name
192
- }, containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [], project: params.project });
193
- });
194
- yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
195
- const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
196
- if (typeof branchCode === 'string' && branchCode.length > 0) {
197
- yield this.placeModel.findOneAndUpdate({
198
- typeOf: { $eq: factory.placeType.ScreeningRoom },
199
- 'project.id': { $eq: createScreeningRoom.project.id },
200
- 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
201
- branchCode: { $eq: createScreeningRoom.branchCode }
202
- }, {
203
- $setOnInsert: {
204
- typeOf: createScreeningRoom.typeOf,
205
- project: createScreeningRoom.project,
206
- branchCode: createScreeningRoom.branchCode
207
- },
208
- $set: setFields
209
- }, {
210
- upsert: true,
211
- new: true,
212
- projection: { _id: 1 }
213
- })
214
- .exec();
215
- }
216
- })));
131
+ });
132
+ }
133
+ /**
134
+ * 施設のpublic属性検索
135
+ * 2024-09-18~
136
+ */
137
+ projectPublicFields(params) {
138
+ var _a;
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const conditions = MovieTheaterRepo.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
141
+ const projection = {
142
+ _id: 0,
143
+ id: { $toString: '$_id' },
144
+ additionalProperty: 1, branchCode: 1,
145
+ kanaName: 1, name: 1,
146
+ parentOrganization: 1, project: 1, telephone: 1, typeOf: 1, url: 1,
147
+ // hasEntranceGate: 1,
148
+ // offers: 1,
149
+ // 'offers.typeOf': 1,
150
+ // 'offers.eligibleQuantity': 1,
151
+ 'offers.availabilityStartsGraceTime': 1,
152
+ 'offers.availabilityEndsGraceTime': 1
153
+ // 'offers.availabilityStartsGraceTimeOnPOS': 1,
154
+ // 'offers.availabilityEndsGraceTimeOnPOS': 1,
155
+ };
156
+ const query = this.civicStructureModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
157
+ if (typeof params.limit === 'number' && params.limit > 0) {
158
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
159
+ query.limit(params.limit)
160
+ .skip(params.limit * (page - 1));
161
+ }
162
+ // tslint:disable-next-line:no-single-line-block-comment
163
+ /* istanbul ignore else */
164
+ if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
165
+ query.sort({ branchCode: params.sort.branchCode });
166
+ }
167
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
168
+ .lean() // 2024-09-18~
169
+ .exec();
217
170
  });
218
171
  }
219
172
  /**
220
173
  * 施設検索
174
+ * redefine(2024-09-18~)
221
175
  */
222
- searchMovieTheaters(params, inclusion, exclusion) {
176
+ projectFields(params, inclusion
177
+ // exclusion: IKeyOfProjection[]
178
+ ) {
223
179
  var _a;
224
180
  return __awaiter(this, void 0, void 0, function* () {
225
181
  const conditions = MovieTheaterRepo.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
226
- let projection = {};
182
+ // let projection: { [key: string]: number } = {};
183
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
184
+ // inclusion.forEach((field) => {
185
+ // if (String(field) !== 'containsPlace' && String(field) !== 'hasPOS') { // 除外(2023-10-26~)
186
+ // projection[field] = 1;
187
+ // }
188
+ // });
189
+ // } else {
190
+ // projection = {
191
+ // __v: 0,
192
+ // createdAt: 0,
193
+ // updatedAt: 0,
194
+ // // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
195
+ // containsPlace: 0,
196
+ // hasPOS: 0 // 除外(2023-10-26~)
197
+ // };
198
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
199
+ // exclusion.forEach((field) => {
200
+ // projection[field] = 0;
201
+ // });
202
+ // }
203
+ // }
204
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
227
205
  if (Array.isArray(inclusion) && inclusion.length > 0) {
228
- inclusion.forEach((field) => {
229
- if (String(field) !== 'containsPlace' && String(field) !== 'hasPOS') { // 除外(2023-10-26~)
230
- projection[field] = 1;
231
- }
232
- });
206
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
233
207
  }
234
208
  else {
235
- projection = {
236
- __v: 0,
237
- createdAt: 0,
238
- updatedAt: 0,
239
- // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
240
- containsPlace: 0,
241
- hasPOS: 0 // 除外(2023-10-26~)
242
- };
243
- if (Array.isArray(exclusion) && exclusion.length > 0) {
244
- exclusion.forEach((field) => {
245
- projection[field] = 0;
246
- });
247
- }
209
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
248
210
  }
249
- const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
211
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
212
+ const query = this.civicStructureModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
250
213
  if (typeof params.limit === 'number' && params.limit > 0) {
251
214
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
252
215
  query.limit(params.limit)
@@ -258,13 +221,13 @@ class MovieTheaterRepo {
258
221
  query.sort({ branchCode: params.sort.branchCode });
259
222
  }
260
223
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
261
- .exec()
262
- .then((docs) => docs.map((doc) => doc.toObject()));
224
+ .lean() // 2024-09-18~
225
+ .exec();
263
226
  });
264
227
  }
265
228
  deleteMovieTheaterById(params) {
266
229
  return __awaiter(this, void 0, void 0, function* () {
267
- yield this.placeModel.findOneAndDelete({
230
+ yield this.civicStructureModel.findOneAndDelete({
268
231
  typeOf: { $eq: factory.placeType.MovieTheater },
269
232
  _id: { $eq: params.id },
270
233
  'project.id': { $eq: params.project.id }
@@ -272,7 +235,7 @@ class MovieTheaterRepo {
272
235
  .exec()
273
236
  .then((doc) => {
274
237
  if (doc === null) {
275
- throw new factory.errors.NotFound(this.placeModel.modelName);
238
+ throw new factory.errors.NotFound(this.civicStructureModel.modelName);
276
239
  }
277
240
  });
278
241
  });
@@ -282,7 +245,7 @@ class MovieTheaterRepo {
282
245
  */
283
246
  deleteMovieTheatersByParentOrganizationId(params) {
284
247
  return __awaiter(this, void 0, void 0, function* () {
285
- return this.placeModel.deleteMany({
248
+ return this.civicStructureModel.deleteMany({
286
249
  typeOf: { $eq: factory.placeType.MovieTheater },
287
250
  'project.id': { $eq: params.project.id },
288
251
  'parentOrganization.id': { $exists: true, $eq: params.parentOrganization.id }
@@ -295,7 +258,7 @@ class MovieTheaterRepo {
295
258
  */
296
259
  deleteMovieTheatersByProject(params) {
297
260
  return __awaiter(this, void 0, void 0, function* () {
298
- yield this.placeModel.deleteMany({
261
+ yield this.civicStructureModel.deleteMany({
299
262
  typeOf: { $eq: factory.placeType.MovieTheater },
300
263
  'project.id': { $eq: params.project.id }
301
264
  })
@@ -303,13 +266,25 @@ class MovieTheaterRepo {
303
266
  });
304
267
  }
305
268
  getCursor(conditions, projection) {
306
- return this.placeModel.find(conditions, projection)
269
+ return this.civicStructureModel.find(conditions, projection)
307
270
  .sort({ branchCode: factory.sortType.Ascending })
308
271
  .cursor();
309
272
  }
310
273
  unsetUnnecessaryFields(params) {
311
274
  return __awaiter(this, void 0, void 0, function* () {
312
- return this.placeModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
275
+ return this.civicStructureModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
276
+ .exec();
277
+ });
278
+ }
279
+ /**
280
+ * 旧施設廃止専用メソッド
281
+ * 2024-09-17~
282
+ */
283
+ deleteOldMovieTheaters() {
284
+ return __awaiter(this, void 0, void 0, function* () {
285
+ return this.placeModel.deleteMany({
286
+ typeOf: { $eq: factory.placeType.MovieTheater }
287
+ })
313
288
  .exec();
314
289
  });
315
290
  }
@@ -13,12 +13,17 @@ interface IUpdateScreeningRoomResult {
13
13
  };
14
14
  typeOf: factory.placeType.ScreeningRoom;
15
15
  }
16
+ type IMovieTheaterIncludingScreeningRooms = Pick<factory.place.movieTheater.IPlace, 'name' | 'branchCode' | 'typeOf' | 'project'> & {
17
+ containsPlace: factory.place.screeningRoom.IPlace[];
18
+ };
16
19
  /**
17
20
  * ルームリポジトリ
18
21
  */
19
22
  export declare class ScreeningRoomRepo {
23
+ private readonly civicStructureModel;
20
24
  private readonly placeModel;
21
25
  constructor(connection: Connection);
26
+ saveScreeningRooms4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
22
27
  createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
23
28
  containedInPlace: {
24
29
  branchCode: string;
@@ -8,30 +8,94 @@ 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.ScreeningRoomRepo = void 0;
13
24
  const factory = require("../../factory");
14
25
  const settings_1 = require("../../settings");
26
+ const civicStructure_1 = require("../mongoose/schemas/civicStructure");
15
27
  const place_1 = require("../mongoose/schemas/place");
16
28
  /**
17
29
  * ルームリポジトリ
18
30
  */
19
31
  class ScreeningRoomRepo {
20
32
  constructor(connection) {
33
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
21
34
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
22
35
  }
36
+ saveScreeningRooms4coa(params) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
39
+ const movieTheater = yield this.civicStructureModel.findOne({
40
+ typeOf: { $eq: factory.placeType.MovieTheater },
41
+ 'project.id': { $eq: params.project.id },
42
+ branchCode: { $eq: movieTheater4update.branchCode }
43
+ }, { _id: 0, id: { $toString: '$_id' } })
44
+ .lean()
45
+ .exec();
46
+ if (movieTheater === null) {
47
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
48
+ }
49
+ const creatingScreeningRooms = params.containsPlace.map((place) => {
50
+ return Object.assign(Object.assign({}, place), { containedInPlace: {
51
+ id: movieTheater.id,
52
+ typeOf: movieTheater4update.typeOf,
53
+ branchCode: movieTheater4update.branchCode,
54
+ name: movieTheater4update.name
55
+ }, containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [], project: params.project });
56
+ });
57
+ yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
58
+ const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
59
+ if (typeof branchCode === 'string' && branchCode.length > 0) {
60
+ yield this.placeModel.findOneAndUpdate({
61
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
62
+ 'project.id': { $eq: createScreeningRoom.project.id },
63
+ 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
64
+ branchCode: { $eq: createScreeningRoom.branchCode }
65
+ }, {
66
+ $setOnInsert: {
67
+ typeOf: createScreeningRoom.typeOf,
68
+ project: createScreeningRoom.project,
69
+ branchCode: createScreeningRoom.branchCode
70
+ },
71
+ $set: setFields
72
+ }, {
73
+ upsert: true,
74
+ new: true,
75
+ projection: { _id: 1 }
76
+ })
77
+ .exec();
78
+ }
79
+ })));
80
+ });
81
+ }
23
82
  createScreeningRoom(screeningRoom) {
24
83
  var _a;
25
84
  return __awaiter(this, void 0, void 0, function* () {
26
85
  // 施設存在確認
27
- const movieTheaterDoc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoom.project.id }, branchCode: { $eq: screeningRoom.containedInPlace.branchCode } }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
86
+ const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoom.project.id }, branchCode: { $eq: screeningRoom.containedInPlace.branchCode } }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
28
87
  ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
29
- : undefined), { _id: 1, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
88
+ : undefined), { _id: 0, id: { $toString: '$_id' }, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
89
+ .lean()
30
90
  .exec();
31
91
  if (movieTheaterDoc === null) {
32
92
  throw new factory.errors.NotFound(factory.placeType.MovieTheater);
33
93
  }
34
- const movieTheater = movieTheaterDoc.toObject();
94
+ // const movieTheater = <Pick<
95
+ // factory.place.movieTheater.IPlace,
96
+ // 'id' | 'typeOf' | 'branchCode' | 'name' | 'parentOrganization'
97
+ // >>movieTheaterDoc.toObject();
98
+ const movieTheater = movieTheaterDoc;
35
99
  const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
36
100
  id: movieTheater.id,
37
101
  typeOf: movieTheater.typeOf,
@@ -16,6 +16,7 @@ interface IUpdateSeatResult {
16
16
  * 座席リポジトリ
17
17
  */
18
18
  export declare class SeatRepo {
19
+ private readonly civicStructureModel;
19
20
  private readonly placeModel;
20
21
  constructor(connection: Connection);
21
22
  static CREATE_SEARCH_SEATS_PROJECTION(params: factory.place.seat.IProjection): {