@chevre/domain 22.3.0-alpha.27 → 22.3.0-alpha.29

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.
@@ -12,26 +12,15 @@ mongoose.Model.on('index', (...args) => {
12
12
  async function main() {
13
13
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
14
 
15
- const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
15
+ const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
16
16
 
17
- let docs = await movieTheaterRepo.projectPublicFields(
18
- {
19
- limit: 1,
20
- page: 1,
21
- project: { id: { $eq: project.id } }
22
- }
23
- );
24
- // tslint:disable-next-line:no-null-keyword
25
- console.dir(docs, { depth: null });
26
- console.log(docs.length, 'docs found');
27
-
28
- docs = await movieTheaterRepo.projectFields(
17
+ const docs = await creativeWorkRepo.projectFields(
29
18
  {
30
19
  limit: 1,
31
20
  page: 1,
32
21
  project: { id: { $eq: project.id } }
33
22
  },
34
- ['branchCode', 'id']
23
+ ['additionalProperty', 'alternativeHeadline', 'contentRating', 'datePublished']
35
24
  );
36
25
  // tslint:disable-next-line:no-null-keyword
37
26
  console.dir(docs, { depth: null });
@@ -23,9 +23,9 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { BulkWriteResult } from 'mongodb';
26
- import { Connection, Document, FilterQuery, Types } from 'mongoose';
26
+ import { Connection, FilterQuery, Types } from 'mongoose';
27
27
  import * as factory from '../factory';
28
- type IKeyOfProjection = keyof factory.creativeWork.movie.ICreativeWork | '_id';
28
+ type IKeyOfProjection = keyof factory.creativeWork.movie.ICreativeWork;
29
29
  /**
30
30
  * コンテンツリポジトリ
31
31
  */
@@ -43,7 +43,9 @@ export declare class CreativeWorkRepo {
43
43
  $unset?: {
44
44
  [key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
45
45
  };
46
- }): Promise<any>;
46
+ }): Promise<{
47
+ id: string;
48
+ }>;
47
49
  /**
48
50
  * コードをキーにして冪等作成
49
51
  */
@@ -60,7 +62,7 @@ export declare class CreativeWorkRepo {
60
62
  /**
61
63
  * コンテンツを検索する
62
64
  */
63
- searchMovies(params: factory.creativeWork.movie.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.creativeWork.movie.ICreativeWork[]>;
65
+ projectFields(params: factory.creativeWork.movie.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.creativeWork.movie.ICreativeWork[]>;
64
66
  /**
65
67
  * コンテンツを削除する
66
68
  */
@@ -72,13 +74,13 @@ export declare class CreativeWorkRepo {
72
74
  id: string;
73
75
  };
74
76
  }): Promise<void>;
75
- getCursor(conditions: FilterQuery<factory.creativeWork.movie.ICreativeWork>, projection: any): import("mongoose").Cursor<Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
77
+ getCursor(conditions: FilterQuery<factory.creativeWork.movie.ICreativeWork>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
76
78
  description?: string | undefined;
77
79
  }> & import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
78
80
  description?: string | undefined;
79
81
  } & {
80
82
  _id: Types.ObjectId;
81
- }, import("mongoose").QueryOptions<Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
83
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
82
84
  description?: string | undefined;
83
85
  }> & import("@chevre/factory/lib/creativeWork/movie").ICreativeWork & {
84
86
  description?: string | undefined;
@@ -22,9 +22,25 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.CreativeWorkRepo = void 0;
24
24
  const mongoose_1 = require("mongoose");
25
- const creativeWork_1 = require("./mongoose/schemas/creativeWork");
26
25
  const factory = require("../factory");
27
26
  const settings_1 = require("../settings");
27
+ const creativeWork_1 = require("./mongoose/schemas/creativeWork");
28
+ const AVAILABLE_PROJECT_FIELDS = [
29
+ 'project',
30
+ 'typeOf',
31
+ 'identifier',
32
+ 'name',
33
+ 'alternativeHeadline',
34
+ // 'description',
35
+ 'datePublished',
36
+ 'distributor',
37
+ 'headline',
38
+ 'thumbnailUrl',
39
+ 'duration',
40
+ 'contentRating',
41
+ 'offers',
42
+ 'additionalProperty'
43
+ ];
28
44
  /**
29
45
  * コンテンツリポジトリ
30
46
  */
@@ -119,21 +135,24 @@ class CreativeWorkRepo {
119
135
  */
120
136
  saveMovie(params) {
121
137
  return __awaiter(this, void 0, void 0, function* () {
138
+ let savedId;
122
139
  let doc;
123
- if (params.id === '') {
140
+ if (typeof params.id !== 'string' || params.id === '') {
124
141
  const { $unset, id } = params, createParams = __rest(params, ["$unset", "id"]); // omit id(2024-09-12~)
125
142
  doc = yield this.creativeWorkModel.create(createParams);
143
+ savedId = doc.id;
126
144
  }
127
145
  else {
128
146
  // 上書き禁止属性を除外
129
147
  const { id, identifier, project, typeOf, $unset } = params, setFields = __rest(params, ["id", "identifier", "project", "typeOf", "$unset"]);
130
- doc = yield this.creativeWorkModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true })
148
+ doc = yield this.creativeWorkModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true, projection: { _id: 1 } })
131
149
  .exec();
150
+ savedId = params.id;
132
151
  }
133
152
  if (doc === null) {
134
153
  throw new factory.errors.NotFound(this.creativeWorkModel.modelName);
135
154
  }
136
- return doc.toObject();
155
+ return { id: savedId };
137
156
  });
138
157
  }
139
158
  /**
@@ -209,28 +228,37 @@ class CreativeWorkRepo {
209
228
  /**
210
229
  * コンテンツを検索する
211
230
  */
212
- searchMovies(params, inclusion, exclusion) {
231
+ projectFields(params, inclusion
232
+ // exclusion: IKeyOfProjection[]
233
+ ) {
213
234
  var _a;
214
235
  return __awaiter(this, void 0, void 0, function* () {
215
236
  const conditions = CreativeWorkRepo.CREATE_MONGO_CONDITIONS(params);
216
- let projection = {};
237
+ // let projection: { [key: string]: number } = {};
238
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
239
+ // inclusion.forEach((field) => {
240
+ // projection[field] = 1;
241
+ // });
242
+ // } else {
243
+ // projection = {
244
+ // __v: 0,
245
+ // createdAt: 0,
246
+ // updatedAt: 0
247
+ // };
248
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
249
+ // exclusion.forEach((field) => {
250
+ // projection[field] = 0;
251
+ // });
252
+ // }
253
+ // }
254
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
217
255
  if (Array.isArray(inclusion) && inclusion.length > 0) {
218
- inclusion.forEach((field) => {
219
- projection[field] = 1;
220
- });
256
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
221
257
  }
222
258
  else {
223
- projection = {
224
- __v: 0,
225
- createdAt: 0,
226
- updatedAt: 0
227
- };
228
- if (Array.isArray(exclusion) && exclusion.length > 0) {
229
- exclusion.forEach((field) => {
230
- projection[field] = 0;
231
- });
232
- }
259
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
233
260
  }
261
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
234
262
  const query = this.creativeWorkModel.find({ $and: conditions }, projection);
235
263
  if (typeof params.limit === 'number' && params.limit > 0) {
236
264
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
@@ -243,8 +271,8 @@ class CreativeWorkRepo {
243
271
  query.sort({ identifier: params.sort.identifier });
244
272
  }
245
273
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
246
- .exec()
247
- .then((docs) => docs.map((doc) => doc.toObject()));
274
+ .lean() // 2024-09-19~
275
+ .exec();
248
276
  });
249
277
  }
250
278
  /**
@@ -252,7 +280,7 @@ class CreativeWorkRepo {
252
280
  */
253
281
  deleteMovie(params) {
254
282
  return __awaiter(this, void 0, void 0, function* () {
255
- yield this.creativeWorkModel.findOneAndRemove({ _id: { $eq: params.id } })
283
+ yield this.creativeWorkModel.findOneAndRemove({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
256
284
  .exec();
257
285
  });
258
286
  }
@@ -1,13 +1,7 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocType = ((factory.place.movieTheater.IPlace & {
3
+ export type IDocType = Omit<factory.place.movieTheater.IPlace, 'id'> & {
4
4
  hasPOS?: factory.place.movieTheater.IPOS[];
5
- }) | factory.place.screeningRoom.IPlace) & {
6
- alternateName?: any;
7
- description?: any;
8
- openingHoursSpecification?: any;
9
- smokingAllowed?: boolean;
10
- sameAs?: any;
11
5
  };
12
6
  type IModel = Model<IDocType>;
13
7
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -1,13 +1,9 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocType = ((factory.place.movieTheater.IPlace & {
4
- hasPOS?: factory.place.movieTheater.IPOS[];
5
- }) | factory.place.screeningRoom.IPlace) & {
6
- alternateName?: any;
3
+ type IDocType = factory.place.screeningRoom.IPlace & {
7
4
  description?: any;
8
5
  openingHoursSpecification?: any;
9
6
  smokingAllowed?: boolean;
10
- sameAs?: any;
11
7
  };
12
8
  type IModel = Model<IDocType>;
13
9
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -21,29 +21,27 @@ const schemaDefinition = {
21
21
  required: true
22
22
  },
23
23
  name: mongoose_1.SchemaTypes.Mixed,
24
- alternateName: mongoose_1.SchemaTypes.Mixed,
25
24
  description: mongoose_1.SchemaTypes.Mixed,
26
25
  address: mongoose_1.SchemaTypes.Mixed,
27
26
  branchCode: String,
28
27
  containedInPlace: mongoose_1.SchemaTypes.Mixed,
29
28
  containsPlace: [mongoose_1.SchemaTypes.Mixed],
30
- hasEntranceGate: [mongoose_1.SchemaTypes.Mixed],
31
- hasPOS: [mongoose_1.SchemaTypes.Mixed],
32
29
  maximumAttendeeCapacity: Number,
33
30
  openingHoursSpecification: mongoose_1.SchemaTypes.Mixed,
34
31
  smokingAllowed: Boolean,
35
- telephone: String,
36
- sameAs: String,
37
- url: String,
38
- kanaName: String,
39
- offers: mongoose_1.SchemaTypes.Mixed,
40
32
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
41
33
  // ↓ルームの施設からの分離に伴い属性追加(2023-06-22~)
42
34
  openSeatingAllowed: mongoose_1.SchemaTypes.Mixed,
43
35
  amenityFeature: mongoose_1.SchemaTypes.Mixed
44
- // createdAt: SchemaTypes.Mixed,
45
- // updatedAt: SchemaTypes.Mixed,
46
- // __v: SchemaTypes.Mixed
36
+ // ↓migrated to civicStructures(2024-09-19~)
37
+ // alternateName: SchemaTypes.Mixed,
38
+ // hasEntranceGate: [SchemaTypes.Mixed],
39
+ // hasPOS: [SchemaTypes.Mixed],
40
+ // sameAs: String,
41
+ // telephone: String,
42
+ // url: String,
43
+ // kanaName: String,
44
+ // offers: SchemaTypes.Mixed,
47
45
  };
48
46
  const schemaOptions = {
49
47
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -80,9 +78,7 @@ const indexes = [
80
78
  ],
81
79
  [
82
80
  { 'project.id': 1, branchCode: 1 },
83
- {
84
- name: 'searchByProjectId-v20220721'
85
- }
81
+ { name: 'searchByProjectId-v20220721' }
86
82
  ],
87
83
  [
88
84
  { 'name.ja': 1, branchCode: 1 },
@@ -102,15 +98,15 @@ const indexes = [
102
98
  }
103
99
  }
104
100
  ],
105
- [
106
- { kanaName: 1, branchCode: 1 },
107
- {
108
- name: 'searchByKanaName-v2',
109
- partialFilterExpression: {
110
- kanaName: { $exists: true }
111
- }
112
- }
113
- ],
101
+ // [
102
+ // { kanaName: 1, branchCode: 1 },
103
+ // {
104
+ // name: 'searchByKanaName-v2',
105
+ // partialFilterExpression: {
106
+ // kanaName: { $exists: true }
107
+ // }
108
+ // }
109
+ // ],
114
110
  [
115
111
  { 'parentOrganization.id': 1, branchCode: 1 },
116
112
  {
@@ -138,15 +134,15 @@ const indexes = [
138
134
  }
139
135
  }
140
136
  ],
141
- [
142
- { 'containsPlace.containsPlace.containsPlace.branchCode': 1, branchCode: 1 },
143
- {
144
- name: 'searchByContainsPlaceContainsPlaceContainsPlaceBranchCode',
145
- partialFilterExpression: {
146
- 'containsPlace.containsPlace.containsPlace.branchCode': { $exists: true }
147
- }
148
- }
149
- ],
137
+ // [
138
+ // { 'containsPlace.containsPlace.containsPlace.branchCode': 1, branchCode: 1 },
139
+ // {
140
+ // name: 'searchByContainsPlaceContainsPlaceContainsPlaceBranchCode',
141
+ // partialFilterExpression: {
142
+ // 'containsPlace.containsPlace.containsPlace.branchCode': { $exists: true }
143
+ // }
144
+ // }
145
+ // ],
150
146
  [
151
147
  { additionalProperty: 1, branchCode: 1 },
152
148
  {
@@ -174,15 +170,15 @@ const indexes = [
174
170
  }
175
171
  }
176
172
  ],
177
- [
178
- { 'containsPlace.containsPlace.containsPlace.additionalProperty': 1, branchCode: 1 },
179
- {
180
- name: 'searchByContainsPlaceContainsPlaceContainsPlaceAdditionalProperty',
181
- partialFilterExpression: {
182
- 'containsPlace.containsPlace.containsPlace.additionalProperty': { $exists: true }
183
- }
184
- }
185
- ],
173
+ // [
174
+ // { 'containsPlace.containsPlace.containsPlace.additionalProperty': 1, branchCode: 1 },
175
+ // {
176
+ // name: 'searchByContainsPlaceContainsPlaceContainsPlaceAdditionalProperty',
177
+ // partialFilterExpression: {
178
+ // 'containsPlace.containsPlace.containsPlace.additionalProperty': { $exists: true }
179
+ // }
180
+ // }
181
+ // ],
186
182
  [
187
183
  { 'containedInPlace.id': 1, branchCode: 1 },
188
184
  {
@@ -204,7 +200,7 @@ const indexes = [
204
200
  ];
205
201
  exports.indexes = indexes;
206
202
  /**
207
- * 施設スキーマ
203
+ * ルームスキーマ
208
204
  */
209
205
  let schema;
210
206
  function createSchema() {
@@ -24,18 +24,12 @@ exports.BusStopRepo = void 0;
24
24
  const factory = require("../../factory");
25
25
  const settings_1 = require("../../settings");
26
26
  const civicStructure_1 = require("../mongoose/schemas/civicStructure");
27
- const place_1 = require("../mongoose/schemas/place");
28
27
  /**
29
28
  * ターミナルリポジトリ
30
29
  */
31
30
  class BusStopRepo {
32
31
  constructor(connection) {
33
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
34
- this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
35
- }
36
- else {
37
- this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
38
- }
32
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
39
33
  }
40
34
  // tslint:disable-next-line:max-func-body-length
41
35
  static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
@@ -11,21 +11,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.HasPOSRepo = void 0;
13
13
  const mongoose_1 = require("mongoose");
14
- const civicStructure_1 = require("../mongoose/schemas/civicStructure");
15
- const place_1 = require("../mongoose/schemas/place");
16
14
  const factory = require("../../factory");
17
15
  const settings_1 = require("../../settings");
16
+ const civicStructure_1 = require("../mongoose/schemas/civicStructure");
18
17
  /**
19
18
  * 施設のPOSリポジトリ
20
19
  */
21
20
  class HasPOSRepo {
22
21
  constructor(connection, operater) {
23
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
24
- this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
25
- }
26
- else {
27
- this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
28
- }
22
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
29
23
  this.operator = operater;
30
24
  }
31
25
  search(params) {
@@ -22,8 +22,9 @@
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
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[];
@@ -34,14 +35,15 @@ type IKeyOfProjection = keyof factory.place.movieTheater.IPlace;
34
35
  */
35
36
  export declare class MovieTheaterRepo {
36
37
  private readonly civicStructureModel;
37
- private readonly civicStructureModelAsSecondary;
38
38
  private readonly placeModel;
39
39
  constructor(connection: Connection);
40
40
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/movieTheater").IPlace>[];
41
41
  /**
42
42
  * 施設を保管する
43
43
  */
44
- saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<factory.place.movieTheater.IPlace>;
44
+ saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<{
45
+ id: string;
46
+ }>;
45
47
  saveMovieTheaterByBranchCode4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
46
48
  /**
47
49
  * 施設のpublic属性検索
@@ -81,59 +83,15 @@ export declare class MovieTheaterRepo {
81
83
  id: string;
82
84
  };
83
85
  }): Promise<void>;
84
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, ((import("@chevre/factory/lib/place/movieTheater").IPlace & {
85
- hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
86
- }) | import("@chevre/factory/lib/place/screeningRoom").IPlace) & {
87
- alternateName?: any;
88
- description?: any;
89
- openingHoursSpecification?: any;
90
- smokingAllowed?: boolean | undefined;
91
- sameAs?: any;
92
- }> & ((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"> & {
93
87
  hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
94
- } & {
95
- alternateName?: any;
96
- description?: any;
97
- openingHoursSpecification?: any;
98
- smokingAllowed?: boolean | undefined;
99
- sameAs?: any;
100
- } & {
101
- _id: import("mongoose").Types.ObjectId;
102
- }) | (import("@chevre/factory/lib/place/screeningRoom").IPlace & {
103
- alternateName?: any;
104
- description?: any;
105
- openingHoursSpecification?: any;
106
- smokingAllowed?: boolean | undefined;
107
- sameAs?: any;
108
88
  } & {
109
89
  _id: import("mongoose").Types.ObjectId;
110
- })), 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"> & {
111
91
  hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
112
- }) | import("@chevre/factory/lib/place/screeningRoom").IPlace) & {
113
- alternateName?: any;
114
- description?: any;
115
- openingHoursSpecification?: any;
116
- smokingAllowed?: boolean | undefined;
117
- sameAs?: any;
118
- }> & ((import("@chevre/factory/lib/place/movieTheater").IPlace & {
119
- hasPOS?: import("@chevre/factory/lib/place/movieTheater").IPOS[] | undefined;
120
- } & {
121
- alternateName?: any;
122
- description?: any;
123
- openingHoursSpecification?: any;
124
- smokingAllowed?: boolean | undefined;
125
- sameAs?: any;
126
- } & {
127
- _id: import("mongoose").Types.ObjectId;
128
- }) | (import("@chevre/factory/lib/place/screeningRoom").IPlace & {
129
- alternateName?: any;
130
- description?: any;
131
- openingHoursSpecification?: any;
132
- smokingAllowed?: boolean | undefined;
133
- sameAs?: any;
134
92
  } & {
135
93
  _id: import("mongoose").Types.ObjectId;
136
- }))>>;
94
+ }>>;
137
95
  unsetUnnecessaryFields(params: {
138
96
  filter: any;
139
97
  $unset: any;
@@ -143,7 +101,7 @@ export declare class MovieTheaterRepo {
143
101
  * 2024-09-17~
144
102
  */
145
103
  deleteOldMovieTheaters(): Promise<import("mongodb").DeleteResult>;
146
- sync2secondary(params: {
104
+ sync2secondary(__: {
147
105
  id: string;
148
106
  }): Promise<void>;
149
107
  }
@@ -34,13 +34,8 @@ const AVAILABLE_PROJECT_FIELDS = [
34
34
  */
35
35
  class MovieTheaterRepo {
36
36
  constructor(connection) {
37
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
38
- this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
39
- }
40
- else {
41
- this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
42
- }
43
- this.civicStructureModelAsSecondary = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
37
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
38
+ // this.civicStructureModelAsSecondary = connection.model(civicStructureModelName, createCivicStructureSchema());
44
39
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
45
40
  }
46
41
  // tslint:disable-next-line:max-func-body-length
@@ -54,84 +49,35 @@ class MovieTheaterRepo {
54
49
  }
55
50
  const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
56
51
  if (typeof branchCodeEq === 'string') {
57
- andConditions.push({
58
- branchCode: {
59
- $exists: true,
60
- $eq: branchCodeEq
61
- }
62
- });
52
+ andConditions.push({ branchCode: { $eq: branchCodeEq } });
63
53
  }
64
54
  const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
65
55
  if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
66
- andConditions.push({
67
- branchCode: {
68
- $exists: true,
69
- $regex: new RegExp(branchCodeRegex)
70
- }
71
- });
56
+ andConditions.push({ branchCode: { $regex: new RegExp(branchCodeRegex) } });
72
57
  }
73
- // tslint:disable-next-line:no-single-line-block-comment
74
- /* istanbul ignore else */
75
58
  if (Array.isArray(params.branchCodes)) {
76
- andConditions.push({
77
- branchCode: {
78
- $exists: true,
79
- $in: params.branchCodes
80
- }
81
- });
59
+ andConditions.push({ branchCode: { $in: params.branchCodes } });
82
60
  }
83
- // tslint:disable-next-line:no-single-line-block-comment
84
- /* istanbul ignore else */
85
61
  const idEq = (_e = params.id) === null || _e === void 0 ? void 0 : _e.$eq;
86
62
  if (typeof idEq === 'string') {
87
- andConditions.push({
88
- _id: {
89
- $eq: idEq
90
- }
91
- });
63
+ andConditions.push({ _id: { $eq: idEq } });
92
64
  }
93
65
  const idIn = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$in;
94
66
  if (Array.isArray(idIn)) {
95
- andConditions.push({
96
- _id: {
97
- $in: idIn
98
- }
99
- });
67
+ andConditions.push({ _id: { $in: idIn } });
100
68
  }
101
- // tslint:disable-next-line:no-single-line-block-comment
102
- /* istanbul ignore else */
103
69
  if (typeof params.name === 'string' && params.name.length > 0) {
104
70
  andConditions.push({
105
71
  $or: [
106
- {
107
- 'name.ja': {
108
- $exists: true,
109
- $regex: new RegExp(params.name)
110
- }
111
- },
112
- {
113
- 'name.en': {
114
- $exists: true,
115
- $regex: new RegExp(params.name)
116
- }
117
- },
118
- {
119
- kanaName: {
120
- $exists: true,
121
- $regex: new RegExp(params.name)
122
- }
123
- }
72
+ { 'name.ja': { $exists: true, $regex: new RegExp(params.name) } },
73
+ { 'name.en': { $exists: true, $regex: new RegExp(params.name) } },
74
+ { kanaName: { $exists: true, $regex: new RegExp(params.name) } }
124
75
  ]
125
76
  });
126
77
  }
127
78
  const parentOrganizationIdEq = (_h = (_g = params.parentOrganization) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
128
79
  if (typeof parentOrganizationIdEq === 'string') {
129
- andConditions.push({
130
- 'parentOrganization.id': {
131
- $exists: true,
132
- $eq: parentOrganizationIdEq
133
- }
134
- });
80
+ andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } });
135
81
  }
136
82
  const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
137
83
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
@@ -149,30 +95,24 @@ class MovieTheaterRepo {
149
95
  */
150
96
  saveMovieTheater(params) {
151
97
  return __awaiter(this, void 0, void 0, function* () {
98
+ let savedId;
152
99
  let doc;
153
100
  if (params.id === '') {
154
101
  const { id } = params, creatingParams = __rest(params, ["id"]); // omit id(2024-09-12~)
155
102
  doc = yield this.civicStructureModel.create(creatingParams);
103
+ savedId = doc.id;
156
104
  }
157
105
  else {
158
106
  // 上書き禁止属性を除外(2022-08-24~)
159
107
  const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
160
- doc = yield this.civicStructureModel.findOneAndUpdate({ _id: params.id }, updateFields, {
161
- upsert: false,
162
- new: true,
163
- projection: {
164
- __v: 0,
165
- createdAt: 0,
166
- updatedAt: 0,
167
- containsPlace: 0
168
- }
169
- })
108
+ doc = yield this.civicStructureModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true, projection: { _id: 1 } })
170
109
  .exec();
110
+ savedId = params.id;
171
111
  }
172
112
  if (doc === null) {
173
113
  throw new factory.errors.NotFound(this.civicStructureModel.modelName);
174
114
  }
175
- return doc.toObject();
115
+ return { id: savedId };
176
116
  });
177
117
  }
178
118
  saveMovieTheaterByBranchCode4coa(params) {
@@ -351,31 +291,35 @@ class MovieTheaterRepo {
351
291
  });
352
292
  }
353
293
  // tslint:disable-next-line:prefer-function-over-method
354
- sync2secondary(params) {
294
+ sync2secondary(__) {
355
295
  return __awaiter(this, void 0, void 0, function* () {
356
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
357
- return;
358
- }
359
- const doc = yield this.placeModel.findOne({
360
- _id: { $eq: params.id },
361
- typeOf: { $eq: factory.placeType.MovieTheater }
362
- })
363
- .lean()
364
- .exec();
365
- if (doc !== null) {
366
- const { _id } = doc, replacement = __rest(doc, ["_id"]);
367
- // console.log('replacing eventSeries', params.id, 'replacement:', replacement);
368
- const replaceResult = yield this.civicStructureModelAsSecondary.findOneAndReplace({
369
- _id: { $eq: params.id },
370
- typeOf: { $eq: factory.placeType.MovieTheater }
371
- }, replacement, {
372
- upsert: true,
373
- rawResult: true
374
- })
375
- .exec();
376
- // tslint:disable-next-line:no-console
377
- console.log('factory.placeType.MovieTheater', params.id, 'replaced. result:', replaceResult);
378
- }
296
+ // if (USE_CIVIC_STRUCTURE_SCHEMA) {
297
+ // return;
298
+ // }
299
+ // const doc = await this.placeModel.findOne({
300
+ // _id: { $eq: params.id },
301
+ // typeOf: { $eq: factory.placeType.MovieTheater }
302
+ // })
303
+ // .lean()
304
+ // .exec();
305
+ // if (doc !== null) {
306
+ // const { _id, ...replacement } = doc;
307
+ // // console.log('replacing eventSeries', params.id, 'replacement:', replacement);
308
+ // const replaceResult = await this.civicStructureModelAsSecondary.findOneAndReplace(
309
+ // {
310
+ // _id: { $eq: params.id },
311
+ // typeOf: { $eq: factory.placeType.MovieTheater }
312
+ // },
313
+ // replacement,
314
+ // {
315
+ // upsert: true,
316
+ // rawResult: true
317
+ // }
318
+ // )
319
+ // .exec();
320
+ // // tslint:disable-next-line:no-console
321
+ // console.log('factory.placeType.MovieTheater', params.id, 'replaced. result:', replaceResult);
322
+ // }
379
323
  });
380
324
  }
381
325
  }
@@ -30,12 +30,7 @@ const place_1 = require("../mongoose/schemas/place");
30
30
  */
31
31
  class ScreeningRoomRepo {
32
32
  constructor(connection) {
33
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
34
- this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
35
- }
36
- else {
37
- this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
38
- }
33
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
39
34
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
40
35
  }
41
36
  saveScreeningRooms4coa(params) {
@@ -19,12 +19,7 @@ const place_1 = require("../mongoose/schemas/place");
19
19
  */
20
20
  class SeatRepo {
21
21
  constructor(connection) {
22
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
23
- this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
24
- }
25
- else {
26
- this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
27
- }
22
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
28
23
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
29
24
  }
30
25
  static CREATE_SEARCH_SEATS_PROJECTION(params) {
@@ -19,12 +19,7 @@ const place_1 = require("../mongoose/schemas/place");
19
19
  */
20
20
  class SectionRepo {
21
21
  constructor(connection) {
22
- if (settings_1.USE_CIVIC_STRUCTURE_SCHEMA) {
23
- this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
24
- }
25
- else {
26
- this.civicStructureModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
27
- }
22
+ this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
28
23
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
29
24
  }
30
25
  // tslint:disable-next-line:max-func-body-length
@@ -241,10 +241,10 @@ function createInformNoteTasks(params) {
241
241
  }
242
242
  function createInformMovieTasks(params) {
243
243
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
244
- const movies4inform = yield repos.creativeWork.searchMovies({ id: { $in: params.ids } }, [
244
+ const movies4inform = yield repos.creativeWork.projectFields({ id: { $in: params.ids } }, [
245
245
  'additionalProperty', 'datePublished', 'duration', 'identifier', 'name', 'project',
246
246
  'typeOf', 'distributor', 'contentRating', 'headline', 'thumbnailUrl'
247
- ], []);
247
+ ]);
248
248
  const informResources = settings.onResourceUpdated.informResource;
249
249
  if (movies4inform.length > 0) {
250
250
  const taskRunsAt = new Date();
@@ -2,10 +2,6 @@ import * as factory from './factory';
2
2
  export declare const MONGO_MAX_TIME_MS: number;
3
3
  export declare const MONGO_READ_PREFERENCE: string;
4
4
  export declare const MONGO_AUTO_INDEX: boolean;
5
- /**
6
- * 施設のprimaryコレクションとして新スキーマを使用するかどうか
7
- */
8
- export declare const USE_CIVIC_STRUCTURE_SCHEMA: boolean;
9
5
  interface IOptions {
10
6
  onOrderStatusChanged: factory.project.IOnOrderStatusChanged;
11
7
  onEventChanged: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Settings = exports.USE_CIVIC_STRUCTURE_SCHEMA = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
3
+ exports.Settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
4
4
  exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
5
5
  ? Number(process.env.MONGO_MAX_TIME_MS)
6
6
  // tslint:disable-next-line:no-magic-numbers
@@ -9,10 +9,6 @@ exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 's
9
9
  ? process.env.MONGO_READ_PREFERENCE
10
10
  : 'primaryPreferred';
11
11
  exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
12
- /**
13
- * 施設のprimaryコレクションとして新スキーマを使用するかどうか
14
- */
15
- exports.USE_CIVIC_STRUCTURE_SCHEMA = process.env.USE_CIVIC_STRUCTURE_SCHEMA === '1';
16
12
  /**
17
13
  * domain settings
18
14
  */
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.3.0-alpha.27"
113
+ "version": "22.3.0-alpha.29"
114
114
  }