@chevre/domain 21.15.0-alpha.0 → 21.15.0-alpha.2

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.
@@ -14,14 +14,18 @@ async function main() {
14
14
 
15
15
  const now = new Date();
16
16
 
17
- const events = await eventRepo.search<chevre.factory.eventType.ScreeningEvent>({
18
- typeOf: chevre.factory.eventType.ScreeningEvent,
19
- project: { id: { $eq: project.id } },
20
- startFrom: now
21
- // startFrom: moment().add(-1, 'day').toDate(),
22
- // startThrough: moment().add(1, 'day').toDate(),
23
- // startThrough: now
24
- });
17
+ const events = await eventRepo.search<chevre.factory.eventType.ScreeningEvent>(
18
+ {
19
+ typeOf: chevre.factory.eventType.ScreeningEvent,
20
+ project: { id: { $eq: project.id } },
21
+ startFrom: now
22
+ // startFrom: moment().add(-1, 'day').toDate(),
23
+ // startThrough: moment().add(1, 'day').toDate(),
24
+ // startThrough: now
25
+ },
26
+ [],
27
+ []
28
+ );
25
29
 
26
30
  // console.log(events);
27
31
  console.log(events.length);
@@ -0,0 +1,78 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+ const POS_CLIENT_ID = String(process.env.POS_CLIENT_ID);
8
+ enum ROLE_NAME {
9
+ Customer = 'customer',
10
+ POS = 'pos'
11
+ }
12
+
13
+ // tslint:disable-next-line:max-func-body-length
14
+ async function main() {
15
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
16
+
17
+ const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
18
+
19
+ const cursor = memberRepo.getCursor(
20
+ {
21
+ 'member.id': { $eq: POS_CLIENT_ID }
22
+ },
23
+ {
24
+ // _id: 1,
25
+ }
26
+ );
27
+ console.log('members found');
28
+
29
+ let i = 0;
30
+ let updateCount = 0;
31
+ await cursor.eachAsync(async (doc) => {
32
+ i += 1;
33
+ const iamMember: chevre.factory.iam.IMember = doc.toObject();
34
+
35
+ const hasCustomerRole = iamMember.member.hasRole.some((role) => role.roleName === ROLE_NAME.Customer);
36
+ const alreadyMigrated = iamMember.member.hasRole.some((role) => role.roleName === ROLE_NAME.POS);
37
+
38
+ if (alreadyMigrated) {
39
+ console.log(
40
+ 'already exist...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.hasRole.length, 'roles', i);
41
+ } else {
42
+ if (!hasCustomerRole) {
43
+ console.error(
44
+ 'has no customer role!',
45
+ iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.hasRole.length, 'roles', i);
46
+ throw new Error('has no customer role!');
47
+ }
48
+
49
+ const newHasRole: chevre.factory.iam.IMemberHasRole = iamMember.member.hasRole;
50
+ newHasRole.push({ roleName: ROLE_NAME.POS, typeOf: chevre.factory.iam.RoleType.OrganizationRole });
51
+ console.log(
52
+ 'updating reservation...',
53
+ iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, newHasRole.length, 'roles', i);
54
+ await memberRepo.updateByMemberId({
55
+ project: { id: iamMember.project.id },
56
+ member: {
57
+ id: iamMember.member.id,
58
+ memberOf: {
59
+ id: iamMember.project.id,
60
+ typeOf: chevre.factory.organizationType.Project
61
+ },
62
+ hasRole: newHasRole
63
+ }
64
+ });
65
+ updateCount += 1;
66
+ console.log(
67
+ 'updated.',
68
+ iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, newHasRole.length, 'roles', i);
69
+ }
70
+ });
71
+
72
+ console.log(i, 'members checked');
73
+ console.log(updateCount, 'members updated');
74
+ }
75
+
76
+ main()
77
+ .then()
78
+ .catch(console.error);
@@ -12,10 +12,11 @@ async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
14
  const additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
15
- const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
15
+ const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
16
16
 
17
- const cursor = categoryCodeRepo.getCursor(
17
+ const cursor = placeRepo.getCursor(
18
18
  {
19
+ typeOf: { $eq: chevre.factory.placeType.MovieTheater }
19
20
  // 'project.id': { $eq: project.id },
20
21
  // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
21
22
  },
@@ -25,7 +26,7 @@ async function main() {
25
26
  // orderDate: 1
26
27
  }
27
28
  );
28
- console.log('categoryCodes found');
29
+ console.log('places found');
29
30
 
30
31
  const additionalPropertyNames: string[] = [];
31
32
  const projectIds: string[] = [];
@@ -36,30 +37,30 @@ async function main() {
36
37
  let i = 0;
37
38
  await cursor.eachAsync(async (doc) => {
38
39
  i += 1;
39
- const categoryCode: chevre.factory.categoryCode.ICategoryCode = doc.toObject();
40
+ const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
40
41
 
41
- const additionalPropertyNamesOnResource = (Array.isArray(categoryCode.additionalProperty))
42
- ? categoryCode.additionalProperty?.map((p) => p.name)
42
+ const additionalPropertyNamesOnResource = (Array.isArray(movieTheater.additionalProperty))
43
+ ? movieTheater.additionalProperty?.map((p) => p.name)
43
44
  : [];
44
45
  if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
45
46
  console.log(
46
47
  additionalPropertyNamesOnResource.join(','),
47
48
  additionalPropertyNamesOnResource.length,
48
49
  'additionalPropertyNamesOnResource found',
49
- categoryCode.project.id,
50
- categoryCode.codeValue
50
+ movieTheater.project.id,
51
+ movieTheater.branchCode
51
52
  );
52
53
  additionalPropertyNames.push(...additionalPropertyNamesOnResource);
53
- projectIds.push(categoryCode.project.id);
54
+ projectIds.push(movieTheater.project.id);
54
55
  additionalPropertyNamesOnResource.forEach((name) => {
55
56
  if (!name.match(/^[a-zA-Z]*$/)) {
56
57
  // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
57
- unexpextedprojectIds.push(categoryCode.project.id);
58
+ unexpextedprojectIds.push(movieTheater.project.id);
58
59
  }
59
60
  // tslint:disable-next-line:no-magic-numbers
60
61
  if (name.length < 5) {
61
62
  // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
62
- unexpextedprojectIds.push(categoryCode.project.id);
63
+ unexpextedprojectIds.push(movieTheater.project.id);
63
64
  }
64
65
  });
65
66
 
@@ -67,19 +68,19 @@ async function main() {
67
68
  checked += 1;
68
69
  const existingAdditionalProperties = await additionalPropertyRepo.search({
69
70
  limit: 1,
70
- project: { id: { $eq: categoryCode.project.id } },
71
+ project: { id: { $eq: movieTheater.project.id } },
71
72
  codeValue: { $eq: additionalPropertyNameOnResource },
72
- inCodeSet: { identifier: { $eq: categoryCode.typeOf } }
73
+ inCodeSet: { identifier: { $eq: movieTheater.typeOf } }
73
74
  });
74
75
  if (existingAdditionalProperties.length === 0) {
75
76
  const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
76
- project: categoryCode.project,
77
+ project: movieTheater.project,
77
78
  // id?: string;
78
79
  typeOf: 'CategoryCode',
79
80
  codeValue: additionalPropertyNameOnResource,
80
81
  inCodeSet: {
81
82
  typeOf: 'CategoryCodeSet',
82
- identifier: categoryCode.typeOf
83
+ identifier: movieTheater.typeOf
83
84
  },
84
85
  name: { ja: additionalPropertyNameOnResource }
85
86
  };
@@ -88,22 +89,21 @@ async function main() {
88
89
  console.log(
89
90
  'additionalProerty created',
90
91
  additionalPropertyNameOnResource,
91
- categoryCode.project.id,
92
- categoryCode.codeValue
92
+ movieTheater.project.id,
93
+ movieTheater.branchCode
93
94
  );
94
95
  } else {
95
96
  console.log(
96
97
  'additionalProerty existed',
97
98
  additionalPropertyNameOnResource,
98
- categoryCode.project.id,
99
- categoryCode.codeValue
99
+ movieTheater.project.id,
100
+ movieTheater.branchCode
100
101
  );
101
102
  }
102
-
103
103
  }
104
104
  }
105
105
  });
106
- console.log(i, 'categoryCodes checked');
106
+ console.log(i, 'places checked');
107
107
  console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
108
108
  console.log('projectIds:', [...new Set(projectIds)]);
109
109
  console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
@@ -15,18 +15,16 @@ async function main() {
15
15
 
16
16
  const events = await eventRepo.search(
17
17
  {
18
- // limit: 100,
19
- // page: 1,
18
+ limit: 100,
19
+ page: 1,
20
20
  // sort: { startDate: 1 },
21
21
  // typeOf: chevre.factory.eventType.ScreeningEvent,
22
22
  project: { id: { $eq: PROJECT_ID } },
23
- id: { $eq: 'al6aff83y' },
23
+ // id: { $eq: 'al6aff83y' },
24
24
  typeOfIn: [chevre.factory.eventType.Event, chevre.factory.eventType.ScreeningEvent]
25
25
  },
26
- {
27
- _id: 1
28
- // name: 1
29
- }
26
+ ['_id', 'name'],
27
+ []
30
28
  );
31
29
  console.log(events);
32
30
  console.log(events.length, 'events found');
@@ -23,7 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { BulkWriteResult } from 'mongodb';
26
- import type { Connection } from 'mongoose';
26
+ import type { Connection, FilterQuery } from 'mongoose';
27
27
  import * as factory from '../factory';
28
28
  import * as EventFactory from '../factory/event';
29
29
  export interface IAttributes4patchUpdate<T extends factory.eventType> {
@@ -78,8 +78,8 @@ interface IAggregateEvent {
78
78
  statuses: IStatus[];
79
79
  }
80
80
  type IKeyOfProjection<T extends factory.eventType> = keyof factory.event.IEvent<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
81
- type IProjection<T extends factory.eventType> = {
82
- [key in IKeyOfProjection<T>]?: 0 | 1;
81
+ type IUnset<T extends factory.eventType> = {
82
+ [key in keyof factory.event.IEvent<T>]?: 1;
83
83
  };
84
84
  export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
85
85
  export declare const keyOfMinimizedScreeningEvent: IKeyOfProjection<factory.eventType.ScreeningEvent>[];
@@ -90,7 +90,7 @@ export declare const keyOfMinimizedEvent: IKeyOfProjection<factory.eventType.Eve
90
90
  export declare class MongoRepository {
91
91
  private readonly eventModel;
92
92
  constructor(connection: Connection);
93
- static CREATE_MONGO_CONDITIONS<T extends factory.eventType>(conditions: ISearchConditions<T>): any[];
93
+ static CREATE_MONGO_CONDITIONS<T extends factory.eventType>(conditions: ISearchConditions<T>): FilterQuery<factory.event.IEvent<T>>[];
94
94
  /**
95
95
  * 複数イベントを作成する
96
96
  */
@@ -135,13 +135,13 @@ export declare class MongoRepository {
135
135
  save<T extends factory.eventType>(params: {
136
136
  id?: string;
137
137
  attributes: factory.event.IAttributes<T>;
138
- $unset?: IProjection<T>;
138
+ $unset?: IUnset<T>;
139
139
  upsert?: boolean;
140
140
  }): Promise<factory.event.IEvent<T>>;
141
141
  saveMany<T extends factory.eventType>(params: {
142
142
  id: string;
143
143
  attributes: factory.event.IAttributes<T>;
144
- $unset?: IProjection<T>;
144
+ $unset?: IUnset<T>;
145
145
  upsert: boolean;
146
146
  }[]): Promise<void>;
147
147
  save4ttts(params: {
@@ -282,10 +282,10 @@ export declare class MongoRepository {
282
282
  validationErrors: import("mongoose").Error[];
283
283
  } | undefined;
284
284
  }>;
285
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
285
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
286
286
  unsetUnnecessaryFields(params: {
287
- filter: any;
288
- $unset: any;
287
+ filter: FilterQuery<any>;
288
+ $unset: IUnset<any>;
289
289
  }): Promise<import("mongodb").UpdateResult>;
290
290
  /**
291
291
  * 既存施設コンテンツの最大バージョンを集計する
@@ -697,8 +697,8 @@ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromC
697
697
  typeOf: factory.placeType.MovieTheater,
698
698
  telephone: theaterFromCOA.theaterTelNum,
699
699
  offers: {
700
- project: { typeOf: project.typeOf, id: project.id },
701
- priceCurrency: factory.priceCurrency.JPY,
700
+ // project: { typeOf: project.typeOf, id: project.id }, // optimize(2023-11-06~)
701
+ // priceCurrency: factory.priceCurrency.JPY, // optimize(2023-11-06~)
702
702
  typeOf: factory.offerType.Offer,
703
703
  eligibleQuantity: {
704
704
  typeOf: 'QuantitativeValue',
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.337.0",
14
- "@cinerino/sdk": "5.0.0-alpha.3",
13
+ "@chevre/factory": "4.338.0",
14
+ "@cinerino/sdk": "5.0.0-alpha.6",
15
15
  "@motionpicture/coa-service": "9.2.0",
16
16
  "@motionpicture/gmo-service": "5.2.0",
17
17
  "@sendgrid/mail": "6.4.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.15.0-alpha.0"
120
+ "version": "21.15.0-alpha.2"
121
121
  }
@@ -1,59 +0,0 @@
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, { autoIndex: false });
13
-
14
- const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
15
-
16
- const cursor = memberRepo.getCursor(
17
- {},
18
- {
19
- // _id: 1,
20
- }
21
- );
22
- console.log('members found');
23
-
24
- let i = 0;
25
- let updateCount = 0;
26
- await cursor.eachAsync(async (doc) => {
27
- i += 1;
28
- const iamMember: chevre.factory.iam.IMember = doc.toObject();
29
-
30
- const memberOfId = iamMember.member.memberOf?.id;
31
- const alreadyMigrated = typeof memberOfId === 'string';
32
-
33
- if (alreadyMigrated) {
34
- console.log('already exist...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
35
- } else {
36
- console.log(
37
- 'updating reservation...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
38
- await memberRepo.updateByMemberMemberOf({
39
- project: { id: iamMember.project.id },
40
- member: {
41
- id: iamMember.member.id,
42
- memberOf: {
43
- id: iamMember.project.id,
44
- typeOf: chevre.factory.organizationType.Project
45
- }
46
- }
47
- });
48
- updateCount += 1;
49
- console.log('updated.', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
50
- }
51
- });
52
-
53
- console.log(i, 'members checked');
54
- console.log(updateCount, 'members updated');
55
- }
56
-
57
- main()
58
- .then()
59
- .catch(console.error);