@chevre/domain 23.2.0-alpha.11 → 23.2.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.
@@ -0,0 +1,63 @@
1
+ // tslint:disable:no-console
2
+ // tslint:disable-next-line:no-implicit-dependencies
3
+ import { Parser } from '@json2csv/plainjs';
4
+ import * as mongoose from 'mongoose';
5
+ import { chevre } from '../../../../lib/index';
6
+
7
+ const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
13
+
14
+ const seats = await seatRepo.searchSeats(
15
+ {
16
+ project: { id: { $eq: project.id } },
17
+ containedInPlace: {
18
+ // branchCode: { $eq: 'Default02' },
19
+ branchCode: { $eq: 'Default' },
20
+ containedInPlace: {
21
+ branchCode: { $eq: '10' },
22
+ containedInPlace: { branchCode: { $eq: '118' } }
23
+ }
24
+ }
25
+ }
26
+ );
27
+ console.log(seats);
28
+ console.log(seats.length, 'seats found');
29
+ try {
30
+ const opts = {
31
+ // formatters: {
32
+ // // Define how strings are formatted
33
+ // string: (value) => {
34
+ // // if (value.includes(',') || value.includes('"') || value.includes('\n')) {
35
+ // // return `"${value.replace(/"/g, '""')}"`; // Standard CSV escaping
36
+ // // }
37
+ // // if (value === '') {
38
+ // // return `""`; // Standard CSV escaping
39
+ // // }
40
+
41
+ // return value; // No quotes if safe
42
+ // }
43
+ // }
44
+ };
45
+ const parser = new Parser(opts);
46
+ const csv = parser.parse(seats.map((seat) => {
47
+ // branchCode,seatingType,name.ja,name.en
48
+ return {
49
+ branchCode: seat.branchCode,
50
+ ...(Array.isArray(seat.seatingType) && seat.seatingType.length > 0) ? { seatingType: seat.seatingType[0] } : undefined,
51
+ 'name.ja': (typeof seat.name?.ja === 'string') ? seat.name.ja : '',
52
+ 'name.en': (typeof seat.name?.en === 'string') ? seat.name.en : ''
53
+ };
54
+ }));
55
+ console.log(csv);
56
+ } catch (err) {
57
+ console.error(err);
58
+ }
59
+ }
60
+
61
+ main()
62
+ .then(console.log)
63
+ .catch(console.error);
@@ -24,6 +24,7 @@ const schemaDefinition = {
24
24
  headline: mongoose_1.SchemaTypes.Mixed,
25
25
  location: mongoose_1.SchemaTypes.Mixed,
26
26
  startDate: { type: Date, required: true }, // required(2025-10-08~)
27
+ subEvent: mongoose_1.SchemaTypes.Mixed, // support(2025-12-31~)
27
28
  workPerformed: mongoose_1.SchemaTypes.Mixed,
28
29
  videoFormat: mongoose_1.SchemaTypes.Mixed,
29
30
  soundFormat: mongoose_1.SchemaTypes.Mixed,
@@ -152,6 +152,17 @@ export declare class SeatRepo {
152
152
  };
153
153
  };
154
154
  }): Promise<string[]>;
155
+ /**
156
+ * コードをキーにして冪等削除
157
+ */
158
+ deleteSeatsByBranchCode(params: {
159
+ /**
160
+ * 座席コード
161
+ */
162
+ branchCode: string;
163
+ }[], options: IUpdateOptions): Promise<{
164
+ bulkWriteResult: BulkWriteResult;
165
+ } | void>;
155
166
  deleteSeatByBranchCode(seat: {
156
167
  /**
157
168
  * 座席コード
@@ -680,6 +680,41 @@ class SeatRepo {
680
680
  return (result !== undefined) ? result.seatingTypes : [];
681
681
  });
682
682
  }
683
+ /**
684
+ * コードをキーにして冪等削除
685
+ */
686
+ deleteSeatsByBranchCode(params, options) {
687
+ return __awaiter(this, void 0, void 0, function* () {
688
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
689
+ const bulkWriteOps = [];
690
+ if (Array.isArray(params)) {
691
+ params.forEach(({ branchCode }) => {
692
+ // 座席の存在するドキュメントでフィルター
693
+ const filter = Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: sectionCode }, 'containsPlace.containsPlace.branchCode': { $eq: branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
694
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
695
+ : undefined);
696
+ const updateFilter = {
697
+ $pull: {
698
+ 'containsPlace.$[screeningRoomSection].containsPlace': { branchCode }
699
+ }
700
+ };
701
+ const arrayFilters = [
702
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } }
703
+ ];
704
+ const updateOne = {
705
+ filter,
706
+ update: updateFilter,
707
+ arrayFilters
708
+ };
709
+ bulkWriteOps.push({ updateOne });
710
+ });
711
+ }
712
+ if (bulkWriteOps.length > 0) {
713
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
714
+ return { bulkWriteResult };
715
+ }
716
+ });
717
+ }
683
718
  deleteSeatByBranchCode(seat, options) {
684
719
  return __awaiter(this, void 0, void 0, function* () {
685
720
  const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
@@ -137,7 +137,7 @@ function searchEventTicketOffersByEvent(params) {
137
137
  page: 1,
138
138
  id: { $eq: event.superEvent.id }
139
139
  // typeOf: factory.eventType.ScreeningEventSeries
140
- }, ['soundFormat', 'videoFormat']);
140
+ }, ['soundFormat', 'videoFormat', 'subEvent']);
141
141
  const superEvent = superEvents.shift();
142
142
  if (superEvent === undefined) {
143
143
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -39,7 +39,7 @@ function searchOfferAppliesToMovieTicket(params) {
39
39
  page: 1,
40
40
  id: { $eq: event.superEvent.id }
41
41
  // typeOf: factory.eventType.ScreeningEventSeries
42
- }, ['soundFormat', 'videoFormat']);
42
+ }, ['soundFormat', 'videoFormat', 'subEvent']);
43
43
  const superEvent = superEvents.shift();
44
44
  if (superEvent === undefined) {
45
45
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -120,7 +120,7 @@ function searchEventTicketOffersByEvent(params) {
120
120
  page: 1,
121
121
  id: { $eq: event.superEvent.id }
122
122
  // typeOf: factory.eventType.ScreeningEventSeries
123
- }, ['soundFormat', 'videoFormat']);
123
+ }, ['soundFormat', 'videoFormat', 'subEvent']);
124
124
  const superEvent = superEvents.shift();
125
125
  if (superEvent === undefined) {
126
126
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -167,7 +167,7 @@ function createInformTasks(params, setting) {
167
167
  }, [
168
168
  'project', 'organizer', 'typeOf', 'name', 'location', 'videoFormat', 'soundFormat', 'workPerformed', 'kanaName', 'eventStatus',
169
169
  'endDate', 'startDate', 'additionalProperty', 'subtitleLanguage', 'dubLanguage',
170
- 'alternativeHeadline', 'description', 'duration', 'headline'
170
+ 'alternativeHeadline', 'description', 'duration', 'headline', 'subEvent'
171
171
  ] // inclusion(2024-07-30~)
172
172
  );
173
173
  // 最適化(2024-03-25~)
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.9",
14
+ "@chevre/factory": "5.4.0-alpha.10",
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",
@@ -33,6 +33,7 @@
33
33
  "description": "Chevre Domain Library for Node.js",
34
34
  "devDependencies": {
35
35
  "@eslint/js": "9.16.0",
36
+ "@json2csv/plainjs": "7.0.6",
36
37
  "@sendgrid/helpers": "8.0.0",
37
38
  "@types/debug": "0.0.30",
38
39
  "@types/google-libphonenumber": "^7.4.19",
@@ -115,5 +116,5 @@
115
116
  "postversion": "git push origin --tags",
116
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
118
  },
118
- "version": "23.2.0-alpha.11"
119
+ "version": "23.2.0-alpha.13"
119
120
  }