@chevre/domain 22.10.0-alpha.1 → 22.10.0-alpha.11
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/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/migrateIssuerUrls.ts +1 -2
- package/example/src/chevre/issuer/renameIssuerIdentifier.ts +61 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +125 -51
- package/example/src/signPayload.ts +45 -0
- package/lib/chevre/repo/event.d.ts +1 -1
- package/lib/chevre/repo/event.js +9 -31
- package/lib/chevre/repo/issuer.d.ts +21 -6
- package/lib/chevre/repo/issuer.js +14 -0
- package/lib/chevre/repo/memberProgram.d.ts +44 -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 +4 -40
- 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 +83 -0
- 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/offer/event.d.ts +38 -0
- package/lib/chevre/repo/offer/event.js +142 -0
- package/lib/chevre/repo/service/availableHour.d.ts +15 -0
- package/lib/chevre/repo/service/availableHour.js +53 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -2
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +6 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +5 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +9 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +157 -34
- 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 +11 -1
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +6 -0
- package/lib/chevre/service/offer/event/authorize.js +4 -9
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +4 -2
- package/package.json +3 -3
|
@@ -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);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
|
|
4
|
-
import { IIssuer } from '../../../../lib/chevre/repo/mongoose/schemas/issuer';
|
|
5
4
|
import { chevre } from '../../../../lib/index';
|
|
6
5
|
|
|
7
6
|
// tslint:disable-next-line:max-func-body-length
|
|
@@ -28,7 +27,7 @@ async function main() {
|
|
|
28
27
|
let updateCount = 0;
|
|
29
28
|
await cursor.eachAsync(async (doc) => {
|
|
30
29
|
i += 1;
|
|
31
|
-
const issuer: IIssuer = doc.toObject();
|
|
30
|
+
const issuer: chevre.factory.issuer.IIssuer = doc.toObject();
|
|
32
31
|
|
|
33
32
|
const alreadyMigrated = typeof issuer.url === 'string';
|
|
34
33
|
|
|
@@ -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);
|
|
@@ -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.Event.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
2
|
import * as moment from 'moment';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
import * as redis from 'redis';
|
|
5
|
+
import * as util from 'util';
|
|
5
6
|
|
|
6
7
|
import { chevre } from '../../../../lib/index';
|
|
7
8
|
|
|
8
9
|
// const project = { id: String(process.env.PROJECT_ID) };
|
|
10
|
+
const { BACKLOG_ISSUE_KEY, BACKLOG_API_KEY, BACKLOG_SPACE_KEY } = process.env;
|
|
11
|
+
const BACKLOG_NOTIFY_URL = `https://${BACKLOG_SPACE_KEY}.backlog.jp/api/v2/issues/${BACKLOG_ISSUE_KEY}/comments?apiKey=${BACKLOG_API_KEY}`;
|
|
9
12
|
|
|
10
13
|
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
11
14
|
socket: {
|
|
@@ -22,6 +25,66 @@ const client = redis.createClient<redis.RedisDefaultModules, Record<string, neve
|
|
|
22
25
|
client.connect();
|
|
23
26
|
mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
24
27
|
|
|
28
|
+
function countRedisKeyByProject(params: {
|
|
29
|
+
project: { id: string };
|
|
30
|
+
now: Date;
|
|
31
|
+
}) {
|
|
32
|
+
return async (repos: {
|
|
33
|
+
event: chevre.repository.Event;
|
|
34
|
+
stockHolder: chevre.repository.StockHolder;
|
|
35
|
+
}) => {
|
|
36
|
+
const cursor = repos.event.getCursor(
|
|
37
|
+
{
|
|
38
|
+
'project.id': {
|
|
39
|
+
$eq: params.project.id
|
|
40
|
+
// $in: useMongoAsStockHolderProjects
|
|
41
|
+
},
|
|
42
|
+
startDate: {
|
|
43
|
+
$gte: params.now
|
|
44
|
+
},
|
|
45
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
46
|
+
// _id: { $eq: 'blyk9q24f' }
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
_id: 1,
|
|
50
|
+
// offers: 1,
|
|
51
|
+
startDate: 1,
|
|
52
|
+
project: 1,
|
|
53
|
+
typeOf: 1
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
console.log('events found');
|
|
57
|
+
|
|
58
|
+
let i = 0;
|
|
59
|
+
let redisKeyCount = 0;
|
|
60
|
+
const eventsWithRedis: string[] = [];
|
|
61
|
+
await cursor.eachAsync(async (doc) => {
|
|
62
|
+
i += 1;
|
|
63
|
+
const event: Pick<
|
|
64
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
65
|
+
'id' | 'startDate' | 'project' | 'typeOf'
|
|
66
|
+
> = doc.toObject();
|
|
67
|
+
|
|
68
|
+
console.log('redisKeyExists?', event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
69
|
+
const redisKeyExists = await repos.stockHolder.redisKeyExists({
|
|
70
|
+
eventId: event.id,
|
|
71
|
+
startDate: event.startDate
|
|
72
|
+
});
|
|
73
|
+
console.log('redisKeyExists:', redisKeyExists, event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
74
|
+
|
|
75
|
+
if (redisKeyExists) {
|
|
76
|
+
redisKeyCount += 1;
|
|
77
|
+
eventsWithRedis.push(event.id);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
console.log(i, 'events checked');
|
|
82
|
+
console.log(redisKeyCount, 'redisKeys found');
|
|
83
|
+
|
|
84
|
+
return { checkedCount: i, redisKeyCount };
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
25
88
|
// tslint:disable-next-line:max-func-body-length
|
|
26
89
|
async function main() {
|
|
27
90
|
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
@@ -37,62 +100,73 @@ async function main() {
|
|
|
37
100
|
);
|
|
38
101
|
const useMongoAsStockHolderProjects =
|
|
39
102
|
(Array.isArray(setting?.useMongoAsStockHolderProjects)) ? setting?.useMongoAsStockHolderProjects : [];
|
|
103
|
+
const results: {
|
|
104
|
+
project: { id: string };
|
|
105
|
+
checkedCount: number;
|
|
106
|
+
redisKeyCount: number;
|
|
107
|
+
}[] = [];
|
|
40
108
|
|
|
41
|
-
|
|
42
|
-
|
|
109
|
+
const now = moment()
|
|
110
|
+
.add(0, 'days')
|
|
111
|
+
.toDate();
|
|
112
|
+
for (const projectId of useMongoAsStockHolderProjects) {
|
|
113
|
+
const { checkedCount, redisKeyCount } = await countRedisKeyByProject({
|
|
114
|
+
project: { id: projectId },
|
|
115
|
+
now
|
|
116
|
+
})({
|
|
117
|
+
event: eventRepo,
|
|
118
|
+
stockHolder: stockHolderRepo
|
|
119
|
+
});
|
|
120
|
+
results.push({
|
|
121
|
+
project: { id: projectId },
|
|
122
|
+
checkedCount,
|
|
123
|
+
redisKeyCount
|
|
124
|
+
});
|
|
43
125
|
}
|
|
44
126
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
57
|
-
// _id: { $eq: 'blyk9q24f' }
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
_id: 1,
|
|
61
|
-
// offers: 1,
|
|
62
|
-
startDate: 1,
|
|
63
|
-
project: 1,
|
|
64
|
-
typeOf: 1
|
|
65
|
-
}
|
|
127
|
+
const header = util.format(
|
|
128
|
+
'| %s | %s | %s | %s |\n| %s | %s | %s | %s |',
|
|
129
|
+
`project `.slice(0, 24),
|
|
130
|
+
`now `.slice(0, 24),
|
|
131
|
+
`checkedCount `.slice(0, 24),
|
|
132
|
+
`redisKeyCount `.slice(0, 24),
|
|
133
|
+
`------------------------ `.slice(0, 24),
|
|
134
|
+
`------------------------ `.slice(0, 24),
|
|
135
|
+
`------------------------ `.slice(0, 24),
|
|
136
|
+
`------------------------ `.slice(0, 24)
|
|
66
137
|
);
|
|
67
|
-
console.log('events found');
|
|
68
|
-
|
|
69
|
-
let i = 0;
|
|
70
|
-
let redisKeyCount = 0;
|
|
71
|
-
const eventsWithRedis: string[] = [];
|
|
72
|
-
await cursor.eachAsync(async (doc) => {
|
|
73
|
-
i += 1;
|
|
74
|
-
const event: Pick<
|
|
75
|
-
chevre.factory.event.screeningEvent.IEvent,
|
|
76
|
-
'id' | 'startDate' | 'project' | 'typeOf'
|
|
77
|
-
> = doc.toObject();
|
|
78
|
-
|
|
79
|
-
console.log('redisKeyExists?', event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
80
|
-
const redisKeyExists = await stockHolderRepo.redisKeyExists({
|
|
81
|
-
eventId: event.id,
|
|
82
|
-
startDate: event.startDate
|
|
83
|
-
});
|
|
84
|
-
console.log('redisKeyExists:', redisKeyExists, event.project.id, event.typeOf, event.id, event.startDate, i);
|
|
85
138
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
139
|
+
const text = util.format(
|
|
140
|
+
'%s\n%s',
|
|
141
|
+
header,
|
|
142
|
+
results.map((result) => {
|
|
143
|
+
return util.format(
|
|
144
|
+
'| %s | %s | %s | %s |',
|
|
145
|
+
`${result.project.id} `.slice(0, 24),
|
|
146
|
+
`${now.toISOString()} `.slice(0, 24),
|
|
147
|
+
`${result.checkedCount} `.slice(0, 24),
|
|
148
|
+
`${result.redisKeyCount} `.slice(0, 24)
|
|
149
|
+
);
|
|
150
|
+
})
|
|
151
|
+
.join('\n')
|
|
152
|
+
);
|
|
153
|
+
console.log(text);
|
|
91
154
|
|
|
92
|
-
|
|
93
|
-
console.log(
|
|
94
|
-
|
|
95
|
-
|
|
155
|
+
// backlogへ通知
|
|
156
|
+
console.log('notifying on backlog...');
|
|
157
|
+
await fetch(
|
|
158
|
+
BACKLOG_NOTIFY_URL,
|
|
159
|
+
{
|
|
160
|
+
method: 'POST',
|
|
161
|
+
headers: new Headers({ 'Content-Type': 'application/json' }),
|
|
162
|
+
body: JSON.stringify({
|
|
163
|
+
content: text,
|
|
164
|
+
notifiedUserId: []
|
|
165
|
+
// notifiedUserId: users.map((user) => user.id)
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
console.log('posted to backlog.');
|
|
96
170
|
}
|
|
97
171
|
|
|
98
172
|
main()
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as jwt from 'jsonwebtoken';
|
|
3
|
+
|
|
4
|
+
async function main(): Promise<void> {
|
|
5
|
+
const payload = {
|
|
6
|
+
member: {
|
|
7
|
+
memberOf: {
|
|
8
|
+
identifier: 'DefaultTier',
|
|
9
|
+
isTierOf: {
|
|
10
|
+
identifier: 'DefaultMemberProgram'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const token = await new Promise<string>((resolve, reject) => {
|
|
17
|
+
// 所有権を暗号化する
|
|
18
|
+
jwt.sign(
|
|
19
|
+
payload,
|
|
20
|
+
'12345qwert',
|
|
21
|
+
{
|
|
22
|
+
// algorithm: jwtSetting.algorithm,
|
|
23
|
+
issuer: 'https://example.com',
|
|
24
|
+
expiresIn: 1800
|
|
25
|
+
// subject,
|
|
26
|
+
},
|
|
27
|
+
(err, encoded) => {
|
|
28
|
+
if (err instanceof Error) {
|
|
29
|
+
reject(err);
|
|
30
|
+
} else {
|
|
31
|
+
if (typeof encoded !== 'string') {
|
|
32
|
+
reject(new Error('cannot be signed unexpectedly'));
|
|
33
|
+
} else {
|
|
34
|
+
resolve(encoded);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
console.log(token);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
main()
|
|
44
|
+
.then(console.log)
|
|
45
|
+
.catch(console.error);
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -371,7 +371,7 @@ class EventRepo {
|
|
|
371
371
|
catch (error) {
|
|
372
372
|
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
373
373
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
374
|
-
throw new factory.errors.AlreadyInUse(factory.eventType.
|
|
374
|
+
throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
throw error;
|
|
@@ -441,10 +441,11 @@ class EventRepo {
|
|
|
441
441
|
});
|
|
442
442
|
}
|
|
443
443
|
else {
|
|
444
|
-
const { coaInfo,
|
|
444
|
+
const { coaInfo, // ←適用しない
|
|
445
|
+
// identifier, // support identifier(2025-05-13~)
|
|
445
446
|
maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // ←適用しない
|
|
446
447
|
eventStatus, superEvent } = creatingEventParams, // <-上書き可能な属性を限定的に
|
|
447
|
-
setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "
|
|
448
|
+
setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent"]);
|
|
448
449
|
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id: uniqid() });
|
|
449
450
|
bulkWriteOps.push({
|
|
450
451
|
updateOne: {
|
|
@@ -524,14 +525,15 @@ class EventRepo {
|
|
|
524
525
|
savedEventId = id;
|
|
525
526
|
}
|
|
526
527
|
else {
|
|
527
|
-
const upsert = params.upsert === true;
|
|
528
|
+
// const upsert: boolean = params.upsert === true;
|
|
529
|
+
const upsert = false; // always false(2025-05-15~)
|
|
528
530
|
doc = yield this.eventModel.findOneAndUpdate({
|
|
529
531
|
_id: { $eq: params.id },
|
|
530
532
|
typeOf: { $eq: typeOf }
|
|
531
533
|
}, Object.assign({
|
|
532
534
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
533
535
|
$setOnInsert: Object.assign({ typeOf,
|
|
534
|
-
project }, (identifier !==
|
|
536
|
+
project }, (typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined), $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), { upsert, new: true, projection: { _id: 1 } })
|
|
535
537
|
.lean()
|
|
536
538
|
.exec();
|
|
537
539
|
savedEventId = params.id;
|
|
@@ -540,7 +542,7 @@ class EventRepo {
|
|
|
540
542
|
catch (error) {
|
|
541
543
|
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
542
544
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
543
|
-
throw new factory.errors.AlreadyInUse(factory.eventType.
|
|
545
|
+
throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
|
|
544
546
|
}
|
|
545
547
|
}
|
|
546
548
|
throw error;
|
|
@@ -566,7 +568,6 @@ class EventRepo {
|
|
|
566
568
|
_id: p.id,
|
|
567
569
|
typeOf: p.attributes.typeOf
|
|
568
570
|
},
|
|
569
|
-
// upsertの場合、createがありうるので属性を除外しない
|
|
570
571
|
update: Object.assign({ $setOnInsert: Object.assign(Object.assign({ typeOf: p.attributes.typeOf, project: p.attributes.project }, (typeof p.attributes.identifier === 'string')
|
|
571
572
|
? { identifier: p.attributes.identifier } : undefined), (typeof p.attributes.remainingAttendeeCapacity === 'number')
|
|
572
573
|
? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
|
|
@@ -577,29 +578,6 @@ class EventRepo {
|
|
|
577
578
|
}
|
|
578
579
|
else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
|
|
579
580
|
throw new factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
|
|
580
|
-
// 上書き禁止属性を除外(2022-08-24~)
|
|
581
|
-
// const { identifier, project, typeOf, ...updateFields } = p.attributes;
|
|
582
|
-
// bulkWriteOps.push({
|
|
583
|
-
// updateOne: {
|
|
584
|
-
// filter: {
|
|
585
|
-
// _id: p.id,
|
|
586
|
-
// typeOf: p.attributes.typeOf
|
|
587
|
-
// },
|
|
588
|
-
// // upsertの場合、createがありうるので属性を除外しない
|
|
589
|
-
// update: {
|
|
590
|
-
// $setOnInsert: {
|
|
591
|
-
// typeOf: p.attributes.typeOf,
|
|
592
|
-
// project: p.attributes.project,
|
|
593
|
-
// ...(typeof p.attributes.identifier === 'string')
|
|
594
|
-
// ? { identifier: p.attributes.identifier } : undefined
|
|
595
|
-
// },
|
|
596
|
-
// $set: updateFields,
|
|
597
|
-
// // $unsetに対応(2022-08-31~)
|
|
598
|
-
// ...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
|
|
599
|
-
// },
|
|
600
|
-
// upsert
|
|
601
|
-
// }
|
|
602
|
-
// });
|
|
603
581
|
}
|
|
604
582
|
});
|
|
605
583
|
}
|
|
@@ -626,7 +604,7 @@ class EventRepo {
|
|
|
626
604
|
// upsertの場合、createがありうるので属性を除外しない
|
|
627
605
|
{
|
|
628
606
|
$setOnInsert: Object.assign({ _id: id, typeOf,
|
|
629
|
-
project }, (identifier !==
|
|
607
|
+
project }, (typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined),
|
|
630
608
|
$set: updateFields
|
|
631
609
|
}, { upsert: true, new: true, projection: { _id: 1 } })
|
|
632
610
|
.lean()
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
|
-
import
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
import { IDocType } from './mongoose/schemas/issuer';
|
|
4
|
+
type IIssuer = factory.issuer.IIssuer;
|
|
5
|
+
type ISearchConditions = factory.issuer.ISearchConditions;
|
|
3
6
|
/**
|
|
4
7
|
* 発行者リポジトリ
|
|
5
8
|
*/
|
|
6
9
|
export declare class IssuerRepo {
|
|
7
10
|
private readonly issuerModel;
|
|
8
11
|
constructor(connection: Connection);
|
|
9
|
-
static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<IIssuer>[];
|
|
12
|
+
static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<factory.issuer.IIssuer>[];
|
|
10
13
|
saveIssuer(params: IIssuer): Promise<{
|
|
11
14
|
id: string;
|
|
12
15
|
}>;
|
|
16
|
+
renameIssuerIdentifier(params: Pick<IIssuer, 'id' | 'identifier'>): Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
}>;
|
|
13
19
|
projectPublicFields(params: ISearchConditions): Promise<Pick<IIssuer, 'id' | 'identifier' | 'project' | 'name' | 'url'>[]>;
|
|
14
20
|
findById(params: {
|
|
15
21
|
id: string;
|
|
@@ -29,13 +35,22 @@ export declare class IssuerRepo {
|
|
|
29
35
|
id: string;
|
|
30
36
|
};
|
|
31
37
|
}): Promise<void>;
|
|
32
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & IIssuer & {
|
|
33
|
-
hasMemberProgram?:
|
|
38
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & factory.issuer.IIssuer & {
|
|
39
|
+
hasMemberProgram?: (
|
|
40
|
+
/**
|
|
41
|
+
* 発行者リポジトリ
|
|
42
|
+
*/
|
|
43
|
+
factory.issuer.IMemberProgram & {
|
|
44
|
+
hasTiers?: Pick<factory.issuer.IMemberProgramTier, "identifier" | "typeOf">[];
|
|
45
|
+
})[];
|
|
34
46
|
} & {
|
|
35
47
|
_id: import("mongoose").Types.ObjectId;
|
|
36
|
-
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & IIssuer & {
|
|
37
|
-
hasMemberProgram?:
|
|
48
|
+
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & factory.issuer.IIssuer & {
|
|
49
|
+
hasMemberProgram?: (factory.issuer.IMemberProgram & {
|
|
50
|
+
hasTiers?: Pick<factory.issuer.IMemberProgramTier, "identifier" | "typeOf">[];
|
|
51
|
+
})[];
|
|
38
52
|
} & {
|
|
39
53
|
_id: import("mongoose").Types.ObjectId;
|
|
40
54
|
}>>;
|
|
41
55
|
}
|
|
56
|
+
export {};
|