@chevre/domain 22.10.0-alpha.8 → 22.10.0
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/adminIdentities.ts +8 -8
- package/example/src/chevre/assetTransaction/processReserve.ts +4 -1
- package/example/src/chevre/concurrentLock/lockOfferRateLimit.ts +64 -0
- package/example/src/chevre/concurrentLock/lockTransactionProcess.ts +44 -0
- package/example/src/chevre/createTaskIfNotExistByAlternateName.ts +1 -1
- package/example/src/chevre/findOneAvailableHours.ts +39 -0
- package/example/src/chevre/identity/getCommonClients.ts +126 -0
- package/example/src/chevre/identity/migrateClients2oauth.ts +200 -0
- package/example/src/chevre/issuer/adminMemberProgramTiers.ts +55 -0
- package/example/src/chevre/maintenance/checkTransactionStatuses.ts +105 -0
- package/example/src/chevre/migrateIdentities.ts +24 -37
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +27 -0
- package/example/src/chevre/roles/addRoleMembers.ts +75 -0
- package/example/src/chevre/saveWebSite.ts +14 -17
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +43 -22
- package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +37 -0
- package/example/src/chevre/transactionNumber/publishOrderNumber.ts +40 -0
- package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +45 -0
- package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +41 -0
- package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +41 -0
- package/example/src/redisMulti.ts +63 -0
- package/example/src/signPayload.ts +1 -1
- package/lib/chevre/eventEmitter/task.d.ts +36 -6
- package/lib/chevre/eventEmitter/task.js +5 -4
- package/lib/chevre/eventEmitter.d.ts +2 -2
- package/lib/chevre/eventEmitter.js +2 -2
- package/lib/chevre/repo/concurrentLock.d.ts +14 -0
- package/lib/chevre/repo/concurrentLock.js +48 -0
- package/lib/chevre/repo/concurrentLockAbstract.d.ts +42 -0
- package/lib/chevre/repo/concurrentLockAbstract.js +9 -0
- package/lib/chevre/repo/confirmationNumber.d.ts +17 -4
- package/lib/chevre/repo/confirmationNumber.js +89 -32
- package/lib/chevre/repo/identity.d.ts +42 -5
- package/lib/chevre/repo/identity.js +35 -4
- package/lib/chevre/repo/issuer.d.ts +10 -2
- package/lib/chevre/repo/member.js +2 -2
- package/lib/chevre/repo/memberProgram.d.ts +43 -2
- package/lib/chevre/repo/memberProgram.js +79 -8
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +3 -1
- package/lib/chevre/repo/mongoose/schemas/issuer.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/offer/event.js +30 -2
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +2 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +11 -1
- package/lib/chevre/repo/mongoose/schemas/service/availableHour.d.ts +18 -0
- package/lib/chevre/repo/mongoose/schemas/service/availableHour.js +65 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +4 -1
- package/lib/chevre/repo/mongoose/schemas/transactionNumber.d.ts +39 -0
- package/lib/chevre/repo/mongoose/schemas/transactionNumber.js +101 -0
- package/lib/chevre/repo/orderNumber.d.ts +15 -4
- package/lib/chevre/repo/orderNumber.js +71 -24
- package/lib/chevre/repo/passport.d.ts +1 -1
- package/lib/chevre/repo/passport.js +31 -13
- package/lib/chevre/repo/rateLimit/offer.d.ts +7 -2
- package/lib/chevre/repo/rateLimit/offer.js +41 -40
- package/lib/chevre/repo/role.d.ts +18 -4
- package/lib/chevre/repo/role.js +53 -4
- package/lib/chevre/repo/service/availableHour.d.ts +15 -0
- package/lib/chevre/repo/service/availableHour.js +53 -0
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +8 -4
- package/lib/chevre/repo/serviceOutputIdentifier.js +54 -22
- package/lib/chevre/repo/stockHolder.d.ts +0 -2
- package/lib/chevre/repo/stockHolder.js +24 -31
- package/lib/chevre/repo/task.d.ts +10 -25
- package/lib/chevre/repo/task.js +65 -36
- package/lib/chevre/repo/transactionNumber.d.ts +15 -4
- package/lib/chevre/repo/transactionNumber.js +67 -22
- package/lib/chevre/repo/transactionNumberCounter.d.ts +28 -0
- package/lib/chevre/repo/transactionNumberCounter.js +128 -0
- package/lib/chevre/repo/transactionProcess.d.ts +7 -4
- package/lib/chevre/repo/transactionProcess.js +34 -13
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +14 -1
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +1 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +9 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +1 -1
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/offer/event/checkAvailability.d.ts +1 -1
- package/lib/chevre/service/offer/event/checkAvailability.js +1 -0
- package/lib/chevre/service/offer/product.js +0 -40
- package/lib/chevre/service/payment/any.d.ts +0 -2
- package/lib/chevre/service/payment/any.js +1 -0
- package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -0
- package/lib/chevre/service/reserve/cancelReservation.js +5 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +2 -2
- package/lib/chevre/service/task/authorizePayment.js +4 -4
- package/lib/chevre/service/task/givePointAward.js +1 -1
- package/lib/chevre/service/task/moneyTransfer.js +1 -1
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -2
- package/lib/chevre/service/task/refund.js +1 -1
- package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnPointAward.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task.d.ts +8 -17
- package/lib/chevre/service/task.js +14 -5
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart/factory.d.ts +20 -0
- package/lib/chevre/service/transaction/returnOrder/preStart/factory.js +2 -0
- package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.d.ts +23 -0
- package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.js +323 -0
- package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.d.ts +13 -0
- package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +132 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +2 -391
- package/package.json +3 -3
- package/example/src/chevre/migrateMembers2identities.ts +0 -109
- package/example/src/chevre/publishConfimationNumber.ts +0 -27
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
const now = new Date();
|
|
11
|
+
console.log('--------', 'aggregating...', ' --------', now);
|
|
12
|
+
|
|
13
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
14
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
15
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
// {status:"InProgress"}を確認
|
|
18
|
+
// {"tasksExportAction.actionStatus":{$ne:"CompletedActionStatus"}}を確認
|
|
19
|
+
|
|
20
|
+
for (const transactionType of [
|
|
21
|
+
chevre.factory.transactionType.PlaceOrder,
|
|
22
|
+
chevre.factory.transactionType.ReturnOrder
|
|
23
|
+
]) {
|
|
24
|
+
const inProgressCount = await transactionRepo.count({
|
|
25
|
+
limit: 1000,
|
|
26
|
+
status: { $in: [chevre.factory.transactionStatusType.InProgress] },
|
|
27
|
+
typeOf: transactionType
|
|
28
|
+
});
|
|
29
|
+
console.log(transactionType, 'inProgressCount:', inProgressCount.count, now);
|
|
30
|
+
|
|
31
|
+
const unCompletedTasksExportCount = await transactionRepo.count({
|
|
32
|
+
limit: 1000,
|
|
33
|
+
tasksExportAction: {
|
|
34
|
+
actionStatus: {
|
|
35
|
+
$in: [
|
|
36
|
+
chevre.factory.actionStatusType.ActiveActionStatus,
|
|
37
|
+
chevre.factory.actionStatusType.CanceledActionStatus,
|
|
38
|
+
chevre.factory.actionStatusType.FailedActionStatus,
|
|
39
|
+
chevre.factory.actionStatusType.PotentialActionStatus
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
typeOf: transactionType
|
|
44
|
+
});
|
|
45
|
+
console.log(transactionType, 'unCompletedTasksExportCount:', unCompletedTasksExportCount.count, now);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (const assetTransactionType of [
|
|
49
|
+
chevre.factory.assetTransactionType.Pay,
|
|
50
|
+
chevre.factory.assetTransactionType.Refund,
|
|
51
|
+
chevre.factory.assetTransactionType.Reserve,
|
|
52
|
+
chevre.factory.assetTransactionType.CancelReservation
|
|
53
|
+
]) {
|
|
54
|
+
const inProgressCount = await assetTransactionRepo.count({
|
|
55
|
+
limit: 1000,
|
|
56
|
+
status: { $in: [chevre.factory.transactionStatusType.InProgress] },
|
|
57
|
+
typeOf: <any>assetTransactionType
|
|
58
|
+
});
|
|
59
|
+
console.log(assetTransactionType, 'inProgressCount:', inProgressCount.count, now);
|
|
60
|
+
|
|
61
|
+
const unCompletedTasksExportCount = await assetTransactionRepo.count({
|
|
62
|
+
limit: 1000,
|
|
63
|
+
tasksExportAction: {
|
|
64
|
+
actionStatus: {
|
|
65
|
+
$in: [
|
|
66
|
+
chevre.factory.actionStatusType.ActiveActionStatus,
|
|
67
|
+
chevre.factory.actionStatusType.CanceledActionStatus,
|
|
68
|
+
chevre.factory.actionStatusType.FailedActionStatus,
|
|
69
|
+
chevre.factory.actionStatusType.PotentialActionStatus
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
typeOf: <any>assetTransactionType
|
|
74
|
+
});
|
|
75
|
+
console.log(assetTransactionType, 'unCompletedTasksExportCount:', unCompletedTasksExportCount.count, now);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const readyTaskCount = await taskRepo.count({
|
|
79
|
+
limit: 100,
|
|
80
|
+
statuses: [
|
|
81
|
+
chevre.factory.taskStatus.Ready,
|
|
82
|
+
chevre.factory.taskStatus.Running
|
|
83
|
+
],
|
|
84
|
+
name: {
|
|
85
|
+
$nin: [
|
|
86
|
+
chevre.factory.taskName.ImportEventCapacitiesFromCOA,
|
|
87
|
+
chevre.factory.taskName.ImportEventsFromCOA,
|
|
88
|
+
chevre.factory.taskName.ImportOffersFromCOA
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
runsThrough: now
|
|
92
|
+
});
|
|
93
|
+
console.log('readyTaskCount:', readyTaskCount.count, now);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const INTERVAL_MS = 60000;
|
|
97
|
+
// const INTERVAL_MS = 5000;
|
|
98
|
+
setInterval(
|
|
99
|
+
() => {
|
|
100
|
+
main()
|
|
101
|
+
.then()
|
|
102
|
+
.catch(console.error);
|
|
103
|
+
},
|
|
104
|
+
INTERVAL_MS
|
|
105
|
+
);
|
|
@@ -11,23 +11,17 @@ async function main() {
|
|
|
11
11
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
12
|
|
|
13
13
|
const identityRepo = await chevre.repository.Identity.createInstance(mongoose.connection);
|
|
14
|
-
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
15
14
|
|
|
16
|
-
const cursor =
|
|
15
|
+
const cursor = identityRepo.getCursor(
|
|
17
16
|
{
|
|
18
|
-
'
|
|
19
|
-
$in: [
|
|
20
|
-
chevre.factory.creativeWorkType.WebApplication
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
'project.id': { $ne: '*' }
|
|
24
|
-
// _id: { $eq: '5f9a4fed4f3709000abe6415' }
|
|
17
|
+
// _id: { $eq: '67de46777ec0510590b68922' }
|
|
25
18
|
},
|
|
26
19
|
{
|
|
27
20
|
_id: 1,
|
|
28
|
-
|
|
21
|
+
about: 1,
|
|
29
22
|
project: 1,
|
|
30
|
-
typeOf: 1
|
|
23
|
+
typeOf: 1,
|
|
24
|
+
issuedBy: 1
|
|
31
25
|
}
|
|
32
26
|
);
|
|
33
27
|
console.log('docs found');
|
|
@@ -36,40 +30,33 @@ async function main() {
|
|
|
36
30
|
let updateCount = 0;
|
|
37
31
|
await cursor.eachAsync(async (doc) => {
|
|
38
32
|
i += 1;
|
|
39
|
-
const
|
|
40
|
-
chevre.factory.
|
|
41
|
-
'
|
|
33
|
+
const identity: Pick<
|
|
34
|
+
chevre.factory.creativeWork.certification.webApplication.ICertification,
|
|
35
|
+
'about' | 'project' | 'typeOf' | 'id' | 'issuedBy'
|
|
42
36
|
> = doc.toObject();
|
|
43
37
|
|
|
38
|
+
const issuedBy = identity.issuedBy;
|
|
39
|
+
const numIssuedBy = (Array.isArray(identity.issuedBy)) ? identity.issuedBy.length : 1;
|
|
40
|
+
|
|
44
41
|
// console.log(
|
|
45
|
-
// 'alreadyMigrated?',
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const clientId = iamMember.member.id;
|
|
49
|
-
const existingIdentity = (await identityRepo.projectFields(
|
|
50
|
-
{
|
|
51
|
-
limit: 1,
|
|
52
|
-
page: 1,
|
|
53
|
-
project: { id: { $eq: iamMember.project.id } },
|
|
54
|
-
about: { id: { $eq: clientId } }
|
|
55
|
-
},
|
|
56
|
-
['issuedBy']
|
|
57
|
-
)).shift();
|
|
58
|
-
if (existingIdentity !== undefined) {
|
|
59
|
-
alreadyMigrated = true;
|
|
60
|
-
}
|
|
61
|
-
} catch (error) {
|
|
62
|
-
// no op
|
|
63
|
-
}
|
|
42
|
+
// 'alreadyMigrated?', identity.project.id, identity.about.id, numIssuedBy, i);
|
|
43
|
+
const alreadyMigrated = Array.isArray(issuedBy);
|
|
64
44
|
|
|
65
45
|
if (alreadyMigrated) {
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
console.log(
|
|
47
|
+
'already migrated.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
|
|
68
48
|
} else {
|
|
69
|
-
|
|
49
|
+
if (typeof identity.id !== 'string') {
|
|
50
|
+
throw new Error(`id undefined ${identity.id}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
await identityRepo.updateIssuedBy2array({
|
|
54
|
+
id: identity.id,
|
|
55
|
+
issuedBy: [issuedBy]
|
|
56
|
+
});
|
|
70
57
|
updateCount += 1;
|
|
71
58
|
console.log(
|
|
72
|
-
'updated.',
|
|
59
|
+
'updated.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
|
|
73
60
|
}
|
|
74
61
|
});
|
|
75
62
|
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.Issuer.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -0,0 +1,27 @@
|
|
|
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 roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
13
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
|
+
];
|
|
16
|
+
for (const roleName of roleNames) {
|
|
17
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
18
|
+
roleName: { $eq: roleName },
|
|
19
|
+
permission: 'eventOffers.*'
|
|
20
|
+
});
|
|
21
|
+
console.log(result, roleName);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
main()
|
|
26
|
+
.then()
|
|
27
|
+
.catch(console.error);
|
|
@@ -0,0 +1,75 @@
|
|
|
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 roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
let roleNames = [
|
|
12
|
+
chevre.factory.role.organizationRole.RoleName.Customer,
|
|
13
|
+
chevre.factory.role.organizationRole.RoleName.EventsViewer,
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.POS
|
|
15
|
+
];
|
|
16
|
+
for (const roleName of roleNames) {
|
|
17
|
+
const result = await roleRepo.addMember({
|
|
18
|
+
roleName,
|
|
19
|
+
member: { typeOf: chevre.factory.creativeWorkType.WebApplication },
|
|
20
|
+
memberOf: { typeOf: chevre.factory.organizationType.Project }
|
|
21
|
+
});
|
|
22
|
+
console.log(result, roleName);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
roleNames = [
|
|
26
|
+
chevre.factory.role.organizationRole.RoleName.Server
|
|
27
|
+
];
|
|
28
|
+
for (const roleName of roleNames) {
|
|
29
|
+
const result = await roleRepo.addMember({
|
|
30
|
+
roleName,
|
|
31
|
+
member: { typeOf: chevre.factory.creativeWorkType.SoftwareApplication },
|
|
32
|
+
memberOf: { typeOf: chevre.factory.organizationType.Project }
|
|
33
|
+
});
|
|
34
|
+
console.log(result, roleName);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
roleNames = [
|
|
38
|
+
chevre.factory.role.organizationRole.RoleName.Accountant,
|
|
39
|
+
chevre.factory.role.organizationRole.RoleName.IAMRoleAdmin,
|
|
40
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
41
|
+
chevre.factory.role.organizationRole.RoleName.MemberAdmin,
|
|
42
|
+
chevre.factory.role.organizationRole.RoleName.Owner,
|
|
43
|
+
chevre.factory.role.organizationRole.RoleName.PaymentServiceAdmin,
|
|
44
|
+
chevre.factory.role.organizationRole.RoleName.SellerAdmin,
|
|
45
|
+
chevre.factory.role.organizationRole.RoleName.TicketClerk,
|
|
46
|
+
chevre.factory.role.organizationRole.RoleName.TicketCollector,
|
|
47
|
+
chevre.factory.role.organizationRole.RoleName.User
|
|
48
|
+
];
|
|
49
|
+
for (const roleName of roleNames) {
|
|
50
|
+
const result = await roleRepo.addMember({
|
|
51
|
+
roleName,
|
|
52
|
+
member: { typeOf: chevre.factory.personType.Person },
|
|
53
|
+
memberOf: { typeOf: chevre.factory.organizationType.Project }
|
|
54
|
+
});
|
|
55
|
+
console.log(result, roleName);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
roleNames = [
|
|
59
|
+
chevre.factory.role.organizationRole.RoleName.SellersIAMRoleAdmin,
|
|
60
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
61
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner
|
|
62
|
+
];
|
|
63
|
+
for (const roleName of roleNames) {
|
|
64
|
+
const result = await roleRepo.addMember({
|
|
65
|
+
roleName,
|
|
66
|
+
member: { typeOf: chevre.factory.personType.Person },
|
|
67
|
+
memberOf: { typeOf: chevre.factory.organizationType.Corporation }
|
|
68
|
+
});
|
|
69
|
+
console.log(result, roleName);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then()
|
|
75
|
+
.catch(console.error);
|
|
@@ -3,7 +3,8 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const project = { id: '*' };
|
|
7
|
+
const WEBSITE_IDENTIFIER = process.env.WEBSITE_IDENTIFIER;
|
|
7
8
|
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
9
|
|
|
9
10
|
// tslint:disable-next-line:max-func-body-length
|
|
@@ -12,26 +13,22 @@ async function main() {
|
|
|
12
13
|
|
|
13
14
|
const webSiteRepo = await chevre.repository.WebSite.createInstance(mongoose.connection);
|
|
14
15
|
|
|
16
|
+
if (typeof WEBSITE_IDENTIFIER !== 'string') {
|
|
17
|
+
throw new Error('WEBSITE_IDENTIFIER undefined');
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
const creatingWebSites: Pick<
|
|
16
21
|
chevre.factory.creativeWork.certification.webSite.ICertification,
|
|
17
22
|
'about' | 'certificationStatus' | 'project' | 'auditDate'
|
|
18
23
|
>[] = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// {
|
|
28
|
-
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
29
|
-
// about: {
|
|
30
|
-
// identifier: 'xxx',
|
|
31
|
-
// typeOf: chevre.factory.creativeWorkType.WebSite
|
|
32
|
-
// },
|
|
33
|
-
// certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationInactive
|
|
34
|
-
// }
|
|
24
|
+
{
|
|
25
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
26
|
+
about: {
|
|
27
|
+
identifier: WEBSITE_IDENTIFIER,
|
|
28
|
+
typeOf: chevre.factory.creativeWorkType.WebSite
|
|
29
|
+
},
|
|
30
|
+
certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationInactive
|
|
31
|
+
}
|
|
35
32
|
];
|
|
36
33
|
for (const creatingWebSite of creatingWebSites) {
|
|
37
34
|
console.log('updating...', creatingWebSite);
|
|
@@ -15,7 +15,8 @@ const client = redis.createClient<redis.RedisDefaultModules, Record<string, neve
|
|
|
15
15
|
port: Number(<string>process.env.REDIS_PORT),
|
|
16
16
|
host: <string>process.env.REDIS_HOST
|
|
17
17
|
},
|
|
18
|
-
password: <string>process.env.REDIS_KEY
|
|
18
|
+
password: <string>process.env.REDIS_KEY,
|
|
19
|
+
name: 'checkRedisKeyCount'
|
|
19
20
|
})
|
|
20
21
|
.on('error', (err) => {
|
|
21
22
|
// eslint-disable-next-line no-console
|
|
@@ -39,7 +40,10 @@ function countRedisKeyByProject(params: {
|
|
|
39
40
|
$eq: params.project.id
|
|
40
41
|
// $in: useMongoAsStockHolderProjects
|
|
41
42
|
},
|
|
42
|
-
startDate: {
|
|
43
|
+
// startDate: {
|
|
44
|
+
// $gte: params.now
|
|
45
|
+
// },
|
|
46
|
+
endDate: {
|
|
43
47
|
$gte: params.now
|
|
44
48
|
},
|
|
45
49
|
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
@@ -81,13 +85,14 @@ function countRedisKeyByProject(params: {
|
|
|
81
85
|
console.log(i, 'events checked');
|
|
82
86
|
console.log(redisKeyCount, 'redisKeys found');
|
|
83
87
|
|
|
84
|
-
return { checkedCount: i, redisKeyCount };
|
|
88
|
+
return { checkedCount: i, redisKeyCount, eventsWithRedis };
|
|
85
89
|
};
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
// tslint:disable-next-line:max-func-body-length
|
|
89
93
|
async function main() {
|
|
90
94
|
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
95
|
+
const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
|
|
91
96
|
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
92
97
|
const stockHolderRepo = await chevre.repository.StockHolder.createInstance(
|
|
93
98
|
client,
|
|
@@ -96,10 +101,23 @@ async function main() {
|
|
|
96
101
|
|
|
97
102
|
const setting = await settingRepo.findOne(
|
|
98
103
|
{ project: { id: { $eq: '*' } } },
|
|
99
|
-
['useMongoAsStockHolderProjects']
|
|
104
|
+
['useMongoAsStockHolderProjects', 'useMongoAsStockHolder']
|
|
100
105
|
);
|
|
101
|
-
const
|
|
106
|
+
const useMongoAsStockHolder = setting?.useMongoAsStockHolder === true;
|
|
107
|
+
let useMongoAsStockHolderProjects =
|
|
102
108
|
(Array.isArray(setting?.useMongoAsStockHolderProjects)) ? setting?.useMongoAsStockHolderProjects : [];
|
|
109
|
+
if (useMongoAsStockHolder) {
|
|
110
|
+
// 全プロジェクト
|
|
111
|
+
useMongoAsStockHolderProjects = (await projectRepo.projectFields(
|
|
112
|
+
{
|
|
113
|
+
// id: { $eq: 'xxx' }
|
|
114
|
+
},
|
|
115
|
+
['id']
|
|
116
|
+
)).map(({ id }) => id);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
useMongoAsStockHolderProjects = useMongoAsStockHolderProjects.filter((id) => id.slice(0, 6) !== 'sskts-');
|
|
120
|
+
|
|
103
121
|
const results: {
|
|
104
122
|
project: { id: string };
|
|
105
123
|
checkedCount: number;
|
|
@@ -122,15 +140,16 @@ async function main() {
|
|
|
122
140
|
checkedCount,
|
|
123
141
|
redisKeyCount
|
|
124
142
|
});
|
|
143
|
+
// console.log(eventsWithRedis);
|
|
125
144
|
}
|
|
126
145
|
|
|
127
146
|
const header = util.format(
|
|
128
147
|
'| %s | %s | %s | %s |\n| %s | %s | %s | %s |',
|
|
129
|
-
`project `.slice(0,
|
|
148
|
+
`project `.slice(0, 40),
|
|
130
149
|
`now `.slice(0, 24),
|
|
131
150
|
`checkedCount `.slice(0, 24),
|
|
132
151
|
`redisKeyCount `.slice(0, 24),
|
|
133
|
-
|
|
152
|
+
`---------------------------------------- `.slice(0, 40),
|
|
134
153
|
`------------------------ `.slice(0, 24),
|
|
135
154
|
`------------------------ `.slice(0, 24),
|
|
136
155
|
`------------------------ `.slice(0, 24)
|
|
@@ -142,7 +161,7 @@ async function main() {
|
|
|
142
161
|
results.map((result) => {
|
|
143
162
|
return util.format(
|
|
144
163
|
'| %s | %s | %s | %s |',
|
|
145
|
-
`${result.project.id} `.slice(0,
|
|
164
|
+
`${result.project.id} `.slice(0, 40),
|
|
146
165
|
`${now.toISOString()} `.slice(0, 24),
|
|
147
166
|
`${result.checkedCount} `.slice(0, 24),
|
|
148
167
|
`${result.redisKeyCount} `.slice(0, 24)
|
|
@@ -153,20 +172,22 @@ async function main() {
|
|
|
153
172
|
console.log(text);
|
|
154
173
|
|
|
155
174
|
// backlogへ通知
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
if (typeof BACKLOG_API_KEY === 'string') {
|
|
176
|
+
console.log('notifying on backlog...');
|
|
177
|
+
await fetch(
|
|
178
|
+
BACKLOG_NOTIFY_URL,
|
|
179
|
+
{
|
|
180
|
+
method: 'POST',
|
|
181
|
+
headers: new Headers({ 'Content-Type': 'application/json' }),
|
|
182
|
+
body: JSON.stringify({
|
|
183
|
+
content: text,
|
|
184
|
+
notifiedUserId: []
|
|
185
|
+
// notifiedUserId: users.map((user) => user.id)
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
console.log('posted to backlog.');
|
|
190
|
+
}
|
|
170
191
|
}
|
|
171
192
|
|
|
172
193
|
main()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
9
|
+
socket: {
|
|
10
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
11
|
+
host: <string>process.env.REDIS_HOST
|
|
12
|
+
},
|
|
13
|
+
password: <string>process.env.REDIS_KEY,
|
|
14
|
+
name: 'checkRedisKeyCount'
|
|
15
|
+
})
|
|
16
|
+
.on('error', (err) => {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.error('createDefaultRedisClient: client onError:', err);
|
|
19
|
+
// reject(err);
|
|
20
|
+
});
|
|
21
|
+
redisClient.connect();
|
|
22
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
const confirmationNumberRepo = await chevre.repository.ConfirmationNumber.createInstance({
|
|
26
|
+
redisClient,
|
|
27
|
+
connection: mongoose.connection
|
|
28
|
+
});
|
|
29
|
+
const result = await confirmationNumberRepo.publish({ orderDate: new Date() });
|
|
30
|
+
console.log(result);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main()
|
|
34
|
+
.then(() => {
|
|
35
|
+
console.log('success!');
|
|
36
|
+
})
|
|
37
|
+
.catch(console.error);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
9
|
+
socket: {
|
|
10
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
11
|
+
host: <string>process.env.REDIS_HOST
|
|
12
|
+
},
|
|
13
|
+
password: <string>process.env.REDIS_KEY,
|
|
14
|
+
name: 'checkRedisKeyCount'
|
|
15
|
+
})
|
|
16
|
+
.on('error', (err) => {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.error('createDefaultRedisClient: client onError:', err);
|
|
19
|
+
// reject(err);
|
|
20
|
+
});
|
|
21
|
+
redisClient.connect();
|
|
22
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
const orderNumberRepo = await chevre.repository.OrderNumber.createInstance({
|
|
26
|
+
redisClient,
|
|
27
|
+
connection: mongoose.connection
|
|
28
|
+
});
|
|
29
|
+
const result = await orderNumberRepo.publishByTimestamp({
|
|
30
|
+
project: { alternateName: 'CIN' },
|
|
31
|
+
orderDate: new Date()
|
|
32
|
+
});
|
|
33
|
+
console.log(result);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then(() => {
|
|
38
|
+
console.log('success!');
|
|
39
|
+
})
|
|
40
|
+
.catch(console.error);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
import * as redis from 'redis';
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
10
|
+
socket: {
|
|
11
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
12
|
+
host: <string>process.env.REDIS_HOST
|
|
13
|
+
},
|
|
14
|
+
password: <string>process.env.REDIS_KEY,
|
|
15
|
+
name: 'checkRedisKeyCount'
|
|
16
|
+
})
|
|
17
|
+
.on('error', (err) => {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.error('createDefaultRedisClient: client onError:', err);
|
|
20
|
+
// reject(err);
|
|
21
|
+
});
|
|
22
|
+
redisClient.connect();
|
|
23
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
|
+
|
|
25
|
+
async function main() {
|
|
26
|
+
const confirmationNumberRepo = await chevre.repository.ConfirmationNumber.createInstance({
|
|
27
|
+
redisClient,
|
|
28
|
+
connection: mongoose.connection
|
|
29
|
+
});
|
|
30
|
+
const result = await confirmationNumberRepo.setUseMongo4confirmationNumberFrom({
|
|
31
|
+
// useMongo4confirmationNumberFrom: moment('2025-05-22T23:50:00Z')
|
|
32
|
+
// .toDate(),
|
|
33
|
+
// useMongo4confirmationNumberFrom: moment('2025-05-25T15:00:00Z')
|
|
34
|
+
// .toDate()
|
|
35
|
+
useMongo4confirmationNumberFrom: moment('2025-05-31T15:00:00Z')
|
|
36
|
+
.toDate()
|
|
37
|
+
});
|
|
38
|
+
console.log(result);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main()
|
|
42
|
+
.then(() => {
|
|
43
|
+
console.log('success!');
|
|
44
|
+
})
|
|
45
|
+
.catch(console.error);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
import * as redis from 'redis';
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
10
|
+
socket: {
|
|
11
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
12
|
+
host: <string>process.env.REDIS_HOST
|
|
13
|
+
},
|
|
14
|
+
password: <string>process.env.REDIS_KEY,
|
|
15
|
+
name: 'checkRedisKeyCount'
|
|
16
|
+
})
|
|
17
|
+
.on('error', (err) => {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.error('createDefaultRedisClient: client onError:', err);
|
|
20
|
+
// reject(err);
|
|
21
|
+
});
|
|
22
|
+
redisClient.connect();
|
|
23
|
+
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
|
+
|
|
25
|
+
async function main() {
|
|
26
|
+
const orderNumberRepo = await chevre.repository.OrderNumber.createInstance({
|
|
27
|
+
redisClient,
|
|
28
|
+
connection: mongoose.connection
|
|
29
|
+
});
|
|
30
|
+
const result = await orderNumberRepo.setUseMongo4orderNumberFrom({
|
|
31
|
+
useMongo4orderNumberFrom: moment('2025-06-03T05:00:00Z')
|
|
32
|
+
.toDate()
|
|
33
|
+
});
|
|
34
|
+
console.log(result);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
main()
|
|
38
|
+
.then(() => {
|
|
39
|
+
console.log('success!');
|
|
40
|
+
})
|
|
41
|
+
.catch(console.error);
|