@chevre/domain 23.1.0-alpha.5 → 23.1.0-alpha.6
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 +1 -0
- package/example/src/chevre/authorizeEventServiceOffer.ts +1 -0
- package/lib/chevre/repo/eventOffer.js +9 -5
- package/lib/chevre/repo/member.d.ts +7 -1
- package/lib/chevre/repo/member.js +1 -0
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +1 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +62 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +2 -18
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
- package/package.json +1 -1
|
@@ -102,6 +102,7 @@ async function main() {
|
|
|
102
102
|
eventOffer: await chevre.repository.EventOffer.createInstance(mongoose.connection),
|
|
103
103
|
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
104
104
|
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
105
|
+
member: await chevre.repository.Member.createInstance(mongoose.connection),
|
|
105
106
|
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
106
107
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
107
108
|
offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
@@ -57,6 +57,7 @@ async function main() {
|
|
|
57
57
|
eventOffer: await chevre.repository.EventOffer.createInstance(mongoose.connection),
|
|
58
58
|
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
59
59
|
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
60
|
+
member: await chevre.repository.Member.createInstance(mongoose.connection),
|
|
60
61
|
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
61
62
|
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
|
|
62
63
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
@@ -32,7 +32,7 @@ class EventOfferRepo {
|
|
|
32
32
|
this.eventOfferModel = connection.model(eventOffer_1.modelName, (0, eventOffer_1.createSchema)());
|
|
33
33
|
}
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
36
36
|
const andConditions = [];
|
|
37
37
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
38
38
|
if (typeof idEq === 'string') {
|
|
@@ -58,19 +58,23 @@ class EventOfferRepo {
|
|
|
58
58
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
59
59
|
andConditions.push({ 'itemOffered.id': { $in: itemOfferedIdIn } });
|
|
60
60
|
}
|
|
61
|
-
const
|
|
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;
|
|
62
66
|
if (typeof offeredByIdEq === 'string') {
|
|
63
67
|
andConditions.push({ 'offeredBy.id': { $exists: true, $eq: offeredByIdEq } });
|
|
64
68
|
}
|
|
65
|
-
const sellerByIdEq = (
|
|
69
|
+
const sellerByIdEq = (_q = (_p = params.seller) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
66
70
|
if (typeof sellerByIdEq === 'string') {
|
|
67
71
|
andConditions.push({ 'seller.id': { $eq: sellerByIdEq } });
|
|
68
72
|
}
|
|
69
|
-
const validFromLte = (
|
|
73
|
+
const validFromLte = (_r = params.validFrom) === null || _r === void 0 ? void 0 : _r.$lte;
|
|
70
74
|
if (validFromLte instanceof Date) {
|
|
71
75
|
andConditions.push({ validFrom: { $lte: validFromLte } });
|
|
72
76
|
}
|
|
73
|
-
const validThroughGte = (
|
|
77
|
+
const validThroughGte = (_s = params.validThrough) === null || _s === void 0 ? void 0 : _s.$gte;
|
|
74
78
|
if (validThroughGte instanceof Date) {
|
|
75
79
|
andConditions.push({ validThrough: { $gte: validThroughGte } });
|
|
76
80
|
}
|
|
@@ -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
|
*/
|
|
@@ -6,6 +6,7 @@ import type { EventRepo } from '../../../repo/event';
|
|
|
6
6
|
import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
7
7
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
8
8
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
9
|
+
import type { MemberRepo } from '../../../repo/member';
|
|
9
10
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
10
11
|
import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
|
|
11
12
|
import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
@@ -27,6 +28,7 @@ interface IStartOperationRepos {
|
|
|
27
28
|
eventOffer: EventOfferRepo;
|
|
28
29
|
eventSeries: EventSeriesRepo;
|
|
29
30
|
issuer: IssuerRepo;
|
|
31
|
+
member: MemberRepo;
|
|
30
32
|
memberProgram: MemberProgramRepo;
|
|
31
33
|
offer: OfferRepo;
|
|
32
34
|
offerCatalog: OfferCatalogRepo;
|
package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import { IMinimizedIndividualEvent } from '../../../../factory/event';
|
|
3
|
+
import type { EventOfferRepo } from '../../../../repo/eventOffer';
|
|
4
|
+
import type { MemberRepo } from '../../../../repo/member';
|
|
5
|
+
/**
|
|
6
|
+
* リクエストから拡張イベントオファーを決定する
|
|
7
|
+
*/
|
|
8
|
+
declare function fixExtendedEventOffer(params: {
|
|
9
|
+
event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project' | 'identifier'>;
|
|
10
|
+
now: Date;
|
|
11
|
+
availableAt: {
|
|
12
|
+
/**
|
|
13
|
+
* 販売アプリケーションID
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
object: factory.assetTransaction.reserve.IObjectWithoutDetail;
|
|
18
|
+
}): (repos: {
|
|
19
|
+
eventOffer: EventOfferRepo;
|
|
20
|
+
member: MemberRepo;
|
|
21
|
+
}) => Promise<Pick<factory.eventOffer.IEventOffer, "identifier" | "itemOffered" | "typeOf" | "offeredBy" | "validFrom" | "validThrough">>;
|
|
22
|
+
export { fixExtendedEventOffer };
|
package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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.fixExtendedEventOffer = fixExtendedEventOffer;
|
|
13
|
+
const moment = require("moment");
|
|
14
|
+
const factory = require("../../../../factory");
|
|
15
|
+
/**
|
|
16
|
+
* リクエストから拡張イベントオファーを決定する
|
|
17
|
+
*/
|
|
18
|
+
function fixExtendedEventOffer(params) {
|
|
19
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const { event, availableAt } = params;
|
|
22
|
+
const acceptedDate = moment(params.now);
|
|
23
|
+
// リクエストによるオファーコード指定が必須
|
|
24
|
+
const eventOfferIdentifierMustBe = (_b = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.offers) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
25
|
+
if (typeof eventOfferIdentifierMustBe !== 'string' || eventOfferIdentifierMustBe === '') {
|
|
26
|
+
throw new factory.errors.ArgumentNull('reservationFor.offers.identifier');
|
|
27
|
+
}
|
|
28
|
+
// アプリケーションIDからアプリケーションコードを参照
|
|
29
|
+
const existingCustomerMember = (yield repos.member.searchCustomerMembers({
|
|
30
|
+
project: { id: event.project.id },
|
|
31
|
+
limit: 1,
|
|
32
|
+
page: 1,
|
|
33
|
+
member: {
|
|
34
|
+
id: { $eq: availableAt.id }
|
|
35
|
+
}
|
|
36
|
+
})).shift();
|
|
37
|
+
if (existingCustomerMember === undefined) {
|
|
38
|
+
throw new factory.errors.NotFound(`Member: ${availableAt.id}`);
|
|
39
|
+
}
|
|
40
|
+
// tslint:disable-next-line:no-console
|
|
41
|
+
console.log('existingCustomerMember found:', JSON.stringify(existingCustomerMember));
|
|
42
|
+
const applicationIdentifier = existingCustomerMember.member.identifier;
|
|
43
|
+
if (typeof applicationIdentifier !== 'string') {
|
|
44
|
+
throw new factory.errors.NotFound(`member.identifier of ${availableAt.id}`);
|
|
45
|
+
}
|
|
46
|
+
// アプリケーションコードで利用可能な拡張オファーを検索
|
|
47
|
+
const existingEventOffer = (yield repos.eventOffer.findEventOffers({
|
|
48
|
+
limit: 1,
|
|
49
|
+
page: 1,
|
|
50
|
+
project: { id: { $eq: event.project.id } }, // プロジェクト
|
|
51
|
+
validFrom: { $lte: acceptedDate.toDate() },
|
|
52
|
+
validThrough: { $gte: acceptedDate.toDate() },
|
|
53
|
+
itemOffered: { id: { $eq: event.id } }, // 対象イベント
|
|
54
|
+
identifier: { $eq: eventOfferIdentifierMustBe }, // オファーコード
|
|
55
|
+
availableAtOrFrom: { identifier: { $eq: applicationIdentifier } } // アプリケーションコード
|
|
56
|
+
}, ['identifier', 'itemOffered', 'offeredBy', 'typeOf', 'validFrom', 'validThrough'])).shift();
|
|
57
|
+
if (existingEventOffer === undefined) {
|
|
58
|
+
throw new factory.errors.NotFound(`eventOffer: ${eventOfferIdentifierMustBe}`);
|
|
59
|
+
}
|
|
60
|
+
return existingEventOffer;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -2,6 +2,7 @@ import * as factory from '../../../factory';
|
|
|
2
2
|
import { IMinimizedIndividualEvent } from '../../../factory/event';
|
|
3
3
|
import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
4
4
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
5
|
+
import type { MemberRepo } from '../../../repo/member';
|
|
5
6
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
6
7
|
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
7
8
|
declare function validateStartRequest(params: {
|
|
@@ -22,6 +23,7 @@ declare function validateStartRequest(params: {
|
|
|
22
23
|
}): (repos: {
|
|
23
24
|
eventOffer: EventOfferRepo;
|
|
24
25
|
issuer: IssuerRepo;
|
|
26
|
+
member: MemberRepo;
|
|
25
27
|
memberProgram: MemberProgramRepo;
|
|
26
28
|
productOffer: ProductOfferRepo;
|
|
27
29
|
}) => Promise<void>;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.validateStartRequest = validateStartRequest;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
|
+
const fixExtendedEventOffer_1 = require("./validateStartRequest/fixExtendedEventOffer");
|
|
15
16
|
const validateIssuedOfferIfExists_1 = require("./validateStartRequest/validateIssuedOfferIfExists");
|
|
16
17
|
const validateMemberTierIfExists_1 = require("./validateStartRequest/validateMemberTierIfExists");
|
|
17
18
|
function validateStartRequest(params) {
|
|
@@ -40,7 +41,6 @@ function validateStartRequest(params) {
|
|
|
40
41
|
*/
|
|
41
42
|
function validateApplicationOffer(params) {
|
|
42
43
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
var _a, _b;
|
|
44
44
|
const { event, availableAt } = params;
|
|
45
45
|
const acceptedDate = moment(params.now);
|
|
46
46
|
const eventOffers = event.offers;
|
|
@@ -70,23 +70,7 @@ function validateApplicationOffer(params) {
|
|
|
70
70
|
}
|
|
71
71
|
// support extensibleEventOffer(2025-11-11~)
|
|
72
72
|
if (eventOffers.typeOf === factory.offerType.AggregateOffer) {
|
|
73
|
-
|
|
74
|
-
const eventOfferIdentifierMustBe = (_b = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.offers) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
75
|
-
if (typeof eventOfferIdentifierMustBe !== 'string' || eventOfferIdentifierMustBe === '') {
|
|
76
|
-
throw new factory.errors.ArgumentNull('reservationFor.offers.identifier');
|
|
77
|
-
}
|
|
78
|
-
const existingEventOffer = (yield repos.eventOffer.findEventOffers({
|
|
79
|
-
limit: 1,
|
|
80
|
-
page: 1,
|
|
81
|
-
project: { id: { $eq: event.project.id } }, // プロジェクト
|
|
82
|
-
validFrom: { $lte: acceptedDate.toDate() },
|
|
83
|
-
validThrough: { $gte: acceptedDate.toDate() },
|
|
84
|
-
itemOffered: { id: { $eq: event.id } }, // 対象イベント
|
|
85
|
-
identifier: { $eq: eventOfferIdentifierMustBe } // オファーコード
|
|
86
|
-
}, ['identifier', 'itemOffered', 'offeredBy', 'typeOf', 'validFrom', 'validThrough'])).shift();
|
|
87
|
-
if (existingEventOffer === undefined) {
|
|
88
|
-
throw new factory.errors.NotFound(`eventOffer: ${eventOfferIdentifierMustBe}`);
|
|
89
|
-
}
|
|
73
|
+
const existingEventOffer = yield (0, fixExtendedEventOffer_1.fixExtendedEventOffer)(params)(repos);
|
|
90
74
|
// 拡張可能なオファー設定の場合のみ、オファートークンを検証する(2025-11-11~)
|
|
91
75
|
yield (0, validateIssuedOfferIfExists_1.validateIssuedOfferIfExists)({
|
|
92
76
|
event,
|
|
@@ -8,6 +8,7 @@ import type { EventRepo, IMinimizedIndividualEvent } from '../../../../repo/even
|
|
|
8
8
|
import type { EventOfferRepo } from '../../../../repo/eventOffer';
|
|
9
9
|
import { EventSeriesRepo } from '../../../../repo/eventSeries';
|
|
10
10
|
import type { IssuerRepo } from '../../../../repo/issuer';
|
|
11
|
+
import type { MemberRepo } from '../../../../repo/member';
|
|
11
12
|
import type { MemberProgramRepo } from '../../../../repo/memberProgram';
|
|
12
13
|
import type { OfferRepo } from '../../../../repo/offer/unitPriceInCatalog';
|
|
13
14
|
import type { OfferCatalogRepo } from '../../../../repo/offerCatalog';
|
|
@@ -57,6 +58,7 @@ declare function processStartReserve4chevre(params: {
|
|
|
57
58
|
eventOffer: EventOfferRepo;
|
|
58
59
|
eventSeries: EventSeriesRepo;
|
|
59
60
|
issuer: IssuerRepo;
|
|
61
|
+
member: MemberRepo;
|
|
60
62
|
memberProgram: MemberProgramRepo;
|
|
61
63
|
offer: OfferRepo;
|
|
62
64
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -8,6 +8,7 @@ import type { EventRepo } from '../../../repo/event';
|
|
|
8
8
|
import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
9
9
|
import { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
10
10
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
11
|
+
import type { MemberRepo } from '../../../repo/member';
|
|
11
12
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
12
13
|
import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
|
|
13
14
|
import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
@@ -36,6 +37,7 @@ interface IAuthorizeRepos {
|
|
|
36
37
|
eventOffer: EventOfferRepo;
|
|
37
38
|
eventSeries: EventSeriesRepo;
|
|
38
39
|
issuer: IssuerRepo;
|
|
40
|
+
member: MemberRepo;
|
|
39
41
|
memberProgram: MemberProgramRepo;
|
|
40
42
|
stockHolder: StockHolderRepo;
|
|
41
43
|
offer: OfferRepo;
|
package/package.json
CHANGED