@chevre/domain 22.11.0-alpha.1 → 22.11.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.
- package/example/src/chevre/checkProjectMembers.ts +55 -0
- package/example/src/chevre/settings/addSettings.ts +32 -0
- package/lib/chevre/repo/setting.d.ts +9 -0
- package/lib/chevre/repo/setting.js +9 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +22 -14
- package/package.json +3 -3
- package/example/src/chevre/checkActions.ts +0 -65
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// tslint:disable-next-line:max-func-body-length
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = memberRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
'member.memberOf.typeOf': { $eq: 'Project' },
|
|
15
|
+
'member.typeOf': { $eq: 'Person' }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
_id: 1,
|
|
19
|
+
member: 1,
|
|
20
|
+
project: 1
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
console.log('docs found');
|
|
24
|
+
|
|
25
|
+
let i = 0;
|
|
26
|
+
let sellerMemberCount = 0;
|
|
27
|
+
await cursor.eachAsync(async (doc) => {
|
|
28
|
+
i += 1;
|
|
29
|
+
const member = <Pick<chevre.factory.iam.IMember, 'member' | 'project'>>doc.toObject();
|
|
30
|
+
|
|
31
|
+
console.log('checking...', member.project.id, member.member?.id, i);
|
|
32
|
+
const sellerMembers = await memberRepo.projectFieldsByProjectId(
|
|
33
|
+
{ id: member.project.id },
|
|
34
|
+
{
|
|
35
|
+
member: {
|
|
36
|
+
id: { $eq: member.member.id },
|
|
37
|
+
typeOf: { $eq: 'Person' },
|
|
38
|
+
memberOf: { typeOf: { $eq: chevre.factory.organizationType.Corporation } }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
['member']
|
|
42
|
+
);
|
|
43
|
+
console.log(sellerMembers.length, 'sellerMember found', member.project.id, member.member?.id, i);
|
|
44
|
+
if (sellerMembers.length > 0) {
|
|
45
|
+
sellerMemberCount += 1;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
console.log(i, 'docs checked');
|
|
50
|
+
console.log(sellerMemberCount, 'members sellerMember');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
main()
|
|
54
|
+
.then()
|
|
55
|
+
.catch(console.error);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
|
|
12
|
+
const useInformReturnAction = (<any>setting)?.onOrderStatusChanged?.useInformReturnAction === true;
|
|
13
|
+
if (useInformReturnAction) {
|
|
14
|
+
console.log('already useInformReturnAction:true');
|
|
15
|
+
} else {
|
|
16
|
+
// update
|
|
17
|
+
await settingRepo.updateByProject4migration(
|
|
18
|
+
{ project: { id: { $eq: '*' } } },
|
|
19
|
+
{
|
|
20
|
+
$set: {
|
|
21
|
+
'onOrderStatusChanged.useInformReturnAction': true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
console.log('updated.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then()
|
|
32
|
+
.catch(console.error);
|
|
@@ -23,4 +23,13 @@ export declare class SettingRepo {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
}, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onResourceUpdated' | 'defaultSenderEmail' | 'useInformResourceTypes' | 'userPoolIdNew' | 'userPoolIdOld' | 'storage' | 'quota' | 'triggerWebhook' | 'waiter'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
26
|
+
updateByProject4migration(filter: {
|
|
27
|
+
project: {
|
|
28
|
+
id: {
|
|
29
|
+
$eq: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}, update: {
|
|
33
|
+
$set: any;
|
|
34
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
26
35
|
}
|
|
@@ -56,5 +56,14 @@ class SettingRepo {
|
|
|
56
56
|
.exec();
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
+
updateByProject4migration(filter, update) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const { $set } = update;
|
|
62
|
+
return this.settingModel.updateOne({ 'project.id': { $eq: filter.project.id.$eq } }, {
|
|
63
|
+
$set
|
|
64
|
+
})
|
|
65
|
+
.exec();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
exports.SettingRepo = SettingRepo;
|
|
@@ -4,24 +4,22 @@ exports.createInformTasks = createInformTasks;
|
|
|
4
4
|
exports.createOnOrderReturnedTasksByTransaction = createOnOrderReturnedTasksByTransaction;
|
|
5
5
|
const factory = require("../../../../factory");
|
|
6
6
|
function createInformTasks(order, returnOrderAction, setting) {
|
|
7
|
-
var _a, _b
|
|
7
|
+
var _a, _b;
|
|
8
8
|
const taskRunsAt = new Date();
|
|
9
9
|
const informOrder = (_a = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
|
|
10
|
-
const useInformReturnAction = (
|
|
10
|
+
// const useInformReturnAction = (<any>setting)?.onOrderStatusChanged?.useInformReturnAction === true; // discontinue(2025-07-01~)
|
|
11
11
|
const informTasks = [];
|
|
12
|
-
// support returnAction4inform(2025-01-22~)
|
|
13
|
-
let informObject;
|
|
14
12
|
const informIdentifier = `${factory.order.OrderType.Order}:${order.orderNumber}:${factory.orderStatus.OrderReturned}`;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
else {
|
|
19
|
-
|
|
20
|
-
}
|
|
13
|
+
const informObject = createReturnAction4inform(returnOrderAction);
|
|
14
|
+
// if (useInformReturnAction) { // discontinue(2025-07-01~)
|
|
15
|
+
// informObject = createReturnAction4inform(returnOrderAction);
|
|
16
|
+
// } else {
|
|
17
|
+
// informObject = createOrder4inform(order);
|
|
18
|
+
// }
|
|
21
19
|
if (Array.isArray(informOrder) && informOrder.length > 0) {
|
|
22
20
|
let recipientId = '';
|
|
23
21
|
recipientId = order.customer.id;
|
|
24
|
-
if (typeof ((
|
|
22
|
+
if (typeof ((_b = order.returner) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
25
23
|
recipientId = order.returner.id;
|
|
26
24
|
}
|
|
27
25
|
informOrder.forEach((informOrderParams) => {
|
|
@@ -63,9 +61,19 @@ function createReturnAction4inform(returnOrderAction) {
|
|
|
63
61
|
const { id, instrument, object, project, typeOf } = returnOrderAction;
|
|
64
62
|
return Object.assign({ id, object, project, typeOf }, (Array.isArray(instrument)) ? { instrument } : undefined);
|
|
65
63
|
}
|
|
66
|
-
function createOrder4inform(
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
// function createOrder4inform(
|
|
65
|
+
// order: IReturnedOrder
|
|
66
|
+
// ): IOrder4inform {
|
|
67
|
+
// return {
|
|
68
|
+
// project: order.project,
|
|
69
|
+
// typeOf: order.typeOf,
|
|
70
|
+
// orderNumber: order.orderNumber,
|
|
71
|
+
// orderStatus: factory.orderStatus.OrderReturned,
|
|
72
|
+
// ...(order.dateReturned !== undefined) ? { dateReturned: order.dateReturned } : undefined,
|
|
73
|
+
// // ↓hub側で使用している可能性もあるので念のため
|
|
74
|
+
// ...(typeof order.id === 'string') ? { id: order.id } : undefined
|
|
75
|
+
// };
|
|
76
|
+
// }
|
|
69
77
|
/**
|
|
70
78
|
* 注文返品後のアクション
|
|
71
79
|
*/
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.395.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "11.0.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.395.0-alpha.2",
|
|
15
|
+
"@cinerino/sdk": "11.0.0-alpha.3",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"postversion": "git push origin --tags",
|
|
114
114
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
115
115
|
},
|
|
116
|
-
"version": "22.11.0-alpha.
|
|
116
|
+
"version": "22.11.0-alpha.2"
|
|
117
117
|
}
|
|
@@ -1,65 +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 CONSOLE_CLIENT_ID = 'xxx';
|
|
8
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
-
type IAction = chevre.factory.action.IAction<chevre.factory.action.IAttributes<chevre.factory.actionType, any, any>>;
|
|
10
|
-
|
|
11
|
-
// tslint:disable-next-line:max-func-body-length
|
|
12
|
-
async function main() {
|
|
13
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
-
|
|
15
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = actionRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
typeOf: { $eq: chevre.factory.actionType.CreateAction },
|
|
20
|
-
'object.typeOf': { $exists: true, $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
-
startDate: {
|
|
22
|
-
$gte: moment()
|
|
23
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
-
.add(-60, 'days')
|
|
25
|
-
.toDate()
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
console.log('actions found');
|
|
32
|
-
|
|
33
|
-
let i = 0;
|
|
34
|
-
await cursor.eachAsync(async (doc) => {
|
|
35
|
-
i += 1;
|
|
36
|
-
const action = <IAction>doc.toObject();
|
|
37
|
-
// const size = JSON.stringify(action).length;
|
|
38
|
-
// // console.log(JSON.stringify(action).length);
|
|
39
|
-
// if (action.typeOf !== chevre.factory.actionType.InformAction
|
|
40
|
-
// && action.typeOf !== chevre.factory.actionType.AuthorizeAction
|
|
41
|
-
// && action.typeOf !== chevre.factory.actionType.CheckAction
|
|
42
|
-
// && size > 2000) {
|
|
43
|
-
// console.log(action.typeOf, action.object?.typeOf);
|
|
44
|
-
// console.log(size);
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
|
-
const eventCount = (Array.isArray(action.result))
|
|
48
|
-
? action.result.filter(({ typeOf }) => typeOf === chevre.factory.eventType.ScreeningEvent)
|
|
49
|
-
.length
|
|
50
|
-
: 0;
|
|
51
|
-
if (action.instrument?.id !== CONSOLE_CLIENT_ID) {
|
|
52
|
-
console.log(eventCount, 'events created', action.project.id, action.startDate, action.instrument?.id, i);
|
|
53
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
54
|
-
if (eventCount > 10) {
|
|
55
|
-
throw new Error('eventCount too large');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
console.log(i, 'actions checked');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main()
|
|
64
|
-
.then()
|
|
65
|
-
.catch(console.error);
|