@chevre/domain 21.30.0-alpha.45 → 21.30.0-alpha.47

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,94 @@
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
+
8
+ // tslint:disable-next-line:max-func-body-length
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
13
+
14
+ const cursor = memberRepo.getCursor(
15
+ {
16
+ 'member.memberOf.typeOf': { $eq: chevre.factory.organizationType.Corporation }
17
+ },
18
+ {
19
+ }
20
+ );
21
+ console.log('members found');
22
+
23
+ let projectIds: string[] = [];
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 alreadyMigrated = false;
31
+ projectIds.push(iamMember.project.id);
32
+
33
+ if (alreadyMigrated) {
34
+ console.log(
35
+ 'already exist.',
36
+ iamMember.project.id,
37
+ iamMember.member.memberOf.typeOf, iamMember.member.memberOf.id, i, updateCount
38
+ );
39
+ } else {
40
+ console.log(
41
+ 'updating...',
42
+ iamMember.project.id,
43
+ iamMember.member.memberOf.typeOf, iamMember.member.memberOf.id, i, updateCount
44
+ );
45
+ updateCount += 1;
46
+ console.log(
47
+ 'updated.',
48
+ iamMember.project.id,
49
+ iamMember.member.memberOf.typeOf, iamMember.member.memberOf.id, i, updateCount
50
+ );
51
+ }
52
+ });
53
+
54
+ projectIds = [...new Set(projectIds)];
55
+ console.log(projectIds);
56
+ console.log(i, 'members checked');
57
+ console.log(updateCount, 'members updated');
58
+
59
+ // 販売者メンバーの存在するプロジェクトについて、inventoryManagerにiam.roleAdminを追加
60
+ const NEW_ROLE_NAME = 'iam.roleAdmin';
61
+ for (const projectId of projectIds) {
62
+ const inventoryManagers = await memberRepo.search({
63
+ project: { id: { $eq: projectId } },
64
+ member: {
65
+ hasRole: { roleName: { $eq: 'inventoryManager' } },
66
+ memberOf: { typeOf: { $eq: chevre.factory.organizationType.Project } }
67
+ }
68
+ });
69
+ console.log(inventoryManagers.length, 'inventoryManagers found', projectId);
70
+ for (const inventoryManager of inventoryManagers) {
71
+ const alreadyRoleAdmin = inventoryManager.member.hasRole.some(({ roleName }) => roleName === NEW_ROLE_NAME);
72
+ if (!alreadyRoleAdmin) {
73
+ const newHasRole: chevre.factory.iam.IMemberRole[] = [
74
+ { typeOf: chevre.factory.iam.RoleType.OrganizationRole, roleName: NEW_ROLE_NAME },
75
+ ...inventoryManager.member.hasRole
76
+ ];
77
+ console.log('adding newRole', projectId, inventoryManager.member.id, newHasRole);
78
+ await memberRepo.updateByMemberId({
79
+ project: { id: inventoryManager.project.id },
80
+ member: {
81
+ id: inventoryManager.member.id,
82
+ memberOf: inventoryManager.member.memberOf,
83
+ hasRole: newHasRole
84
+ },
85
+ $unset: {}
86
+ });
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ main()
93
+ .then()
94
+ .catch(console.error);
@@ -8,10 +8,36 @@ async function main() {
8
8
 
9
9
  let updateResult: any;
10
10
 
11
- const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
12
- updateResult = await authorizationRepo.unsetUnnecessaryFields({
11
+ const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
12
+ const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
13
+ const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
14
+ updateResult = await memberRepo.unsetUnnecessaryFields({
13
15
  filter: {
14
- validFrom: { $lte: new Date() }
16
+ _id: { $exists: true }
17
+ },
18
+ $unset: {
19
+ __v: 1,
20
+ createdAt: 1,
21
+ updatedAt: 1
22
+ }
23
+ });
24
+ console.log('unset processed.', updateResult);
25
+
26
+ updateResult = await noteRepo.unsetUnnecessaryFields({
27
+ filter: {
28
+ _id: { $exists: true }
29
+ },
30
+ $unset: {
31
+ __v: 1,
32
+ createdAt: 1,
33
+ updatedAt: 1
34
+ }
35
+ });
36
+ console.log('unset processed.', updateResult);
37
+
38
+ updateResult = await ownershipInfoRepo.unsetUnnecessaryFields({
39
+ filter: {
40
+ _id: { $exists: true }
15
41
  },
16
42
  $unset: {
17
43
  __v: 1,
@@ -169,4 +169,8 @@ export declare class MongoRepository {
169
169
  };
170
170
  }): Promise<string[]>;
171
171
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
172
+ unsetUnnecessaryFields(params: {
173
+ filter: any;
174
+ $unset: any;
175
+ }): Promise<import("mongodb").UpdateResult>;
172
176
  }
@@ -295,5 +295,11 @@ class MongoRepository {
295
295
  .sort({ 'member.id': factory.sortType.Ascending })
296
296
  .cursor();
297
297
  }
298
+ unsetUnnecessaryFields(params) {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ return this.memberModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
301
+ .exec();
302
+ });
303
+ }
298
304
  }
299
305
  exports.MongoRepository = MongoRepository;
@@ -19,6 +19,9 @@ const schemaDefinition = {
19
19
  type: mongoose_1.SchemaTypes.Mixed,
20
20
  required: true
21
21
  }
22
+ // __v: SchemaTypes.Mixed,
23
+ // createdAt: SchemaTypes.Mixed,
24
+ // updatedAt: SchemaTypes.Mixed
22
25
  };
23
26
  const schemaOptions = {
24
27
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -29,10 +32,8 @@ const schemaOptions = {
29
32
  writeConcern: writeConcern_1.writeConcern,
30
33
  strict: true,
31
34
  strictQuery: false,
32
- timestamps: {
33
- createdAt: 'createdAt',
34
- updatedAt: 'updatedAt'
35
- },
35
+ timestamps: false,
36
+ versionKey: false,
36
37
  toJSON: {
37
38
  getters: false,
38
39
  virtuals: false,
@@ -58,14 +59,6 @@ function createSchema() {
58
59
  }
59
60
  exports.createSchema = createSchema;
60
61
  const indexes = [
61
- [
62
- { createdAt: 1 },
63
- { name: 'searchByCreatedAt' }
64
- ],
65
- [
66
- { updatedAt: 1 },
67
- { name: 'searchByUpdatedAt' }
68
- ],
69
62
  [
70
63
  { 'member.id': 1 },
71
64
  { name: 'searchByMemberId' }
@@ -42,6 +42,9 @@ const schemaDefinition = {
42
42
  type: String,
43
43
  required: true
44
44
  }
45
+ // __v: SchemaTypes.Mixed,
46
+ // createdAt: SchemaTypes.Mixed,
47
+ // updatedAt: SchemaTypes.Mixed
45
48
  };
46
49
  const schemaOptions = {
47
50
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -52,10 +55,8 @@ const schemaOptions = {
52
55
  writeConcern: writeConcern_1.writeConcern,
53
56
  strict: true,
54
57
  strictQuery: false,
55
- timestamps: {
56
- createdAt: 'createdAt',
57
- updatedAt: 'updatedAt'
58
- },
58
+ timestamps: false,
59
+ versionKey: false,
59
60
  toJSON: {
60
61
  getters: false,
61
62
  virtuals: false,
@@ -70,14 +71,6 @@ const schemaOptions = {
70
71
  }
71
72
  };
72
73
  const indexes = [
73
- [
74
- { createdAt: 1 },
75
- { name: 'searchByCreatedAt' }
76
- ],
77
- [
78
- { updatedAt: 1 },
79
- { name: 'searchByUpdatedAt' }
80
- ],
81
74
  [
82
75
  { identifier: 1 },
83
76
  { name: 'searchByIdentifier' }
@@ -22,6 +22,9 @@ const schemaDefinition = {
22
22
  ownedFrom: Date,
23
23
  ownedThrough: Date,
24
24
  typeOfGood: mongoose_1.SchemaTypes.Mixed
25
+ // __v: SchemaTypes.Mixed,
26
+ // createdAt: SchemaTypes.Mixed,
27
+ // updatedAt: SchemaTypes.Mixed
25
28
  };
26
29
  const schemaOptions = {
27
30
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -32,10 +35,8 @@ const schemaOptions = {
32
35
  writeConcern: writeConcern_1.writeConcern,
33
36
  strict: true,
34
37
  strictQuery: false,
35
- timestamps: {
36
- createdAt: 'createdAt',
37
- updatedAt: 'updatedAt'
38
- },
38
+ timestamps: false,
39
+ versionKey: false,
39
40
  toJSON: {
40
41
  getters: false,
41
42
  virtuals: false,
@@ -61,14 +62,6 @@ function createSchema() {
61
62
  }
62
63
  exports.createSchema = createSchema;
63
64
  const indexes = [
64
- [
65
- { createdAt: 1 },
66
- { name: 'searchByCreatedAt' }
67
- ],
68
- [
69
- { updatedAt: 1 },
70
- { name: 'searchByUpdatedAt' }
71
- ],
72
65
  [
73
66
  // 識別子はユニークな前提
74
67
  { identifier: 1 },
@@ -35,5 +35,9 @@ export declare class MongoRepository {
35
35
  typeOf: factory.creativeWork.noteDigitalDocument.IAbout['typeOf'];
36
36
  };
37
37
  }): Promise<import("mongodb").DeleteResult>;
38
+ unsetUnnecessaryFields(params: {
39
+ filter: any;
40
+ $unset: any;
41
+ }): Promise<import("mongodb").UpdateResult>;
38
42
  }
39
43
  export {};
@@ -178,5 +178,11 @@ class MongoRepository {
178
178
  .exec();
179
179
  });
180
180
  }
181
+ unsetUnnecessaryFields(params) {
182
+ return __awaiter(this, void 0, void 0, function* () {
183
+ return this.noteModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
184
+ .exec();
185
+ });
186
+ }
181
187
  }
182
188
  exports.MongoRepository = MongoRepository;
@@ -116,4 +116,8 @@ export declare class MongoRepository {
116
116
  id: string;
117
117
  };
118
118
  }): Promise<void>;
119
+ unsetUnnecessaryFields(params: {
120
+ filter: any;
121
+ $unset: any;
122
+ }): Promise<import("mongodb").UpdateResult>;
119
123
  }
@@ -427,5 +427,11 @@ class MongoRepository {
427
427
  }
428
428
  });
429
429
  }
430
+ unsetUnnecessaryFields(params) {
431
+ return __awaiter(this, void 0, void 0, function* () {
432
+ return this.ownershipInfoModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
433
+ .exec();
434
+ });
435
+ }
430
436
  }
431
437
  exports.MongoRepository = MongoRepository;
@@ -16,7 +16,6 @@ exports.verifyToken = exports.getToken = void 0;
16
16
  const jwt = require("jsonwebtoken");
17
17
  const credentials_1 = require("../credentials");
18
18
  const factory = require("../factory");
19
- const settings_1 = require("../settings");
20
19
  const ALGORITHM = 'HS256';
21
20
  /**
22
21
  * コードをトークンに変換する
@@ -54,12 +53,15 @@ function getToken(params) {
54
53
  typ = `${credentials_1.credentials.jwt.payloadTypPrefix}:${params.agent.typeOf}`;
55
54
  }
56
55
  }
57
- const isAuthorize4order = authorization.object.typeOf === factory.order.OrderType.Order;
58
- const payload = Object.assign(Object.assign({}, (settings_1.USE_TOKEN_WITH_NO_VERSION && isAuthorize4order) ? authorization.object : undefined), {
56
+ // const isAuthorize4order: boolean = authorization.object.typeOf === factory.order.OrderType.Order;
57
+ const payload = {
58
+ // NO_VERSIONを廃止(2024-05-06~)
59
+ // ...(USE_TOKEN_WITH_NO_VERSION && isAuthorize4order) ? authorization.object : undefined,
59
60
  // sub: authorization.id, // 拡張(2024-05-01~)
60
- token_use: 'access', version: credentials_1.credentials.jwt.version, // 拡張(2024-05-02~)
61
+ token_use: 'access',
62
+ version: credentials_1.credentials.jwt.version,
61
63
  typ // 拡張(2024-05-07~)
62
- });
64
+ };
63
65
  return new Promise((resolve, reject) => {
64
66
  // 所有権を暗号化する
65
67
  jwt.sign(payload, credentials_1.credentials.jwt.secret, Object.assign(Object.assign({ algorithm: ALGORITHM,
@@ -179,12 +181,12 @@ function verifyToken(params) {
179
181
  }
180
182
  else {
181
183
  // NO_VERSIONを廃止(2024-05-06~)
182
- if (settings_1.USE_TOKEN_WITH_NO_VERSION) {
183
- result = payload;
184
- }
185
- else {
186
- throw new factory.errors.NotImplemented('USE_TOKEN_WITH_NO_VERSION not implemented');
187
- }
184
+ throw new factory.errors.NotImplemented('USE_TOKEN_WITH_NO_VERSION discontinued');
185
+ // if (USE_TOKEN_WITH_NO_VERSION) {
186
+ // result = payload;
187
+ // } else {
188
+ // throw new factory.errors.NotImplemented('USE_TOKEN_WITH_NO_VERSION not implemented');
189
+ // }
188
190
  }
189
191
  return result;
190
192
  });
@@ -40,7 +40,6 @@ export declare const USE_CHECK_RESOURCE_TASK: boolean;
40
40
  export declare const USE_OPTIMIZE_RESERVATION_EXCEPTIONS: string[];
41
41
  export declare const USE_OPTIMIZE_INFORM_EVENT: boolean;
42
42
  export declare const USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER: boolean;
43
- export declare const USE_TOKEN_WITH_NO_VERSION: boolean;
44
43
  export declare const MONGO_MAX_TIME_MS: number;
45
44
  export declare const MONGO_READ_PREFERENCE: string;
46
45
  export declare const MONGO_AUTO_INDEX: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_TOKEN_WITH_NO_VERSION = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const factory = require("./factory");
5
5
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
6
6
  ? process.env.INFORM_TRANSACTION_URL.split(' ')
@@ -63,7 +63,6 @@ exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = (typeof process.env.USE_OPTIMIZE_R
63
63
  : [];
64
64
  exports.USE_OPTIMIZE_INFORM_EVENT = process.env.USE_OPTIMIZE_INFORM_EVENT === '1';
65
65
  exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = process.env.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER === '1';
66
- exports.USE_TOKEN_WITH_NO_VERSION = process.env.USE_TOKEN_WITH_NO_VERSION === '1';
67
66
  exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
68
67
  ? Number(process.env.MONGO_MAX_TIME_MS)
69
68
  // tslint:disable-next-line:no-magic-numbers
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.369.0-alpha.11",
14
- "@cinerino/sdk": "5.18.0-alpha.19",
13
+ "@chevre/factory": "4.369.1",
14
+ "@cinerino/sdk": "6.1.0-alpha.1",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
17
17
  "@sendgrid/mail": "6.4.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": "21.30.0-alpha.45"
113
+ "version": "21.30.0-alpha.47"
114
114
  }