@chevre/domain 22.3.0-alpha.5 → 22.3.0-alpha.6

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,126 @@
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 additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
15
+ const accountTitleRepo = await chevre.repository.AccountTitle.createInstance(mongoose.connection);
16
+
17
+ const cursor = accountTitleRepo.getCursor(
18
+ {
19
+ // 'project.id': { $eq: project.id },
20
+ // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
21
+ },
22
+ {
23
+ // paymentMethods: 1,
24
+ // project: 1,
25
+ // orderDate: 1
26
+ }
27
+ );
28
+ console.log('docs found');
29
+
30
+ const additionalPropertyNames: string[] = [];
31
+ const projectIds: string[] = [];
32
+ const unexpextedprojectIds: string[] = [];
33
+ let checked: number = 0;
34
+ let created: number = 0;
35
+
36
+ let i = 0;
37
+ await cursor.eachAsync(async (doc) => {
38
+ i += 1;
39
+ const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
40
+ const accountTitleSets: Pick<chevre.factory.accountTitle.IAccountTitle, 'additionalProperty' | 'codeValue' | 'typeOf' | 'hasCategoryCode'>[] =
41
+ (Array.isArray(accountTitleCategory.hasCategoryCode))
42
+ ? accountTitleCategory.hasCategoryCode
43
+ : [];
44
+ for (const accountTitleSet of accountTitleSets) {
45
+ const accountTitles: Pick<chevre.factory.accountTitle.IAccountTitle, 'additionalProperty' | 'codeValue' | 'typeOf'>[] =
46
+ (Array.isArray(accountTitleSet.hasCategoryCode))
47
+ ? accountTitleSet.hasCategoryCode
48
+ : [];
49
+ for (const accountTitle of accountTitles) {
50
+ const additionalPropertyNamesOnResource = (Array.isArray(accountTitle.additionalProperty))
51
+ ? accountTitle.additionalProperty?.map((p) => p.name)
52
+ : [];
53
+ if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
54
+ console.log(
55
+ additionalPropertyNamesOnResource.join(','),
56
+ additionalPropertyNamesOnResource.length,
57
+ 'additionalPropertyNamesOnResource found',
58
+ accountTitleCategory.project.id,
59
+ accountTitle.codeValue
60
+ );
61
+ additionalPropertyNames.push(...additionalPropertyNamesOnResource);
62
+ projectIds.push(accountTitleCategory.project.id);
63
+ additionalPropertyNamesOnResource.forEach((name) => {
64
+ if (!name.match(/^[a-zA-Z]*$/)) {
65
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
66
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
67
+ }
68
+ // tslint:disable-next-line:no-magic-numbers
69
+ if (name.length < 5) {
70
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
71
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
72
+ }
73
+ });
74
+
75
+ for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
76
+ checked += 1;
77
+ const existingAdditionalProperties = await additionalPropertyRepo.search({
78
+ limit: 1,
79
+ project: { id: { $eq: accountTitleCategory.project.id } },
80
+ codeValue: { $eq: additionalPropertyNameOnResource },
81
+ inCodeSet: { identifier: { $eq: accountTitle.typeOf } }
82
+ });
83
+ if (existingAdditionalProperties.length === 0) {
84
+ const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
85
+ project: accountTitleCategory.project,
86
+ // id?: string;
87
+ typeOf: 'CategoryCode',
88
+ codeValue: additionalPropertyNameOnResource,
89
+ inCodeSet: {
90
+ typeOf: 'CategoryCodeSet',
91
+ identifier: accountTitle.typeOf
92
+ },
93
+ name: { ja: additionalPropertyNameOnResource }
94
+ };
95
+ // await additionalPropertyRepo.save({ attributes: additionalProperty });
96
+ created += 1;
97
+ console.log(
98
+ 'additionalProerty created',
99
+ additionalPropertyNameOnResource,
100
+ accountTitleCategory.project.id,
101
+ accountTitle.codeValue
102
+ );
103
+ } else {
104
+ console.log(
105
+ 'additionalProerty existed',
106
+ additionalPropertyNameOnResource,
107
+ accountTitleCategory.project.id,
108
+ accountTitle.codeValue
109
+ );
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ });
116
+ console.log(i, 'docs checked');
117
+ console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
118
+ console.log('projectIds:', [...new Set(projectIds)]);
119
+ console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
120
+ console.log('checked:', checked);
121
+ console.log('created:', created);
122
+ }
123
+
124
+ main()
125
+ .then()
126
+ .catch(console.error);
@@ -0,0 +1,113 @@
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 additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
15
+ const accountTitleRepo = await chevre.repository.AccountTitle.createInstance(mongoose.connection);
16
+
17
+ const cursor = accountTitleRepo.getCursor(
18
+ {
19
+ // 'project.id': { $eq: project.id },
20
+ // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
21
+ },
22
+ {
23
+ // paymentMethods: 1,
24
+ // project: 1,
25
+ // orderDate: 1
26
+ }
27
+ );
28
+ console.log('docs found');
29
+
30
+ const additionalPropertyNames: string[] = [];
31
+ const projectIds: string[] = [];
32
+ const unexpextedprojectIds: string[] = [];
33
+ let checked: number = 0;
34
+ let created: number = 0;
35
+
36
+ let i = 0;
37
+ await cursor.eachAsync(async (doc) => {
38
+ i += 1;
39
+ const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
40
+
41
+ const additionalPropertyNamesOnResource = (Array.isArray(accountTitleCategory.additionalProperty))
42
+ ? accountTitleCategory.additionalProperty?.map((p) => p.name)
43
+ : [];
44
+ if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
45
+ console.log(
46
+ additionalPropertyNamesOnResource.join(','),
47
+ additionalPropertyNamesOnResource.length,
48
+ 'additionalPropertyNamesOnResource found',
49
+ accountTitleCategory.project.id,
50
+ accountTitleCategory.codeValue
51
+ );
52
+ additionalPropertyNames.push(...additionalPropertyNamesOnResource);
53
+ projectIds.push(accountTitleCategory.project.id);
54
+ additionalPropertyNamesOnResource.forEach((name) => {
55
+ if (!name.match(/^[a-zA-Z]*$/)) {
56
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
57
+ }
58
+ // tslint:disable-next-line:no-magic-numbers
59
+ if (name.length < 5) {
60
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
61
+ }
62
+ });
63
+
64
+ for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
65
+ checked += 1;
66
+ const existingAdditionalProperties = await additionalPropertyRepo.search({
67
+ limit: 1,
68
+ project: { id: { $eq: accountTitleCategory.project.id } },
69
+ codeValue: { $eq: additionalPropertyNameOnResource },
70
+ inCodeSet: { identifier: { $eq: accountTitleCategory.typeOf } }
71
+ });
72
+ if (existingAdditionalProperties.length === 0) {
73
+ const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
74
+ project: accountTitleCategory.project,
75
+ // id?: string;
76
+ typeOf: 'CategoryCode',
77
+ codeValue: additionalPropertyNameOnResource,
78
+ inCodeSet: {
79
+ typeOf: 'CategoryCodeSet',
80
+ identifier: accountTitleCategory.typeOf
81
+ },
82
+ name: { ja: additionalPropertyNameOnResource }
83
+ };
84
+ // await additionalPropertyRepo.save({ attributes: additionalProperty });
85
+ created += 1;
86
+ console.log(
87
+ 'additionalProerty created',
88
+ additionalPropertyNameOnResource,
89
+ accountTitleCategory.project.id,
90
+ accountTitleCategory.codeValue
91
+ );
92
+ } else {
93
+ console.log(
94
+ 'additionalProerty existed',
95
+ additionalPropertyNameOnResource,
96
+ accountTitleCategory.project.id,
97
+ accountTitleCategory.codeValue
98
+ );
99
+ }
100
+ }
101
+ }
102
+ });
103
+ console.log(i, 'docs checked');
104
+ console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
105
+ console.log('projectIds:', [...new Set(projectIds)]);
106
+ console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
107
+ console.log('checked:', checked);
108
+ console.log('created:', created);
109
+ }
110
+
111
+ main()
112
+ .then()
113
+ .catch(console.error);
@@ -0,0 +1,120 @@
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 additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
15
+ const accountTitleRepo = await chevre.repository.AccountTitle.createInstance(mongoose.connection);
16
+
17
+ const cursor = accountTitleRepo.getCursor(
18
+ {
19
+ // 'project.id': { $eq: project.id },
20
+ // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
21
+ },
22
+ {
23
+ // paymentMethods: 1,
24
+ // project: 1,
25
+ // orderDate: 1
26
+ }
27
+ );
28
+ console.log('docs found');
29
+
30
+ const additionalPropertyNames: string[] = [];
31
+ const projectIds: string[] = [];
32
+ const unexpextedprojectIds: string[] = [];
33
+ let checked: number = 0;
34
+ let created: number = 0;
35
+
36
+ let i = 0;
37
+ await cursor.eachAsync(async (doc) => {
38
+ i += 1;
39
+ const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
40
+ const accountTitleSets: Pick<chevre.factory.accountTitle.IAccountTitle, 'additionalProperty' | 'codeValue' | 'typeOf'>[] =
41
+ (Array.isArray(accountTitleCategory.hasCategoryCode))
42
+ ? accountTitleCategory.hasCategoryCode
43
+ : [];
44
+ for (const accountTitleSet of accountTitleSets) {
45
+ const additionalPropertyNamesOnResource = (Array.isArray(accountTitleSet.additionalProperty))
46
+ ? accountTitleSet.additionalProperty?.map((p) => p.name)
47
+ : [];
48
+ if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
49
+ console.log(
50
+ additionalPropertyNamesOnResource.join(','),
51
+ additionalPropertyNamesOnResource.length,
52
+ 'additionalPropertyNamesOnResource found',
53
+ accountTitleCategory.project.id,
54
+ accountTitleSet.codeValue
55
+ );
56
+ additionalPropertyNames.push(...additionalPropertyNamesOnResource);
57
+ projectIds.push(accountTitleCategory.project.id);
58
+ additionalPropertyNamesOnResource.forEach((name) => {
59
+ if (!name.match(/^[a-zA-Z]*$/)) {
60
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
61
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
62
+ }
63
+ // tslint:disable-next-line:no-magic-numbers
64
+ if (name.length < 5) {
65
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
66
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
67
+ }
68
+ });
69
+
70
+ for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
71
+ checked += 1;
72
+ const existingAdditionalProperties = await additionalPropertyRepo.search({
73
+ limit: 1,
74
+ project: { id: { $eq: accountTitleCategory.project.id } },
75
+ codeValue: { $eq: additionalPropertyNameOnResource },
76
+ inCodeSet: { identifier: { $eq: accountTitleSet.typeOf } }
77
+ });
78
+ if (existingAdditionalProperties.length === 0) {
79
+ const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
80
+ project: accountTitleCategory.project,
81
+ // id?: string;
82
+ typeOf: 'CategoryCode',
83
+ codeValue: additionalPropertyNameOnResource,
84
+ inCodeSet: {
85
+ typeOf: 'CategoryCodeSet',
86
+ identifier: accountTitleSet.typeOf
87
+ },
88
+ name: { ja: additionalPropertyNameOnResource }
89
+ };
90
+ // await additionalPropertyRepo.save({ attributes: additionalProperty });
91
+ created += 1;
92
+ console.log(
93
+ 'additionalProerty created',
94
+ additionalPropertyNameOnResource,
95
+ accountTitleCategory.project.id,
96
+ accountTitleSet.codeValue
97
+ );
98
+ } else {
99
+ console.log(
100
+ 'additionalProerty existed',
101
+ additionalPropertyNameOnResource,
102
+ accountTitleCategory.project.id,
103
+ accountTitleSet.codeValue
104
+ );
105
+ }
106
+ }
107
+ }
108
+ }
109
+ });
110
+ console.log(i, 'docs checked');
111
+ console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
112
+ console.log('projectIds:', [...new Set(projectIds)]);
113
+ console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
114
+ console.log('checked:', checked);
115
+ console.log('created:', created);
116
+ }
117
+
118
+ main()
119
+ .then()
120
+ .catch(console.error);
@@ -15,7 +15,7 @@ const schemaDefinition = {
15
15
  codeValue: String,
16
16
  // alternateName: String,
17
17
  name: String,
18
- description: String,
18
+ // description: String,
19
19
  inCodeSet: mongoose_1.SchemaTypes.Mixed,
20
20
  hasCategoryCode: mongoose_1.SchemaTypes.Mixed,
21
21
  inDefinedTermSet: mongoose_1.SchemaTypes.Mixed,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.383.0-alpha.1",
12
+ "@chevre/factory": "4.383.0-alpha.2",
13
13
  "@cinerino/sdk": "10.9.0-alpha.1",
14
14
  "@motionpicture/coa-service": "9.5.0-alpha.0",
15
15
  "@motionpicture/gmo-service": "5.3.0",
@@ -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.5"
113
+ "version": "22.3.0-alpha.6"
114
114
  }