@chevre/domain 22.10.0-alpha.2 → 22.10.0-alpha.21
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/assetTransaction/processReserve.ts +4 -1
- package/example/src/chevre/createTaskIfNotExistByAlternateName.ts +1 -1
- package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
- package/example/src/chevre/findOneAvailableHours.ts +39 -0
- package/example/src/chevre/issuer/adminMemberProgramTiers.ts +55 -0
- package/example/src/chevre/issuer/renameIssuerIdentifier.ts +61 -0
- package/example/src/chevre/maintenance/checkTransactionStatuses.ts +105 -0
- 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/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/redisMulti.ts +63 -0
- package/example/src/signPayload.ts +45 -0
- 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/event.d.ts +1 -1
- package/lib/chevre/repo/event.js +9 -31
- package/lib/chevre/repo/issuer.d.ts +13 -2
- package/lib/chevre/repo/issuer.js +14 -0
- 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/event.js +19 -0
- 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.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/offer/event.js +111 -0
- 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/offer/event.d.ts +38 -0
- package/lib/chevre/repo/offer/event.js +142 -0
- package/lib/chevre/repo/orderNumber.d.ts +15 -4
- package/lib/chevre/repo/orderNumber.js +64 -23
- 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 +3 -2
- package/lib/chevre/repo/rateLimit/offer.js +8 -2
- 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 +47 -21
- 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 +8 -4
- package/lib/chevre/repo/transactionNumber.js +47 -21
- package/lib/chevre/repo/transactionNumberCounter.d.ts +28 -0
- package/lib/chevre/repo/transactionNumberCounter.js +128 -0
- package/lib/chevre/repo/transactionProcess.d.ts +1 -1
- package/lib/chevre/repo/transactionProcess.js +1 -1
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -2
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +11 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +63 -58
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -0
- package/lib/chevre/service/offer/event/authorize/factory.js +3 -2
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +9 -1
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize.js +4 -9
- 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.js +1 -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
|
@@ -18,7 +18,10 @@ async function main() {
|
|
|
18
18
|
await redisClient.connect();
|
|
19
19
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
20
20
|
|
|
21
|
-
const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance(
|
|
21
|
+
const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance({
|
|
22
|
+
redisClient,
|
|
23
|
+
connection: mongoose.connection
|
|
24
|
+
});
|
|
22
25
|
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
23
26
|
|
|
24
27
|
const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: new Date() });
|
|
@@ -5,7 +5,7 @@ import { chevre } from '../../../lib/index';
|
|
|
5
5
|
|
|
6
6
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
|
-
chevre.eventEmitter.task.onTaskStatusChanged((event) => {
|
|
8
|
+
chevre.eventEmitter.task.taskEventEmitter.onTaskStatusChanged((event) => {
|
|
9
9
|
console.log('onTaskStatusChanged', event);
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
const IDENTIFIER = 'xxx';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
// const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
|
+
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
let docs = await eventOfferRepo.projectFields(
|
|
16
|
+
{
|
|
17
|
+
project: { id: { $eq: project.id } },
|
|
18
|
+
identifier: { $eq: IDENTIFIER }
|
|
19
|
+
},
|
|
20
|
+
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
21
|
+
);
|
|
22
|
+
console.log('docs:', docs);
|
|
23
|
+
console.log(docs.length, 'docs found');
|
|
24
|
+
|
|
25
|
+
if (docs.length > 0) {
|
|
26
|
+
await eventOfferRepo.deleteById({
|
|
27
|
+
project: { id: docs[0].project.id },
|
|
28
|
+
id: docs[0].id
|
|
29
|
+
});
|
|
30
|
+
console.log('deleted', docs[0].id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await eventOfferRepo.save({
|
|
34
|
+
attributes: {
|
|
35
|
+
identifier: IDENTIFIER,
|
|
36
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
37
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
38
|
+
itemOffered: {
|
|
39
|
+
id: 'xxxxx',
|
|
40
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
41
|
+
},
|
|
42
|
+
seller: {
|
|
43
|
+
id: 'xxxxx',
|
|
44
|
+
typeOf: chevre.factory.organizationType.Organization
|
|
45
|
+
},
|
|
46
|
+
availableAtOrFrom: { id: 'xxx' },
|
|
47
|
+
validFrom: new Date(),
|
|
48
|
+
validThrough: new Date(),
|
|
49
|
+
validForMemberTier: { identifier: 'xxx', typeOf: 'MemberProgramTier' }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
console.log('created.');
|
|
53
|
+
|
|
54
|
+
docs = await await eventOfferRepo.projectFields(
|
|
55
|
+
{
|
|
56
|
+
project: { id: { $eq: project.id } },
|
|
57
|
+
identifier: { $eq: IDENTIFIER }
|
|
58
|
+
},
|
|
59
|
+
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
60
|
+
);
|
|
61
|
+
console.log('docs:', docs);
|
|
62
|
+
console.log(docs.length, 'docs found');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main()
|
|
66
|
+
.then()
|
|
67
|
+
.catch(console.error);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
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 availableHourRepo = await chevre.repository.ServiceAvailableHour.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const setting = await availableHourRepo.findValidOne(
|
|
12
|
+
{
|
|
13
|
+
// now: new Date(),
|
|
14
|
+
now: moment('2025-05-15T00:00:00Z')
|
|
15
|
+
.toDate()
|
|
16
|
+
},
|
|
17
|
+
['opens', 'typeOf']
|
|
18
|
+
);
|
|
19
|
+
console.log('setting:', setting);
|
|
20
|
+
const result = await availableHourRepo.saveOne(
|
|
21
|
+
{
|
|
22
|
+
// opens: '09:00:00',
|
|
23
|
+
validFrom: moment('2025-05-19T17:00:00Z')
|
|
24
|
+
.toDate(),
|
|
25
|
+
validThrough: moment('2025-05-19T20:00:00Z')
|
|
26
|
+
.toDate(),
|
|
27
|
+
typeOf: 'OpeningHoursSpecification'
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
console.log('saved', result);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main()
|
|
34
|
+
.then(() => {
|
|
35
|
+
console.log('success!');
|
|
36
|
+
})
|
|
37
|
+
.catch((err) => {
|
|
38
|
+
console.error(err);
|
|
39
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
const IDENTIFIER = 'DefaultMemberProgram';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const memberProgramRepo = await chevre.repository.MemberProgram.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const memberPrograms = await memberProgramRepo.projectMemberPrograms(
|
|
15
|
+
{
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
identifier: { $eq: IDENTIFIER }
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
console.log('docs:', memberPrograms);
|
|
21
|
+
console.log(memberPrograms.length, 'docs found');
|
|
22
|
+
|
|
23
|
+
if (memberPrograms.length > 0) {
|
|
24
|
+
const memberProgram = memberPrograms[0];
|
|
25
|
+
await memberProgramRepo.updateOne({
|
|
26
|
+
project: { id: project.id },
|
|
27
|
+
identifier: memberProgram.identifier,
|
|
28
|
+
hostingOrganization: { id: 'xxx' },
|
|
29
|
+
hasTiers: [
|
|
30
|
+
{ identifier: 'bronze' },
|
|
31
|
+
{ identifier: 'silver' },
|
|
32
|
+
{ identifier: 'gold' }
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
console.log('updated.');
|
|
36
|
+
|
|
37
|
+
const tiers = await memberProgramRepo.projectMemberProgramTiers(
|
|
38
|
+
{
|
|
39
|
+
limit: 10,
|
|
40
|
+
page: 1,
|
|
41
|
+
project: { id: { $eq: project.id } },
|
|
42
|
+
isTierOf: {
|
|
43
|
+
identifier: { $eq: memberProgram.identifier }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
// tslint:disable-next-line:no-null-keyword
|
|
48
|
+
console.dir(tiers, { depth: null });
|
|
49
|
+
console.log(tiers.length, 'tiers found');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
main()
|
|
54
|
+
.then()
|
|
55
|
+
.catch(console.error);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const NEW_IDENTIFIER = 'DefaultTokenIssuer';
|
|
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 issuerRepo = await chevre.repository.Issuer.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = issuerRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
_id: 1,
|
|
20
|
+
project: 1,
|
|
21
|
+
identifier: 1,
|
|
22
|
+
url: 1,
|
|
23
|
+
name: 1
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
console.log('docs found');
|
|
27
|
+
|
|
28
|
+
let i = 0;
|
|
29
|
+
let updateCount = 0;
|
|
30
|
+
await cursor.eachAsync(async (doc) => {
|
|
31
|
+
i += 1;
|
|
32
|
+
const issuer: chevre.factory.issuer.IIssuer = doc.toObject();
|
|
33
|
+
|
|
34
|
+
const alreadyMigrated = issuer.identifier === NEW_IDENTIFIER;
|
|
35
|
+
|
|
36
|
+
if (alreadyMigrated) {
|
|
37
|
+
console.log(
|
|
38
|
+
'already migrated.',
|
|
39
|
+
issuer.id, issuer.project.id, issuer.identifier, i);
|
|
40
|
+
} else {
|
|
41
|
+
console.log(
|
|
42
|
+
'updating...',
|
|
43
|
+
issuer.id, issuer.project.id, issuer.identifier, i);
|
|
44
|
+
await issuerRepo.renameIssuerIdentifier({
|
|
45
|
+
id: issuer.id,
|
|
46
|
+
identifier: NEW_IDENTIFIER
|
|
47
|
+
});
|
|
48
|
+
updateCount += 1;
|
|
49
|
+
console.log(
|
|
50
|
+
'updated.',
|
|
51
|
+
issuer.id, issuer.project.id, issuer.identifier, i);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log(i, 'docs checked');
|
|
56
|
+
console.log(updateCount, 'docs updated');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
main()
|
|
60
|
+
.then()
|
|
61
|
+
.catch(console.error);
|
|
@@ -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,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);
|
|
@@ -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);
|