@chevre/domain 23.1.0-alpha.1 → 23.1.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/assetTransaction/processReserve.ts +9 -3
- package/example/src/chevre/authorizeEventServiceOffer.ts +8 -5
- package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
- package/example/src/chevre/member/migrateMemberIdentifier.ts +99 -0
- package/example/src/chevre/reIndex.ts +2 -2
- package/lib/chevre/repo/eventOffer.d.ts +52 -0
- package/lib/chevre/repo/eventOffer.js +191 -0
- package/lib/chevre/repo/member.d.ts +18 -1
- package/lib/chevre/repo/member.js +14 -8
- package/lib/chevre/repo/mongoose/schemas/eventOffer.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +102 -0
- package/lib/chevre/repo/mongoose/schemas/member.js +10 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +8 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +6 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +63 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +30 -30
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +10 -26
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.d.ts +23 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +62 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +38 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +39 -19
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +0 -3
- package/lib/chevre/service/offer/event/authorize/factory.js +4 -3
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +42 -25
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +6 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -4
- package/lib/chevre/service/offer/event/authorize.d.ts +5 -0
- package/lib/chevre/service/offer/event/authorize.js +10 -5
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
- package/lib/chevre/service/offer/event.d.ts +2 -1
- package/lib/chevre/service/offer/event.js +3 -1
- package/lib/chevre/service/offer/onEventChanged.js +29 -13
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +29 -23
- package/package.json +3 -3
|
@@ -76,8 +76,8 @@ async function main() {
|
|
|
76
76
|
reservationFor: {
|
|
77
77
|
id: EVENT_ID,
|
|
78
78
|
offers: {
|
|
79
|
-
token: OFFER_TOKEN,
|
|
80
|
-
identifier: 'LegacyReservation'
|
|
79
|
+
// token: OFFER_TOKEN,
|
|
80
|
+
// identifier: 'LegacyReservation'
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
@@ -88,7 +88,9 @@ async function main() {
|
|
|
88
88
|
validateEvent: false,
|
|
89
89
|
validateEventOfferPeriod: true,
|
|
90
90
|
validateAppliesToMovieTicket: true,
|
|
91
|
-
instrument: [
|
|
91
|
+
instrument: [
|
|
92
|
+
...(typeof OFFER_TOKEN === 'string') ? [{ ticketToken: OFFER_TOKEN, typeOf: <'Ticket'>'Ticket' }] : []
|
|
93
|
+
],
|
|
92
94
|
availableAtOrFrom: { id: APPLICATION_ID }
|
|
93
95
|
// stockHoldUntilDaysAfterEventEnd: STOCK_HOLD_UNTIL_DAYS_AFTER_EVENT_END
|
|
94
96
|
},
|
|
@@ -96,11 +98,14 @@ async function main() {
|
|
|
96
98
|
)(
|
|
97
99
|
{
|
|
98
100
|
advanceBookingRequirement: await chevre.repository.AdvanceBookingRequirement.createInstance(mongoose.connection),
|
|
101
|
+
authorization: await chevre.repository.Authorization.createInstance(mongoose.connection),
|
|
99
102
|
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
100
103
|
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
|
|
101
104
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
105
|
+
eventOffer: await chevre.repository.EventOffer.createInstance(mongoose.connection),
|
|
102
106
|
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
103
107
|
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
108
|
+
member: await chevre.repository.Member.createInstance(mongoose.connection),
|
|
104
109
|
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
105
110
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
106
111
|
offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
@@ -113,6 +118,7 @@ async function main() {
|
|
|
113
118
|
seat: await chevre.repository.place.Seat.createInstance(mongoose.connection),
|
|
114
119
|
setting: await chevre.repository.Setting.createInstance(mongoose.connection),
|
|
115
120
|
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
121
|
+
ticket: await chevre.repository.Ticket.createInstance(mongoose.connection),
|
|
116
122
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection)
|
|
117
123
|
},
|
|
118
124
|
new chevre.settings.Settings({
|
|
@@ -29,10 +29,10 @@ async function main() {
|
|
|
29
29
|
reservationFor: {
|
|
30
30
|
id: 'bmcvkft63',
|
|
31
31
|
offers: {
|
|
32
|
-
validForMemberTier: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
// validForMemberTier: {
|
|
33
|
+
// token: 'xx',
|
|
34
|
+
// isTierOf: { identifier: 'DefaultMemberProgram' }
|
|
35
|
+
// }
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
}
|
|
@@ -41,7 +41,8 @@ async function main() {
|
|
|
41
41
|
transaction: { id: 'xxx' },
|
|
42
42
|
validateEventOfferPeriod: true,
|
|
43
43
|
validateEvent: false,
|
|
44
|
-
store: { id: 'xxx' }
|
|
44
|
+
store: { id: 'xxx' },
|
|
45
|
+
instrument: []
|
|
45
46
|
},
|
|
46
47
|
{
|
|
47
48
|
noOfferSpecified: true,
|
|
@@ -54,8 +55,10 @@ async function main() {
|
|
|
54
55
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
55
56
|
authorization: await chevre.repository.Authorization.createInstance(mongoose.connection),
|
|
56
57
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
58
|
+
eventOffer: await chevre.repository.EventOffer.createInstance(mongoose.connection),
|
|
57
59
|
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
58
60
|
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
61
|
+
member: await chevre.repository.Member.createInstance(mongoose.connection),
|
|
59
62
|
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
60
63
|
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
|
|
61
64
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const validFrom = moment()
|
|
15
|
+
.toDate();
|
|
16
|
+
const validThrough = moment(validFrom)
|
|
17
|
+
.add(1, 'hour')
|
|
18
|
+
.toDate();
|
|
19
|
+
const eventOffer: Omit<chevre.factory.eventOffer.IEventOffer, 'id'> = {
|
|
20
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
21
|
+
identifier: '20251113eventOffer',
|
|
22
|
+
itemOffered: {
|
|
23
|
+
id: '69151228ad580da66c8b5068',
|
|
24
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
25
|
+
},
|
|
26
|
+
availableAtOrFrom: {
|
|
27
|
+
identifier: 'SmartTheaterTXN'
|
|
28
|
+
},
|
|
29
|
+
validFrom,
|
|
30
|
+
validThrough,
|
|
31
|
+
seller: {
|
|
32
|
+
id: '59d20831e53ebc2b4e774466',
|
|
33
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
34
|
+
},
|
|
35
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
let result = await eventOfferRepo.upsertEventOffersByIdentifier(
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
$set: eventOffer,
|
|
42
|
+
$unset: {}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
{
|
|
46
|
+
update: false
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
console.log(result);
|
|
50
|
+
|
|
51
|
+
result = await eventOfferRepo.upsertEventOffersByIdentifier(
|
|
52
|
+
[
|
|
53
|
+
{
|
|
54
|
+
$set: eventOffer,
|
|
55
|
+
$unset: {}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
{
|
|
59
|
+
update: true
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
console.log(result);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main()
|
|
66
|
+
.then()
|
|
67
|
+
.catch(console.error);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
const identifierMap = [
|
|
10
|
+
{
|
|
11
|
+
id: '7divuoimobsfgq95tp1csorjqq',
|
|
12
|
+
identifier: 'SmartTheaterTXNMember'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: '51qbjcfr72h62m06vtv5kkhgje',
|
|
16
|
+
identifier: 'SmartTheaterTXN'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'ckevmf3fueqcunnideu6artt',
|
|
20
|
+
identifier: 'SmartTheaterPOS'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: '3eo6okferrsdpfd9j2ce1iv9k7',
|
|
24
|
+
identifier: 'SmartTheaterTVM'
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// tslint:disable-next-line:max-func-body-length
|
|
29
|
+
async function main() {
|
|
30
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
31
|
+
|
|
32
|
+
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
33
|
+
|
|
34
|
+
const cursor = memberRepo.getCursor(
|
|
35
|
+
{
|
|
36
|
+
// typeOf: { $eq: chevre.factory.placeType.ScreeningRoom }
|
|
37
|
+
'project.id': { $eq: '*' }
|
|
38
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
project: 1,
|
|
42
|
+
member: 1
|
|
43
|
+
// paymentMethods: 1,
|
|
44
|
+
// project: 1,
|
|
45
|
+
// orderDate: 1
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
console.log('docs found');
|
|
49
|
+
|
|
50
|
+
let updated: number = 0;
|
|
51
|
+
let i = 0;
|
|
52
|
+
await cursor.eachAsync(async (doc) => {
|
|
53
|
+
i += 1;
|
|
54
|
+
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
55
|
+
|
|
56
|
+
const applicationIdentifier = iamMember.member.identifier;
|
|
57
|
+
const updatingIdentifier = identifierMap.find(({ id }) => id === iamMember.member.id)?.identifier;
|
|
58
|
+
if (typeof updatingIdentifier !== 'string') {
|
|
59
|
+
throw new Error(`map not found. ${iamMember.member.name}`);
|
|
60
|
+
}
|
|
61
|
+
const identifierExists = typeof applicationIdentifier === 'string';
|
|
62
|
+
|
|
63
|
+
if (identifierExists) {
|
|
64
|
+
if (applicationIdentifier !== updatingIdentifier) {
|
|
65
|
+
throw new Error(`unexpected application identifier. ${iamMember.member.name}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log(
|
|
69
|
+
'identifier exists',
|
|
70
|
+
iamMember.project.id,
|
|
71
|
+
iamMember.member.name,
|
|
72
|
+
applicationIdentifier
|
|
73
|
+
);
|
|
74
|
+
} else {
|
|
75
|
+
console.log(
|
|
76
|
+
'migrating identifier...',
|
|
77
|
+
iamMember.project.id,
|
|
78
|
+
iamMember.member.name,
|
|
79
|
+
updatingIdentifier
|
|
80
|
+
);
|
|
81
|
+
await memberRepo.updateByMemberId({
|
|
82
|
+
project: { id: iamMember.project.id },
|
|
83
|
+
member: {
|
|
84
|
+
id: iamMember.member.id,
|
|
85
|
+
memberOf: iamMember.member.memberOf,
|
|
86
|
+
identifier: updatingIdentifier
|
|
87
|
+
},
|
|
88
|
+
$unset: {}
|
|
89
|
+
});
|
|
90
|
+
updated += 1;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
console.log(i, 'docs checked');
|
|
94
|
+
console.log('updated:', updated);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main()
|
|
98
|
+
.then()
|
|
99
|
+
.catch(console.error);
|
|
@@ -11,8 +11,8 @@ 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.
|
|
15
|
-
|
|
14
|
+
await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
15
|
+
await chevre.repository.Member.createInstance(mongoose.connection);
|
|
16
16
|
console.log('success!');
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
2
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
import { IDocType } from './mongoose/schemas/eventOffer';
|
|
5
|
+
type IUnset = {
|
|
6
|
+
[key in keyof IDocType]?: 1;
|
|
7
|
+
};
|
|
8
|
+
type IDocWithId = IDocType & {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
type IKeyOfProjection = keyof IDocType;
|
|
12
|
+
/**
|
|
13
|
+
* イベントオファーリポジトリ
|
|
14
|
+
*/
|
|
15
|
+
export declare class EventOfferRepo {
|
|
16
|
+
private readonly eventOfferModel;
|
|
17
|
+
constructor(connection: Connection);
|
|
18
|
+
static CREATE_MONGO_CONDITIONS(params: factory.eventOffer.ISearchConditions): FilterQuery<IDocType>[];
|
|
19
|
+
findEventOffers(params: factory.eventOffer.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
|
|
20
|
+
/**
|
|
21
|
+
* オファーコードとイベントIDをキーにして冪等置換
|
|
22
|
+
*/
|
|
23
|
+
upsertEventOffersByIdentifier(params: {
|
|
24
|
+
$set: Pick<IDocType, 'identifier' | 'itemOffered' | 'offeredBy' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough' | 'availableAtOrFrom'> & {
|
|
25
|
+
id?: never;
|
|
26
|
+
};
|
|
27
|
+
$unset: IUnset;
|
|
28
|
+
}[], options: {
|
|
29
|
+
/**
|
|
30
|
+
* falseの場合setOnInsertのみ
|
|
31
|
+
* trueの場合setのみ
|
|
32
|
+
*/
|
|
33
|
+
update: boolean;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
bulkWriteResult: BulkWriteResult;
|
|
36
|
+
modifiedProductOffers: {
|
|
37
|
+
id: string;
|
|
38
|
+
}[];
|
|
39
|
+
} | void>;
|
|
40
|
+
/**
|
|
41
|
+
* 販売者の提供するイベントオファーを削除する
|
|
42
|
+
*/
|
|
43
|
+
deleteEventOffersBySeller(params: {
|
|
44
|
+
project: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
seller: {
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
}): Promise<DeleteResult>;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EventOfferRepo = void 0;
|
|
13
|
+
const factory = require("../factory");
|
|
14
|
+
const settings_1 = require("../settings");
|
|
15
|
+
const eventOffer_1 = require("./mongoose/schemas/eventOffer");
|
|
16
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
17
|
+
'identifier',
|
|
18
|
+
'project',
|
|
19
|
+
'itemOffered',
|
|
20
|
+
'offeredBy',
|
|
21
|
+
'typeOf',
|
|
22
|
+
'validFrom',
|
|
23
|
+
'validThrough',
|
|
24
|
+
'availableAtOrFrom',
|
|
25
|
+
'seller'
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* イベントオファーリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class EventOfferRepo {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.eventOfferModel = connection.model(eventOffer_1.modelName, (0, eventOffer_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
36
|
+
const andConditions = [];
|
|
37
|
+
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
38
|
+
if (typeof idEq === 'string') {
|
|
39
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
40
|
+
}
|
|
41
|
+
const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
42
|
+
if (typeof projectIdEq === 'string') {
|
|
43
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
44
|
+
}
|
|
45
|
+
const identifierEq = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
46
|
+
if (typeof identifierEq === 'string') {
|
|
47
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
48
|
+
}
|
|
49
|
+
const identifierIn = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$in;
|
|
50
|
+
if (Array.isArray(identifierIn)) {
|
|
51
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
52
|
+
}
|
|
53
|
+
const itemOfferedIdEq = (_g = (_f = params.itemOffered) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
54
|
+
if (typeof itemOfferedIdEq === 'string') {
|
|
55
|
+
andConditions.push({ 'itemOffered.id': { $eq: itemOfferedIdEq } });
|
|
56
|
+
}
|
|
57
|
+
const itemOfferedIdIn = (_j = (_h = params.itemOffered) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
|
|
58
|
+
if (Array.isArray(itemOfferedIdIn)) {
|
|
59
|
+
andConditions.push({ 'itemOffered.id': { $in: itemOfferedIdIn } });
|
|
60
|
+
}
|
|
61
|
+
const availableAtOrFromIdentifierEq = (_l = (_k = params.availableAtOrFrom) === null || _k === void 0 ? void 0 : _k.identifier) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
62
|
+
if (typeof availableAtOrFromIdentifierEq === 'string') {
|
|
63
|
+
andConditions.push({ 'availableAtOrFrom.identifier': { $eq: availableAtOrFromIdentifierEq } });
|
|
64
|
+
}
|
|
65
|
+
const offeredByIdEq = (_o = (_m = params.offeredBy) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
66
|
+
if (typeof offeredByIdEq === 'string') {
|
|
67
|
+
andConditions.push({ 'offeredBy.id': { $exists: true, $eq: offeredByIdEq } });
|
|
68
|
+
}
|
|
69
|
+
const sellerByIdEq = (_q = (_p = params.seller) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
70
|
+
if (typeof sellerByIdEq === 'string') {
|
|
71
|
+
andConditions.push({ 'seller.id': { $eq: sellerByIdEq } });
|
|
72
|
+
}
|
|
73
|
+
const validFromLte = (_r = params.validFrom) === null || _r === void 0 ? void 0 : _r.$lte;
|
|
74
|
+
if (validFromLte instanceof Date) {
|
|
75
|
+
andConditions.push({ validFrom: { $lte: validFromLte } });
|
|
76
|
+
}
|
|
77
|
+
const validThroughGte = (_s = params.validThrough) === null || _s === void 0 ? void 0 : _s.$gte;
|
|
78
|
+
if (validThroughGte instanceof Date) {
|
|
79
|
+
andConditions.push({ validThrough: { $gte: validThroughGte } });
|
|
80
|
+
}
|
|
81
|
+
return andConditions;
|
|
82
|
+
}
|
|
83
|
+
findEventOffers(params, inclusion) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
var _a;
|
|
86
|
+
const conditions = EventOfferRepo.CREATE_MONGO_CONDITIONS(params);
|
|
87
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
88
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
89
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
93
|
+
}
|
|
94
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
95
|
+
const query = this.eventOfferModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
96
|
+
if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
|
|
97
|
+
query.sort({ validFrom: params.sort.validFrom });
|
|
98
|
+
}
|
|
99
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
100
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
101
|
+
query.limit(params.limit)
|
|
102
|
+
.skip(params.limit * (page - 1));
|
|
103
|
+
}
|
|
104
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
105
|
+
.lean()
|
|
106
|
+
.exec();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* オファーコードとイベントIDをキーにして冪等置換
|
|
111
|
+
*/
|
|
112
|
+
upsertEventOffersByIdentifier(params, options) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const { update } = options;
|
|
115
|
+
const bulkWriteOps = [];
|
|
116
|
+
const queryFilters = [];
|
|
117
|
+
if (Array.isArray(params)) {
|
|
118
|
+
params.forEach(({ $set, $unset }) => {
|
|
119
|
+
const { identifier, itemOffered, offeredBy, seller, project, validFrom, validThrough, availableAtOrFrom } = $set;
|
|
120
|
+
if (typeof identifier !== 'string' || identifier === '') {
|
|
121
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
122
|
+
}
|
|
123
|
+
if (typeof itemOffered.id !== 'string' || itemOffered.id === '') {
|
|
124
|
+
throw new factory.errors.ArgumentNull('itemOffered.id');
|
|
125
|
+
}
|
|
126
|
+
// リソースのユニークネスを保証するfilter
|
|
127
|
+
const filter = {
|
|
128
|
+
'project.id': { $eq: project.id },
|
|
129
|
+
'itemOffered.id': { $eq: itemOffered.id },
|
|
130
|
+
identifier: { $eq: identifier }
|
|
131
|
+
};
|
|
132
|
+
queryFilters.push({
|
|
133
|
+
'project.id': { $eq: project.id },
|
|
134
|
+
'itemOffered.id': { $eq: itemOffered.id },
|
|
135
|
+
identifier: { $eq: identifier }
|
|
136
|
+
});
|
|
137
|
+
if (update === true) {
|
|
138
|
+
const setFields = Object.assign({ validFrom,
|
|
139
|
+
validThrough,
|
|
140
|
+
availableAtOrFrom }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
|
|
141
|
+
const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
142
|
+
const updateOne = {
|
|
143
|
+
filter,
|
|
144
|
+
update: updateFilter,
|
|
145
|
+
upsert: false
|
|
146
|
+
};
|
|
147
|
+
bulkWriteOps.push({ updateOne });
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const setOnInsert = Object.assign({ itemOffered, identifier, project, seller, typeOf: factory.offerType.Offer, validFrom,
|
|
151
|
+
validThrough,
|
|
152
|
+
availableAtOrFrom }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
|
|
153
|
+
const updateFilter = {
|
|
154
|
+
$setOnInsert: setOnInsert
|
|
155
|
+
};
|
|
156
|
+
const updateOne = {
|
|
157
|
+
filter,
|
|
158
|
+
update: updateFilter,
|
|
159
|
+
upsert: true
|
|
160
|
+
};
|
|
161
|
+
bulkWriteOps.push({ updateOne });
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (bulkWriteOps.length > 0) {
|
|
166
|
+
const bulkWriteResult = yield this.eventOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
167
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
168
|
+
const modifiedProductOffers = yield this.eventOfferModel.find({ $or: queryFilters }, {
|
|
169
|
+
_id: 0,
|
|
170
|
+
id: { $toString: '$_id' }
|
|
171
|
+
})
|
|
172
|
+
.lean()
|
|
173
|
+
.exec();
|
|
174
|
+
return { bulkWriteResult, modifiedProductOffers };
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 販売者の提供するイベントオファーを削除する
|
|
180
|
+
*/
|
|
181
|
+
deleteEventOffersBySeller(params) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
return this.eventOfferModel.deleteMany({
|
|
184
|
+
'project.id': { $eq: params.project.id },
|
|
185
|
+
'seller.id': { $eq: params.seller.id }
|
|
186
|
+
})
|
|
187
|
+
.exec();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.EventOfferRepo = EventOfferRepo;
|
|
@@ -2,7 +2,13 @@ import type { Connection, FilterQuery } from 'mongoose';
|
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
import { IGlobalMember } from './mongoose/schemas/member/global';
|
|
4
4
|
type IKeyOfProjection = keyof factory.iam.IMember;
|
|
5
|
-
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'
|
|
5
|
+
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'> & {
|
|
6
|
+
/**
|
|
7
|
+
* アプリケーションコード
|
|
8
|
+
* 2025-11-13~
|
|
9
|
+
*/
|
|
10
|
+
identifier?: string;
|
|
11
|
+
};
|
|
6
12
|
/**
|
|
7
13
|
* IAMメンバーリポジトリ
|
|
8
14
|
*/
|
|
@@ -35,6 +41,13 @@ export declare class MemberRepo {
|
|
|
35
41
|
name?: {
|
|
36
42
|
$regex?: string;
|
|
37
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* アプリケーションコード
|
|
46
|
+
* 2025-11-15~
|
|
47
|
+
*/
|
|
48
|
+
identifier?: {
|
|
49
|
+
$eq?: string;
|
|
50
|
+
};
|
|
38
51
|
};
|
|
39
52
|
}): Promise<{
|
|
40
53
|
member: ICustomerMember;
|
|
@@ -87,6 +100,10 @@ export declare class MemberRepo {
|
|
|
87
100
|
hasRole?: factory.iam.IMemberRole[];
|
|
88
101
|
image?: string;
|
|
89
102
|
name?: string;
|
|
103
|
+
/**
|
|
104
|
+
* アプリケーションコード
|
|
105
|
+
*/
|
|
106
|
+
identifier?: string;
|
|
90
107
|
};
|
|
91
108
|
$unset: {
|
|
92
109
|
'member.member'?: 1;
|
|
@@ -30,7 +30,7 @@ class MemberRepo {
|
|
|
30
30
|
}
|
|
31
31
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
32
32
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
34
34
|
const andConditions = [];
|
|
35
35
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
36
36
|
if (typeof idEq === 'string') {
|
|
@@ -64,7 +64,11 @@ class MemberRepo {
|
|
|
64
64
|
if (Array.isArray(memberIdIn)) {
|
|
65
65
|
andConditions.push({ 'member.id': { $in: memberIdIn } });
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const memberIdentifierEq = (_u = (_t = params.member) === null || _t === void 0 ? void 0 : _t.identifier) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
68
|
+
if (typeof memberIdentifierEq === 'string') {
|
|
69
|
+
andConditions.push({ 'member.identifier': { $exists: true, $eq: memberIdentifierEq } });
|
|
70
|
+
}
|
|
71
|
+
const memberNameRegex = (_w = (_v = params.member) === null || _v === void 0 ? void 0 : _v.name) === null || _w === void 0 ? void 0 : _w.$regex;
|
|
68
72
|
if (typeof memberNameRegex === 'string' && memberNameRegex.length > 0) {
|
|
69
73
|
andConditions.push({
|
|
70
74
|
'member.name': {
|
|
@@ -73,7 +77,7 @@ class MemberRepo {
|
|
|
73
77
|
}
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
|
-
const memberHasRoleRoleNameEq = (
|
|
80
|
+
const memberHasRoleRoleNameEq = (_z = (_y = (_x = params.member) === null || _x === void 0 ? void 0 : _x.hasRole) === null || _y === void 0 ? void 0 : _y.roleName) === null || _z === void 0 ? void 0 : _z.$eq;
|
|
77
81
|
if (typeof memberHasRoleRoleNameEq === 'string') {
|
|
78
82
|
andConditions.push({
|
|
79
83
|
'member.hasRole.roleName': {
|
|
@@ -82,7 +86,7 @@ class MemberRepo {
|
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
|
-
const memberHasRoleRoleNameIn = (
|
|
89
|
+
const memberHasRoleRoleNameIn = (_2 = (_1 = (_0 = params.member) === null || _0 === void 0 ? void 0 : _0.hasRole) === null || _1 === void 0 ? void 0 : _1.roleName) === null || _2 === void 0 ? void 0 : _2.$in;
|
|
86
90
|
if (Array.isArray(memberHasRoleRoleNameIn)) {
|
|
87
91
|
andConditions.push({
|
|
88
92
|
'member.hasRole.roleName': {
|
|
@@ -110,7 +114,7 @@ class MemberRepo {
|
|
|
110
114
|
*/
|
|
111
115
|
searchCustomerMembers(params) {
|
|
112
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
114
118
|
if (typeof params.project.id !== 'string' || params.project.id === '') {
|
|
115
119
|
throw new factory.errors.ArgumentNull('project.id');
|
|
116
120
|
}
|
|
@@ -128,7 +132,8 @@ class MemberRepo {
|
|
|
128
132
|
}
|
|
129
133
|
},
|
|
130
134
|
id: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.member) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') ? { $eq: params.member.id.$eq } : undefined), (Array.isArray((_d = (_c = params.member) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in)) ? { $in: params.member.id.$in } : undefined),
|
|
131
|
-
|
|
135
|
+
identifier: Object.assign({}, (typeof ((_f = (_e = params.member) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$eq) === 'string') ? { $eq: params.member.identifier.$eq } : undefined),
|
|
136
|
+
name: Object.assign({}, (typeof ((_h = (_g = params.member) === null || _g === void 0 ? void 0 : _g.name) === null || _h === void 0 ? void 0 : _h.$regex) === 'string') ? { $regex: params.member.name.$regex } : undefined)
|
|
132
137
|
}
|
|
133
138
|
});
|
|
134
139
|
const projection = {
|
|
@@ -138,6 +143,7 @@ class MemberRepo {
|
|
|
138
143
|
// typeOf: 'WebApplication',
|
|
139
144
|
hasRole: '$member.hasRole',
|
|
140
145
|
id: '$member.id',
|
|
146
|
+
identifier: '$member.identifier',
|
|
141
147
|
member: '$member.member',
|
|
142
148
|
memberOf: '$member.memberOf',
|
|
143
149
|
name: '$member.name'
|
|
@@ -154,7 +160,7 @@ class MemberRepo {
|
|
|
154
160
|
},
|
|
155
161
|
{ $project: projection }
|
|
156
162
|
]);
|
|
157
|
-
if (typeof ((
|
|
163
|
+
if (typeof ((_j = params.sort) === null || _j === void 0 ? void 0 : _j['member.id']) === 'number') {
|
|
158
164
|
aggregate.sort(params.sort);
|
|
159
165
|
}
|
|
160
166
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
@@ -259,7 +265,7 @@ class MemberRepo {
|
|
|
259
265
|
'member.memberOf.id': { $eq: params.member.memberOf.id },
|
|
260
266
|
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
|
|
261
267
|
}, {
|
|
262
|
-
$set: Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined
|
|
268
|
+
$set: Object.assign(Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined), (typeof params.member.identifier === 'string') ? { 'member.identifier': params.member.identifier } : undefined
|
|
263
269
|
// discontinue(2025-01-14~)
|
|
264
270
|
// ...(Array.isArray(params.member.member)) ? { 'member.member': params.member.member } : undefined
|
|
265
271
|
),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IDocType = factory.eventOffer.IEventOffer;
|
|
4
|
+
type IModel = Model<IDocType>;
|
|
5
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
|
+
declare const modelName = "EventOffer";
|
|
8
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|