@chevre/domain 20.1.0-alpha.21 → 20.1.0-alpha.23

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,89 @@
1
+ // tslint:disable:no-console
2
+ // import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const project = { id: String(process.env.PROJECT_ID) };
8
+ const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
9
+
10
+ // tslint:disable-next-line:max-func-body-length
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
+
14
+ const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
15
+ // const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
16
+
17
+ const cursor = creativeWorkRepo.getCursor(
18
+ {
19
+ // 'project.id': { $eq: project.id },
20
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID }
21
+ // _id: { $eq: 'al6aff83w' }
22
+ },
23
+ {
24
+ // _id: 1,
25
+ }
26
+ );
27
+ console.log('creativeWorks found');
28
+
29
+ const additionalPropertyNames: string[] = [];
30
+ const projectIds: string[] = [];
31
+
32
+ let i = 0;
33
+ let updateCount = 0;
34
+ await cursor.eachAsync(async (doc) => {
35
+ i += 1;
36
+ const creativeWork: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
37
+
38
+ const additionalPropertyNamesOnEvent = creativeWork.additionalProperty?.map((p) => p.name);
39
+ if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
40
+ console.log(additionalPropertyNamesOnEvent.length, 'additionalPropertyNamesOnEvent found', creativeWork.project.id);
41
+ additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
42
+ projectIds.push(creativeWork.project.id);
43
+ additionalPropertyNamesOnEvent.forEach((name) => {
44
+ if (!name.match(/^[a-zA-Z]*$/)) {
45
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
46
+ }
47
+ // tslint:disable-next-line:no-magic-numbers
48
+ if (name.length < 5) {
49
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
50
+ }
51
+ });
52
+
53
+ // for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
54
+ // const existings = await additionalPropertyRepo.search({
55
+ // project: { id: { $eq: event.project.id } },
56
+ // limit: 1,
57
+ // page: 1,
58
+ // name: { $regex: `^${additionalPropertyNameOnEvent}$` }
59
+ // });
60
+ // if (existings.length > 0) {
61
+ // console.log('already existed', additionalPropertyNameOnEvent, event.id, event.project.id);
62
+ // } else {
63
+ // updateCount += 1;
64
+ // await additionalPropertyRepo.save({
65
+ // attributes: {
66
+ // project: event.project,
67
+ // typeOf: 'CategoryCode',
68
+ // codeValue: additionalPropertyNameOnEvent,
69
+ // inCodeSet: {
70
+ // typeOf: 'CategoryCodeSet',
71
+ // identifier: <any>event.typeOf
72
+ // },
73
+ // name: { ja: additionalPropertyNameOnEvent }
74
+ // }
75
+ // });
76
+ // console.log('created', additionalPropertyNameOnEvent, event.id, event.project.id);
77
+ // }
78
+ // }
79
+ }
80
+ });
81
+ console.log(i, 'events checked');
82
+ console.log(updateCount, 'events updated');
83
+ console.log([...new Set(additionalPropertyNames)]);
84
+ console.log([...new Set(projectIds)]);
85
+ }
86
+
87
+ main()
88
+ .then()
89
+ .catch(console.error);
@@ -6,18 +6,18 @@ import * as factory from '../factory';
6
6
  export declare class MongoRepository {
7
7
  private readonly additionalPropertyModel;
8
8
  constructor(connection: Connection);
9
- static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): any[];
9
+ static CREATE_MONGO_CONDITIONS(params: factory.additionalProperty.ISearchConditions): any[];
10
10
  /**
11
11
  * 検索
12
12
  */
13
- search(params: factory.categoryCode.ISearchConditions): Promise<factory.categoryCode.ICategoryCode[]>;
13
+ search(params: factory.additionalProperty.ISearchConditions): Promise<factory.additionalProperty.IAdditionalProperty[]>;
14
14
  findById(params: {
15
15
  id: string;
16
- }): Promise<factory.categoryCode.ICategoryCode>;
16
+ }): Promise<factory.additionalProperty.IAdditionalProperty>;
17
17
  save(params: {
18
18
  id?: string;
19
- attributes: factory.categoryCode.ICategoryCode;
20
- }): Promise<factory.categoryCode.ICategoryCode>;
19
+ attributes: factory.additionalProperty.IAdditionalProperty;
20
+ }): Promise<factory.additionalProperty.IAdditionalProperty>;
21
21
  /**
22
22
  * 削除する
23
23
  */
@@ -124,12 +124,6 @@ class MongoRepository {
124
124
  }
125
125
  return andConditions;
126
126
  }
127
- // public async count(params: factory.categoryCode.ISearchConditions): Promise<number> {
128
- // const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
129
- // return this.additionalPropertyModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
130
- // .setOptions({ maxTimeMS: 10000 })
131
- // .exec();
132
- // }
133
127
  /**
134
128
  * 検索
135
129
  */
@@ -34,7 +34,7 @@ class MongoRepository {
34
34
  }
35
35
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
36
36
  static CREATE_MONGO_CONDITIONS(conditions) {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
37
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
38
38
  const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
39
39
  const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
40
40
  if (typeof projectIdEq === 'string') {
@@ -119,6 +119,15 @@ class MongoRepository {
119
119
  }
120
120
  });
121
121
  }
122
+ const additionalPropertyElemMatch = (_h = conditions.additionalProperty) === null || _h === void 0 ? void 0 : _h.$elemMatch;
123
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
124
+ andConditions.push({
125
+ additionalProperty: {
126
+ $exists: true,
127
+ $elemMatch: additionalPropertyElemMatch
128
+ }
129
+ });
130
+ }
122
131
  let params;
123
132
  switch (conditions.typeOf) {
124
133
  case factory.eventType.ScreeningEvent:
@@ -145,7 +154,7 @@ class MongoRepository {
145
154
  }
146
155
  // tslint:disable-next-line:no-single-line-block-comment
147
156
  /* istanbul ignore else */
148
- const superEventLocationIdEq = (_k = (_j = (_h = params.superEvent) === null || _h === void 0 ? void 0 : _h.location) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
157
+ const superEventLocationIdEq = (_l = (_k = (_j = params.superEvent) === null || _j === void 0 ? void 0 : _j.location) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
149
158
  if (typeof superEventLocationIdEq === 'string') {
150
159
  andConditions.push({
151
160
  'superEvent.location.id': {
@@ -233,7 +242,7 @@ class MongoRepository {
233
242
  });
234
243
  }
235
244
  }
236
- const itemOfferedIdIn = (_m = (_l = params.offers.itemOffered) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$in;
245
+ const itemOfferedIdIn = (_o = (_m = params.offers.itemOffered) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$in;
237
246
  if (Array.isArray(itemOfferedIdIn)) {
238
247
  andConditions.push({
239
248
  'offers.itemOffered.id': {
@@ -283,8 +292,8 @@ class MongoRepository {
283
292
  }
284
293
  }
285
294
  }
286
- const sellerMakesOfferElemMatch = (_q = (_p = (_o = params.offers) === null || _o === void 0 ? void 0 : _o.seller) === null || _p === void 0 ? void 0 : _p.makesOffer) === null || _q === void 0 ? void 0 : _q.$elemMatch;
287
- if (typeof ((_r = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _r === void 0 ? void 0 : _r.$eq) === 'string') {
295
+ const sellerMakesOfferElemMatch = (_r = (_q = (_p = params.offers) === null || _p === void 0 ? void 0 : _p.seller) === null || _q === void 0 ? void 0 : _q.makesOffer) === null || _r === void 0 ? void 0 : _r.$elemMatch;
296
+ if (typeof ((_s = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _s === void 0 ? void 0 : _s.$eq) === 'string') {
288
297
  andConditions.push({
289
298
  'offers.seller.makesOffer': {
290
299
  $exists: true,
@@ -321,7 +330,7 @@ class MongoRepository {
321
330
  ]
322
331
  });
323
332
  }
324
- const locationIdEq = (_t = (_s = params.location) === null || _s === void 0 ? void 0 : _s.id) === null || _t === void 0 ? void 0 : _t.$eq;
333
+ const locationIdEq = (_u = (_t = params.location) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
325
334
  // tslint:disable-next-line:no-single-line-block-comment
326
335
  /* istanbul ignore else */
327
336
  if (typeof locationIdEq === 'string') {
@@ -343,7 +352,7 @@ class MongoRepository {
343
352
  });
344
353
  }
345
354
  }
346
- const workPerformedIdentifierIn = (_u = params.workPerformed) === null || _u === void 0 ? void 0 : _u.identifiers;
355
+ const workPerformedIdentifierIn = (_v = params.workPerformed) === null || _v === void 0 ? void 0 : _v.identifiers;
347
356
  // tslint:disable-next-line:no-single-line-block-comment
348
357
  /* istanbul ignore else */
349
358
  if (Array.isArray(workPerformedIdentifierIn)) {
@@ -354,7 +363,7 @@ class MongoRepository {
354
363
  }
355
364
  });
356
365
  }
357
- const videoFormatTypeOfEq = (_w = (_v = params.videoFormat) === null || _v === void 0 ? void 0 : _v.typeOf) === null || _w === void 0 ? void 0 : _w.$eq;
366
+ const videoFormatTypeOfEq = (_x = (_w = params.videoFormat) === null || _w === void 0 ? void 0 : _w.typeOf) === null || _x === void 0 ? void 0 : _x.$eq;
358
367
  if (typeof videoFormatTypeOfEq === 'string') {
359
368
  andConditions.push({
360
369
  'videoFormat.typeOf': {
@@ -363,7 +372,7 @@ class MongoRepository {
363
372
  }
364
373
  });
365
374
  }
366
- const videoFormatTypeOfIn = (_y = (_x = params.videoFormat) === null || _x === void 0 ? void 0 : _x.typeOf) === null || _y === void 0 ? void 0 : _y.$in;
375
+ const videoFormatTypeOfIn = (_z = (_y = params.videoFormat) === null || _y === void 0 ? void 0 : _y.typeOf) === null || _z === void 0 ? void 0 : _z.$in;
367
376
  if (Array.isArray(videoFormatTypeOfIn)) {
368
377
  andConditions.push({
369
378
  'videoFormat.typeOf': {
@@ -372,7 +381,7 @@ class MongoRepository {
372
381
  }
373
382
  });
374
383
  }
375
- const soundFormatTypeOfEq = (_0 = (_z = params.soundFormat) === null || _z === void 0 ? void 0 : _z.typeOf) === null || _0 === void 0 ? void 0 : _0.$eq;
384
+ const soundFormatTypeOfEq = (_1 = (_0 = params.soundFormat) === null || _0 === void 0 ? void 0 : _0.typeOf) === null || _1 === void 0 ? void 0 : _1.$eq;
376
385
  if (typeof soundFormatTypeOfEq === 'string') {
377
386
  andConditions.push({
378
387
  'soundFormat.typeOf': {
@@ -381,7 +390,7 @@ class MongoRepository {
381
390
  }
382
391
  });
383
392
  }
384
- const soundFormatTypeOfIn = (_2 = (_1 = params.soundFormat) === null || _1 === void 0 ? void 0 : _1.typeOf) === null || _2 === void 0 ? void 0 : _2.$in;
393
+ const soundFormatTypeOfIn = (_3 = (_2 = params.soundFormat) === null || _2 === void 0 ? void 0 : _2.typeOf) === null || _3 === void 0 ? void 0 : _3.$in;
385
394
  if (Array.isArray(soundFormatTypeOfIn)) {
386
395
  andConditions.push({
387
396
  'soundFormat.typeOf': {
package/package.json CHANGED
@@ -9,12 +9,12 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.279.0-alpha.1",
12
+ "@chevre/factory": "4.279.0-alpha.2",
13
13
  "@cinerino/sdk": "3.133.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
17
- "@surfrock/sdk": "1.1.0",
17
+ "@surfrock/sdk": "1.2.0-alpha.0",
18
18
  "@waiter/domain": "5.1.0",
19
19
  "JSONStream": "^1.3.5",
20
20
  "aws-sdk": "^2.984.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.1.0-alpha.21"
123
+ "version": "20.1.0-alpha.23"
124
124
  }