@chevre/domain 23.0.0-alpha.3 → 23.0.0-alpha.5
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/note/findNotes.ts +34 -0
- package/example/src/chevre/note/upsertNotesByIdentifier.ts +6 -4
- package/lib/chevre/repo/mongoose/schemas/note.js +9 -0
- package/lib/chevre/repo/note.d.ts +2 -9
- package/lib/chevre/repo/note.js +52 -18
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +1 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +19 -105
- package/package.json +3 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
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 noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
|
|
13
|
+
const notes = await noteRepo.findNotes(
|
|
14
|
+
{
|
|
15
|
+
limit: 10,
|
|
16
|
+
page: 1,
|
|
17
|
+
project: { id: { $eq: project.id } },
|
|
18
|
+
hasDigitalDocumentPermission: {
|
|
19
|
+
grantee: {
|
|
20
|
+
audienceType: {
|
|
21
|
+
$eq: chevre.factory.creativeWork.noteDigitalDocument.PermissionGranteeAudienceType.Public
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
['about', 'identifier']
|
|
27
|
+
);
|
|
28
|
+
// tslint:disable-next-line:no-null-keyword
|
|
29
|
+
console.dir(notes, { depth: null });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main()
|
|
33
|
+
.then()
|
|
34
|
+
.catch(console.error);
|
|
@@ -27,14 +27,13 @@ async function main() {
|
|
|
27
27
|
};
|
|
28
28
|
const createResult = await noteRepo.upsertNotesByIdentifier(
|
|
29
29
|
[
|
|
30
|
-
{
|
|
31
|
-
$set: creatingNote
|
|
32
|
-
// $unset: {}
|
|
33
|
-
},
|
|
34
30
|
{
|
|
35
31
|
$set: creatingNote
|
|
36
32
|
// $unset: {}
|
|
37
33
|
}
|
|
34
|
+
// {
|
|
35
|
+
// $set: creatingNote
|
|
36
|
+
// }
|
|
38
37
|
],
|
|
39
38
|
{ update: false }
|
|
40
39
|
);
|
|
@@ -46,6 +45,9 @@ async function main() {
|
|
|
46
45
|
{
|
|
47
46
|
$set: creatingNote
|
|
48
47
|
}
|
|
48
|
+
// {
|
|
49
|
+
// $set: creatingNote
|
|
50
|
+
// }
|
|
49
51
|
],
|
|
50
52
|
{ update: true }
|
|
51
53
|
);
|
|
@@ -85,6 +85,15 @@ const indexes = [
|
|
|
85
85
|
[
|
|
86
86
|
{ identifier: 1, dateCreated: -1 },
|
|
87
87
|
{ name: 'identifier' }
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
{ 'hasDigitalDocumentPermission.grantee.audienceType': 1, dateCreated: -1 },
|
|
91
|
+
{
|
|
92
|
+
name: 'permissionGranteeAudienceType',
|
|
93
|
+
partialFilterExpression: {
|
|
94
|
+
'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
88
97
|
]
|
|
89
98
|
// discontinue(2025-05-08~)
|
|
90
99
|
// [
|
|
@@ -15,6 +15,8 @@ export declare class NoteRepo {
|
|
|
15
15
|
})[]>;
|
|
16
16
|
/**
|
|
17
17
|
* メモ識別子をキーにして冪等置換
|
|
18
|
+
* 主題+識別子でユニーク必須
|
|
19
|
+
* 編集の場合、存在検証される
|
|
18
20
|
*/
|
|
19
21
|
upsertNotesByIdentifier(params: {
|
|
20
22
|
$set: Pick<INoteDigitalDocument, 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'> & {
|
|
@@ -32,15 +34,6 @@ export declare class NoteRepo {
|
|
|
32
34
|
id: string;
|
|
33
35
|
}[];
|
|
34
36
|
} | void>;
|
|
35
|
-
/**
|
|
36
|
-
* 既知のメモIDリストからメモを削除する
|
|
37
|
-
*/
|
|
38
|
-
deleteNotesByIds(params: {
|
|
39
|
-
project: {
|
|
40
|
-
id: string;
|
|
41
|
-
};
|
|
42
|
-
ids: string[];
|
|
43
|
-
}): Promise<DeleteResult | void>;
|
|
44
37
|
/**
|
|
45
38
|
* 主題リソースから全メモを削除する
|
|
46
39
|
*/
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -35,7 +35,7 @@ class NoteRepo {
|
|
|
35
35
|
this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
|
|
36
36
|
}
|
|
37
37
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
38
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
39
39
|
const andConditions = [];
|
|
40
40
|
const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
|
|
41
41
|
if (Array.isArray(idIn)) {
|
|
@@ -77,6 +77,10 @@ class NoteRepo {
|
|
|
77
77
|
if (Array.isArray(identifierIn)) {
|
|
78
78
|
andConditions.push({ identifier: { $in: identifierIn } });
|
|
79
79
|
}
|
|
80
|
+
const audienceTypeEq = (_v = (_u = (_t = params.hasDigitalDocumentPermission) === null || _t === void 0 ? void 0 : _t.grantee) === null || _u === void 0 ? void 0 : _u.audienceType) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
81
|
+
if (typeof audienceTypeEq === 'string') {
|
|
82
|
+
andConditions.push({ 'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true, $eq: audienceTypeEq } });
|
|
83
|
+
}
|
|
80
84
|
return andConditions;
|
|
81
85
|
}
|
|
82
86
|
findNotes(params, inclusion) {
|
|
@@ -107,25 +111,33 @@ class NoteRepo {
|
|
|
107
111
|
}
|
|
108
112
|
/**
|
|
109
113
|
* メモ識別子をキーにして冪等置換
|
|
114
|
+
* 主題+識別子でユニーク必須
|
|
115
|
+
* 編集の場合、存在検証される
|
|
110
116
|
*/
|
|
117
|
+
// tslint:disable-next-line:max-func-body-length
|
|
111
118
|
upsertNotesByIdentifier(params, options) {
|
|
112
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
120
|
const now = new Date();
|
|
114
121
|
const { update } = options;
|
|
115
122
|
const bulkWriteOps = [];
|
|
116
123
|
const queryFilters = [];
|
|
124
|
+
let uniqueIdentifiers = [];
|
|
117
125
|
if (Array.isArray(params)) {
|
|
118
126
|
params.forEach(({ $set }) => {
|
|
119
127
|
const { about, creator, identifier, project, provider, text, version, hasDigitalDocumentPermission } = $set;
|
|
120
|
-
if (typeof
|
|
128
|
+
if (typeof about.id !== 'string' || about.id === '') {
|
|
129
|
+
throw new factory.errors.ArgumentNull('about.id');
|
|
130
|
+
}
|
|
131
|
+
if (typeof identifier !== 'string' || identifier === '') {
|
|
121
132
|
throw new factory.errors.ArgumentNull('identifier');
|
|
122
133
|
}
|
|
123
|
-
if (typeof version !== 'string' || version
|
|
134
|
+
if (typeof version !== 'string' || version === '') {
|
|
124
135
|
throw new factory.errors.ArgumentNull('version');
|
|
125
136
|
}
|
|
126
137
|
if (typeof text !== 'string') {
|
|
127
138
|
throw new factory.errors.ArgumentNull('text');
|
|
128
139
|
}
|
|
140
|
+
uniqueIdentifiers.push(`${about.id}:${identifier}`);
|
|
129
141
|
// リソースのユニークネスを保証するfilter
|
|
130
142
|
const filter = {
|
|
131
143
|
'project.id': { $eq: project.id },
|
|
@@ -167,6 +179,25 @@ class NoteRepo {
|
|
|
167
179
|
});
|
|
168
180
|
}
|
|
169
181
|
if (bulkWriteOps.length > 0) {
|
|
182
|
+
// 主題+識別子でユニーク検証
|
|
183
|
+
uniqueIdentifiers = [...new Set(uniqueIdentifiers)];
|
|
184
|
+
if (uniqueIdentifiers.length !== bulkWriteOps.length) {
|
|
185
|
+
throw new factory.errors.Argument('identifier', '(about.id + identifier)s must be unique');
|
|
186
|
+
}
|
|
187
|
+
if (update === true) {
|
|
188
|
+
// 編集の場合、存在検証
|
|
189
|
+
const modifyingNotes = yield this.noteModel.find({ $or: queryFilters }, {
|
|
190
|
+
_id: 0,
|
|
191
|
+
id: { $toString: '$_id' }
|
|
192
|
+
})
|
|
193
|
+
.lean()
|
|
194
|
+
.exec();
|
|
195
|
+
// tslint:disable-next-line:no-console
|
|
196
|
+
console.log('NoteRepo.upsertNotesByIdentifier:', params.length, 'params ->', modifyingNotes.length, 'modifyingNotes found.', JSON.stringify(modifyingNotes));
|
|
197
|
+
if (modifyingNotes.length !== bulkWriteOps.length) {
|
|
198
|
+
throw new factory.errors.NotFound(factory.creativeWorkType.NoteDigitalDocument);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
170
201
|
const bulkWriteResult = yield this.noteModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
171
202
|
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
172
203
|
const modifiedNotes = yield this.noteModel.find({ $or: queryFilters }, {
|
|
@@ -179,21 +210,24 @@ class NoteRepo {
|
|
|
179
210
|
}
|
|
180
211
|
});
|
|
181
212
|
}
|
|
182
|
-
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
deleteNotesByIds(params
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
213
|
+
// /**
|
|
214
|
+
// * 既知のメモIDリストからメモを削除する
|
|
215
|
+
// */
|
|
216
|
+
// public async deleteNotesByIds(params: {
|
|
217
|
+
// project: { id: string };
|
|
218
|
+
// ids: string[];
|
|
219
|
+
// }): Promise<DeleteResult | void> {
|
|
220
|
+
// const { project, ids } = params;
|
|
221
|
+
// if (Array.isArray(ids) && ids.length > 0) {
|
|
222
|
+
// return this.noteModel.deleteMany(
|
|
223
|
+
// {
|
|
224
|
+
// 'project.id': { $eq: project.id },
|
|
225
|
+
// _id: { $in: ids }
|
|
226
|
+
// }
|
|
227
|
+
// )
|
|
228
|
+
// .exec();
|
|
229
|
+
// }
|
|
230
|
+
// }
|
|
197
231
|
/**
|
|
198
232
|
* 主題リソースから全メモを削除する
|
|
199
233
|
*/
|
|
@@ -20,6 +20,7 @@ function verifyOfferedByToken(params) {
|
|
|
20
20
|
try {
|
|
21
21
|
result = yield new Promise((resolve, reject) => {
|
|
22
22
|
jwt.verify(token, secret, {
|
|
23
|
+
algorithms: ['HS256'],
|
|
23
24
|
issuer
|
|
24
25
|
// ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
|
|
25
26
|
}, (err, decoded) => {
|
|
@@ -4,105 +4,7 @@ exports.tour2creatingEvent = tour2creatingEvent;
|
|
|
4
4
|
exports.schedule2tours = schedule2tours;
|
|
5
5
|
const moment = require("moment-timezone");
|
|
6
6
|
const factory = require("../../../../factory");
|
|
7
|
-
|
|
8
|
-
// function schedule2createEventParams(
|
|
9
|
-
// schedule: factory.schedule.IEventWithSchedule,
|
|
10
|
-
// createDate: Date
|
|
11
|
-
// ): factory.event.screeningEvent.ICreateParams[] {
|
|
12
|
-
// const eventServiceId = schedule.offers?.itemOffered?.id;
|
|
13
|
-
// const makesOffer = schedule.offers?.seller?.makesOffer;
|
|
14
|
-
// const applicationIds: string[] = (Array.isArray(makesOffer))
|
|
15
|
-
// ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
|
|
16
|
-
// : [];
|
|
17
|
-
// const eventSeriesId = schedule.superEvent?.id;
|
|
18
|
-
// if (typeof eventServiceId !== 'string' || eventServiceId === '') {
|
|
19
|
-
// throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
|
|
20
|
-
// }
|
|
21
|
-
// if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
|
|
22
|
-
// throw new factory.errors.NotFound('schedule.superEvent.id');
|
|
23
|
-
// }
|
|
24
|
-
// // 引数情報取得
|
|
25
|
-
// if (schedule.eventSchedule === undefined) {
|
|
26
|
-
// throw new factory.errors.NotFound('eventSchedule');
|
|
27
|
-
// }
|
|
28
|
-
// const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
|
|
29
|
-
// debug(targetInfo.length, 'targetInfos ->', targetInfo);
|
|
30
|
-
// const createParams: factory.event.screeningEvent.ICreateParams[] = [];
|
|
31
|
-
// for (const performanceInfo of targetInfo) {
|
|
32
|
-
// const oldEventId = [
|
|
33
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
34
|
-
// performanceInfo.day.slice(-6),
|
|
35
|
-
// workPerformedIdentifier,
|
|
36
|
-
// movieTheater.branchCode,
|
|
37
|
-
// screeningRoom.branchCode,
|
|
38
|
-
// performanceInfo.start_time
|
|
39
|
-
// ].join('');
|
|
40
|
-
// const maxValue = movieTheater.offers?.eligibleQuantity?.maxValue;
|
|
41
|
-
// const availabilityEnds: Date = moment(performanceInfo.end_date)
|
|
42
|
-
// .tz('Asia/Tokyo')
|
|
43
|
-
// .endOf('date')
|
|
44
|
-
// .toDate();
|
|
45
|
-
// const availabilityStarts: Date = moment(performanceInfo.start_date)
|
|
46
|
-
// .tz('Asia/Tokyo')
|
|
47
|
-
// .startOf('date')
|
|
48
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
49
|
-
// .add(-3, 'months')
|
|
50
|
-
// .toDate();
|
|
51
|
-
// const validThrough: Date = moment(performanceInfo.end_date)
|
|
52
|
-
// .tz('Asia/Tokyo')
|
|
53
|
-
// .endOf('date')
|
|
54
|
-
// .toDate();
|
|
55
|
-
// const validFrom: Date = moment(performanceInfo.start_date)
|
|
56
|
-
// .tz('Asia/Tokyo')
|
|
57
|
-
// .startOf('date')
|
|
58
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
59
|
-
// .add(-3, 'months')
|
|
60
|
-
// .toDate();
|
|
61
|
-
// // イベント作成
|
|
62
|
-
// createParams.push({
|
|
63
|
-
// eventStatus: factory.eventStatusType.EventScheduled,
|
|
64
|
-
// doorTime: performanceInfo.door_time,
|
|
65
|
-
// startDate: performanceInfo.start_date,
|
|
66
|
-
// endDate: performanceInfo.end_date,
|
|
67
|
-
// offers: {
|
|
68
|
-
// eligibleQuantity: {
|
|
69
|
-
// ...(typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
|
|
70
|
-
// },
|
|
71
|
-
// itemOffered: {
|
|
72
|
-
// // 興行ID追加(2022-09-01~)
|
|
73
|
-
// id: eventServiceId,
|
|
74
|
-
// serviceOutput: {
|
|
75
|
-
// typeOf: factory.reservationType.EventReservation,
|
|
76
|
-
// reservedTicket: {
|
|
77
|
-
// typeOf: 'Ticket',
|
|
78
|
-
// ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
79
|
-
// }
|
|
80
|
-
// },
|
|
81
|
-
// },
|
|
82
|
-
// seller: {
|
|
83
|
-
// // event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
84
|
-
// makesOffer: applicationIds.map((applicationId) => {
|
|
85
|
-
// return {
|
|
86
|
-
// typeOf: factory.offerType.Offer,
|
|
87
|
-
// availableAtOrFrom: { id: applicationId }, // support no-array(2024-10-13~),
|
|
88
|
-
// availabilityEnds,
|
|
89
|
-
// availabilityStarts,
|
|
90
|
-
// validFrom,
|
|
91
|
-
// validThrough
|
|
92
|
-
// };
|
|
93
|
-
// })
|
|
94
|
-
// }
|
|
95
|
-
// },
|
|
96
|
-
// // 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
97
|
-
// additionalProperty: [
|
|
98
|
-
// { name: 'tourNumber', value: String(performanceInfo.tour_number) },
|
|
99
|
-
// { name: 'oldEventId', value: oldEventId }
|
|
100
|
-
// ],
|
|
101
|
-
// identifier: oldEventId
|
|
102
|
-
// });
|
|
103
|
-
// }
|
|
104
|
-
// return createParams;
|
|
105
|
-
// }
|
|
7
|
+
const TIMEZONE = 'Asia/Tokyo';
|
|
106
8
|
// tslint:disable-next-line:max-func-body-length
|
|
107
9
|
function tour2creatingEvent(tour, movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries, project) {
|
|
108
10
|
var _a;
|
|
@@ -115,22 +17,34 @@ function tour2creatingEvent(tour, movieTheater, screeningRoom, existingApplicati
|
|
|
115
17
|
screeningRoom.branchCode,
|
|
116
18
|
tour.start_time
|
|
117
19
|
].join('');
|
|
20
|
+
// 00:00:00で再実装(2025-10-09~)
|
|
21
|
+
// const availabilityEnds: Date = moment(tour.end_date)
|
|
22
|
+
// .tz(TIMEZONE)
|
|
23
|
+
// .endOf('date')
|
|
24
|
+
// .toDate();
|
|
118
25
|
const availabilityEnds = moment(tour.end_date)
|
|
119
|
-
.tz(
|
|
120
|
-
.
|
|
26
|
+
.tz(TIMEZONE)
|
|
27
|
+
.startOf('date')
|
|
28
|
+
.add(1, 'day')
|
|
121
29
|
.toDate();
|
|
122
30
|
const availabilityStarts = moment(tour.start_date)
|
|
123
|
-
.tz(
|
|
31
|
+
.tz(TIMEZONE)
|
|
124
32
|
.startOf('date')
|
|
125
33
|
// tslint:disable-next-line:no-magic-numbers
|
|
126
34
|
.add(-3, 'months')
|
|
127
35
|
.toDate();
|
|
36
|
+
// 00:00:00で再実装(2025-10-09~)
|
|
37
|
+
// const validThrough: Date = moment(tour.end_date)
|
|
38
|
+
// .tz(TIMEZONE)
|
|
39
|
+
// .endOf('date')
|
|
40
|
+
// .toDate();
|
|
128
41
|
const validThrough = moment(tour.end_date)
|
|
129
|
-
.tz(
|
|
130
|
-
.
|
|
42
|
+
.tz(TIMEZONE)
|
|
43
|
+
.startOf('date')
|
|
44
|
+
.add(1, 'day')
|
|
131
45
|
.toDate();
|
|
132
46
|
const validFrom = moment(tour.start_date)
|
|
133
|
-
.tz(
|
|
47
|
+
.tz(TIMEZONE)
|
|
134
48
|
.startOf('date')
|
|
135
49
|
// tslint:disable-next-line:no-magic-numbers
|
|
136
50
|
.add(-3, 'months')
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "5.
|
|
15
|
-
"@cinerino/sdk": "12.5.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.1.0-alpha.0",
|
|
15
|
+
"@cinerino/sdk": "12.5.0-alpha.6",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.0.0-alpha.
|
|
118
|
+
"version": "23.0.0-alpha.5"
|
|
119
119
|
}
|