@chevre/domain 22.5.0-alpha.23 → 22.5.0-alpha.24
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.
- package/example/src/chevre/migrateSellerMakesOfferAvailableAt.ts +8 -7
- package/example/src/chevre/person/cleanUpCognitoUsers.ts +89 -0
- package/example/src/chevre/searchSellersByAggregate.ts +3 -4
- package/lib/chevre/repo/creativeWork.js +1 -3
- package/lib/chevre/repo/place/movieTheater.js +1 -3
- package/lib/chevre/repo/product.js +1 -3
- package/lib/chevre/repo/project.js +1 -3
- package/lib/chevre/repo/seller.d.ts +5 -3
- package/lib/chevre/repo/seller.js +12 -7
- package/lib/chevre/service/aggregation/project.js +0 -1
- package/lib/chevre/service/assetTransaction/cancelReservation.js +0 -2
- package/lib/chevre/service/assetTransaction/registerService.js +0 -1
- package/lib/chevre/service/moneyTransfer.js +0 -1
- package/lib/chevre/service/notification.js +0 -1
- package/lib/chevre/service/payment/paymentCard.js +0 -5
- package/lib/chevre/service/reserve/findByCode.js +0 -1
- package/lib/chevre/service/task/deletePerson.js +0 -1
- package/lib/chevre/service/transaction/returnOrder/preStart.js +0 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ async function main() {
|
|
|
14
14
|
|
|
15
15
|
const cursor = sellerRepo.getCursor(
|
|
16
16
|
{
|
|
17
|
-
_id: { $eq: '
|
|
17
|
+
// _id: { $eq: '5a392dfdfca1c8737fb6da42' }
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
_id: 1,
|
|
@@ -66,12 +66,13 @@ async function main() {
|
|
|
66
66
|
console.log(
|
|
67
67
|
'updating project...',
|
|
68
68
|
seller.project.id, seller.typeOf, seller.id, seller.name?.ja, i, newMakesOffer);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
await sellerRepo.save({
|
|
70
|
+
id: String(seller.id),
|
|
71
|
+
attributes: <any>{
|
|
72
|
+
project: seller.project,
|
|
73
|
+
makesOffer: newMakesOffer
|
|
74
|
+
}
|
|
75
|
+
});
|
|
75
76
|
updateCount += 1;
|
|
76
77
|
console.log(
|
|
77
78
|
'updated.',
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import { CognitoIdentityProvider, UserType } from '@aws-sdk/client-cognito-identity-provider';
|
|
3
|
+
import { fromEnv } from '@aws-sdk/credential-providers';
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
|
|
9
|
+
export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
10
|
+
const NEW_USERPOOL_PROVIDER_NAME = 'SSKTS';
|
|
11
|
+
|
|
12
|
+
// tslint:disable-next-line:max-func-body-length
|
|
13
|
+
async function main(): Promise<void> {
|
|
14
|
+
const awsCredentials = fromEnv();
|
|
15
|
+
const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
|
|
16
|
+
apiVersion: 'latest',
|
|
17
|
+
region: 'ap-northeast-1',
|
|
18
|
+
credentials: awsCredentials
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// create user
|
|
22
|
+
const newPersonRepo = await chevre.repository.Person.createInstance({
|
|
23
|
+
userPoolId: USERPOOL_ID_NEW,
|
|
24
|
+
cognitoIdentityServiceProvider
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const users: UserType[] = [];
|
|
28
|
+
let nextToken: string | undefined = '';
|
|
29
|
+
let page: number = 0;
|
|
30
|
+
while (typeof nextToken === 'string') {
|
|
31
|
+
page += 1;
|
|
32
|
+
console.log('listUsersInGroup processing...', nextToken, page);
|
|
33
|
+
const listUsersInGroupResult = await newPersonRepo.cognitoIdentityServiceProvider.listUsersInGroup(
|
|
34
|
+
{
|
|
35
|
+
Limit: 50,
|
|
36
|
+
UserPoolId: USERPOOL_ID_NEW,
|
|
37
|
+
GroupName: 'ap-northeast-1_UWLLyMcjt_SSKTS',
|
|
38
|
+
...(typeof nextToken === 'string' && nextToken !== '') ? { NextToken: nextToken } : undefined
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
// tslint:disable-next-line:no-null-keyword
|
|
42
|
+
console.dir(listUsersInGroupResult.Users?.at(0), { depth: null });
|
|
43
|
+
nextToken = listUsersInGroupResult.NextToken;
|
|
44
|
+
if (Array.isArray(listUsersInGroupResult.Users)) {
|
|
45
|
+
users.push(...listUsersInGroupResult.Users);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
console.log('listUsersInGroup processed', nextToken, page);
|
|
49
|
+
console.log(users.length, 'users found');
|
|
50
|
+
|
|
51
|
+
const oneMonthAgo = moment()
|
|
52
|
+
.add(-1, 'months');
|
|
53
|
+
for (const user of users) {
|
|
54
|
+
const isSSKTSMember = user.Username?.startsWith(NEW_USERPOOL_PROVIDER_NAME, 0);
|
|
55
|
+
if (!isSSKTSMember) {
|
|
56
|
+
console.error(user);
|
|
57
|
+
throw new Error('not ssktsMember');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const sub = user.Attributes?.find(({ Name }) => Name === 'sub')?.Value;
|
|
61
|
+
// if (user.Enabled === true && sub === '46686164-2c18-491a-8594-52c944d895e9') {
|
|
62
|
+
if (user.Enabled === true) {
|
|
63
|
+
console.log('disabling...', user.Username, sub);
|
|
64
|
+
// disable link provider
|
|
65
|
+
const adminDisableUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDisableUser({
|
|
66
|
+
UserPoolId: USERPOOL_ID_NEW,
|
|
67
|
+
Username: user.Username
|
|
68
|
+
});
|
|
69
|
+
console.log('disabled.', user.Username, sub, adminDisableUserResult);
|
|
70
|
+
} else {
|
|
71
|
+
if (user.UserLastModifiedDate instanceof Date) {
|
|
72
|
+
if (moment(user.UserLastModifiedDate)
|
|
73
|
+
.isBefore(oneMonthAgo)) {
|
|
74
|
+
console.log('adminDeleteUser prossing...', user.Username, sub);
|
|
75
|
+
const adminDeleteUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDeleteUser({
|
|
76
|
+
UserPoolId: USERPOOL_ID_NEW,
|
|
77
|
+
Username: user.Username
|
|
78
|
+
});
|
|
79
|
+
console.log('adminDeleteUser processed.', user.Username, sub, adminDeleteUserResult);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main()
|
|
88
|
+
.then()
|
|
89
|
+
.catch(console.error);
|
|
@@ -12,15 +12,14 @@ async function main() {
|
|
|
12
12
|
|
|
13
13
|
const sellersByAggregate = await sellerRepo.searchByAggregate(
|
|
14
14
|
{
|
|
15
|
-
limit:
|
|
15
|
+
limit: 1,
|
|
16
16
|
page: 1,
|
|
17
|
-
sort: { branchCode: chevre.factory.sortType.Descending }
|
|
18
|
-
id: { $eq: '59d20831e53ebc2b4e774466' }
|
|
17
|
+
sort: { branchCode: chevre.factory.sortType.Descending }
|
|
18
|
+
// id: { $eq: '59d20831e53ebc2b4e774466' }
|
|
19
19
|
// project: { id: { $eq: project.id } }
|
|
20
20
|
// paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
21
21
|
// hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
22
22
|
},
|
|
23
|
-
[],
|
|
24
23
|
['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
|
|
25
24
|
);
|
|
26
25
|
console.log('sellers found', sellersByAggregate, sellersByAggregate[0]?.hasMerchantReturnPolicy);
|
|
@@ -228,9 +228,7 @@ class CreativeWorkRepo {
|
|
|
228
228
|
/**
|
|
229
229
|
* コンテンツを検索する
|
|
230
230
|
*/
|
|
231
|
-
projectFields(params, inclusion
|
|
232
|
-
// exclusion: IKeyOfProjection[]
|
|
233
|
-
) {
|
|
231
|
+
projectFields(params, inclusion) {
|
|
234
232
|
var _a;
|
|
235
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
236
234
|
const conditions = CreativeWorkRepo.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -173,9 +173,7 @@ class MovieTheaterRepo {
|
|
|
173
173
|
* 施設検索
|
|
174
174
|
* redefine(2024-09-18~)
|
|
175
175
|
*/
|
|
176
|
-
projectFields(params, inclusion
|
|
177
|
-
// exclusion: IKeyOfProjection[]
|
|
178
|
-
) {
|
|
176
|
+
projectFields(params, inclusion) {
|
|
179
177
|
var _a;
|
|
180
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
179
|
const conditions = MovieTheaterRepo.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
|
|
@@ -174,9 +174,7 @@ class ProductRepo {
|
|
|
174
174
|
/**
|
|
175
175
|
* プロダクトを検索する
|
|
176
176
|
*/
|
|
177
|
-
projectFields(conditions, inclusion
|
|
178
|
-
// exclusion: IKeyOfProjection[] // discontinue(2024-09-28~)
|
|
179
|
-
) {
|
|
177
|
+
projectFields(conditions, inclusion) {
|
|
180
178
|
var _a;
|
|
181
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
180
|
const andConditions = ProductRepo.CREATE_MONGO_CONDITIONS(conditions);
|
|
@@ -92,9 +92,7 @@ class ProjectRepo {
|
|
|
92
92
|
/**
|
|
93
93
|
* プロジェクト検索
|
|
94
94
|
*/
|
|
95
|
-
projectFields(conditions, inclusion
|
|
96
|
-
// exclusion: IKeyOfProjection[] // discontinue(2024-10-09~)
|
|
97
|
-
) {
|
|
95
|
+
projectFields(conditions, inclusion) {
|
|
98
96
|
var _a;
|
|
99
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
98
|
const andConditions = ProjectRepo.CREATE_MONGO_CONDITIONS(conditions);
|
|
@@ -33,7 +33,9 @@ interface IUnset {
|
|
|
33
33
|
[key: string]: 1;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
type ISellerByAggregate = Pick<ISellerWithId, 'additionalProperty' | 'branchCode' | '
|
|
36
|
+
type ISellerByAggregate = Pick<ISellerWithId, 'additionalProperty' | 'branchCode' | 'id' | 'name' | 'project' | 'telephone' | 'typeOf' | 'url'> & {
|
|
37
|
+
hasMerchantReturnPolicy?: Pick<factory.seller.ISellerMerchantReturnPolicy, 'typeOf' | 'url'>[];
|
|
38
|
+
};
|
|
37
39
|
interface IMemberSearchConditions {
|
|
38
40
|
/**
|
|
39
41
|
* 販売者メンバーで絞る場合
|
|
@@ -56,7 +58,7 @@ export declare class SellerRepo {
|
|
|
56
58
|
private readonly sellerModel;
|
|
57
59
|
constructor(connection: Connection);
|
|
58
60
|
static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions & IMemberSearchConditions): FilterQuery<factory.seller.ISeller>[];
|
|
59
|
-
static CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
61
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(exclusion: (keyof ISellerByAggregate)[]): {
|
|
60
62
|
[field: string]: AnyExpression;
|
|
61
63
|
};
|
|
62
64
|
/**
|
|
@@ -71,7 +73,7 @@ export declare class SellerRepo {
|
|
|
71
73
|
/**
|
|
72
74
|
* 集計検索(publicな属性検索が目的)
|
|
73
75
|
*/
|
|
74
|
-
searchByAggregate(conditions: factory.seller.ISearchConditions & IMemberSearchConditions,
|
|
76
|
+
searchByAggregate(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, exclusion: (keyof ISellerByAggregate)[]): Promise<ISellerByAggregate[]>;
|
|
75
77
|
/**
|
|
76
78
|
* 販売者検索
|
|
77
79
|
*/
|
|
@@ -157,7 +157,9 @@ class SellerRepo {
|
|
|
157
157
|
}
|
|
158
158
|
return andConditions;
|
|
159
159
|
}
|
|
160
|
-
static CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
160
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
161
|
+
// inclusion: string[], // discontinue(2024-10-20~)
|
|
162
|
+
exclusion) {
|
|
161
163
|
const projectStage = {
|
|
162
164
|
_id: 0,
|
|
163
165
|
id: { $toString: '$_id' },
|
|
@@ -185,10 +187,10 @@ class SellerRepo {
|
|
|
185
187
|
url: '$url',
|
|
186
188
|
telephone: '$telephone'
|
|
187
189
|
};
|
|
188
|
-
if (inclusion.length > 0) {
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
190
|
+
// if (inclusion.length > 0) {
|
|
191
|
+
// // no op
|
|
192
|
+
// } else
|
|
193
|
+
if (exclusion.length > 0) {
|
|
192
194
|
exclusion.forEach((field) => {
|
|
193
195
|
if (typeof projectStage[field] === 'string' || typeof projectStage[field] === 'object') {
|
|
194
196
|
// tslint:disable-next-line:no-dynamic-delete
|
|
@@ -247,12 +249,15 @@ class SellerRepo {
|
|
|
247
249
|
/**
|
|
248
250
|
* 集計検索(publicな属性検索が目的)
|
|
249
251
|
*/
|
|
250
|
-
searchByAggregate(conditions,
|
|
252
|
+
searchByAggregate(conditions,
|
|
253
|
+
// inclusion: (keyof ISellerByAggregate)[], // discontinue(2024-10-20~)
|
|
254
|
+
exclusion) {
|
|
251
255
|
var _a;
|
|
252
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
253
257
|
const matchStages = SellerRepo.CREATE_MONGO_CONDITIONS(conditions)
|
|
254
258
|
.map((c) => ({ $match: c }));
|
|
255
|
-
const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(inclusion, exclusion);
|
|
259
|
+
// const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(inclusion, exclusion);
|
|
260
|
+
const projectStage = SellerRepo.CREATE_AGGREGATE_SELLERS_PROJECTION(exclusion);
|
|
256
261
|
const sortByBranchCode = (_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.branchCode;
|
|
257
262
|
const aggregate = this.sellerModel.aggregate([
|
|
258
263
|
...matchStages,
|
|
@@ -86,7 +86,6 @@ function start(params) {
|
|
|
86
86
|
const project = yield repos.project.findById({
|
|
87
87
|
id: params.project.id,
|
|
88
88
|
inclusion: ['typeOf']
|
|
89
|
-
// exclusion: []
|
|
90
89
|
});
|
|
91
90
|
const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
|
|
92
91
|
const transactionNumber = params.transactionNumber;
|
|
@@ -142,7 +141,6 @@ function startAndConfirm(params) {
|
|
|
142
141
|
const project = yield repos.project.findById({
|
|
143
142
|
id: params.project.id,
|
|
144
143
|
inclusion: ['typeOf']
|
|
145
|
-
// exclusion: []
|
|
146
144
|
});
|
|
147
145
|
const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
|
|
148
146
|
const transactionNumber = params.transactionNumber;
|
|
@@ -25,7 +25,6 @@ function authorize(params) {
|
|
|
25
25
|
const project = yield repos.project.findById({
|
|
26
26
|
id: params.project.id,
|
|
27
27
|
inclusion: ['settings', 'typeOf']
|
|
28
|
-
// exclusion: []
|
|
29
28
|
});
|
|
30
29
|
const transaction = yield repos.assetTransaction.findById({
|
|
31
30
|
typeOf: params.purpose.typeOf,
|
|
@@ -31,7 +31,6 @@ function sendEmailMessage(params) {
|
|
|
31
31
|
const project = yield repos.project.findById({
|
|
32
32
|
id: params.project.id,
|
|
33
33
|
inclusion: ['settings']
|
|
34
|
-
// exclusion: []
|
|
35
34
|
});
|
|
36
35
|
const action = yield repos.action.start(createSendEmailMessageActionAttributes(params));
|
|
37
36
|
let result = {};
|
|
@@ -22,11 +22,6 @@ const onRefund_1 = require("./any/onRefund");
|
|
|
22
22
|
const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
|
|
23
23
|
function authorize(params, paymentServiceId) {
|
|
24
24
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
// const project = <Pick<factory.project.IProject, 'id' | 'typeOf'>>await repos.project.findById({
|
|
26
|
-
// id: params.project.id,
|
|
27
|
-
// inclusion: ['_id', 'typeOf'],
|
|
28
|
-
// exclusion: []
|
|
29
|
-
// });
|
|
30
25
|
var _a;
|
|
31
26
|
const transactionNumber = params.transactionNumber;
|
|
32
27
|
if (typeof transactionNumber !== 'string') {
|
|
@@ -44,7 +44,6 @@ function findByCode(params) {
|
|
|
44
44
|
const reservationFromRepo = yield repos.reservation.projectFieldsById({
|
|
45
45
|
id: reservationId,
|
|
46
46
|
inclusion: ['additionalTicketText', 'checkedIn', 'reservationStatus', 'reservedTicket']
|
|
47
|
-
// exclusion: [] // discontinue(2024-08-08~)
|
|
48
47
|
});
|
|
49
48
|
const { id, additionalTicketText, checkedIn, reservationStatus, reservedTicket } = reservationFromRepo;
|
|
50
49
|
const reservation = Object.assign(Object.assign({ id, reservationStatus, reservedTicket: {
|
|
@@ -97,7 +97,6 @@ function deleteById(params) {
|
|
|
97
97
|
const project = yield repos.project.findById({
|
|
98
98
|
id: params.project.id,
|
|
99
99
|
inclusion: ['settings']
|
|
100
|
-
// exclusion: []
|
|
101
100
|
});
|
|
102
101
|
// const useUsernameAsGMOMemberId = project.settings?.useUsernameAsGMOMemberId === true;
|
|
103
102
|
// 移行の場合、全所有権情報通知タスクを作成
|
|
@@ -79,7 +79,6 @@ function preStart(params) {
|
|
|
79
79
|
const { hasMerchantReturnPolicy } = yield repos.project.findById({
|
|
80
80
|
id: seller.project.id,
|
|
81
81
|
inclusion: ['hasMerchantReturnPolicy']
|
|
82
|
-
// exclusion: []
|
|
83
82
|
});
|
|
84
83
|
const appliedReturnPolicy = yield findApplicableReturnPolicy(Object.assign({ acceptedOffers,
|
|
85
84
|
events,
|
package/package.json
CHANGED