@chevre/domain 28.1.0-alpha.0 → 28.1.0-alpha.2
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/lib/chevre/repo/adminAcceptedOffer.d.ts +2 -13
- package/lib/chevre/repo/adminAcceptedOffer.js +26 -31
- package/lib/chevre/repo/factory/reservation/minimizeReservationFor.js +0 -5
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +20 -20
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/repo/offerCatalog.d.ts +4 -4
- package/lib/chevre/repo/offerCatalog.js +19 -19
- package/lib/chevre/repo/offerCatalogItem.d.ts +1 -1
- package/lib/chevre/repo/offerCatalogItem.js +9 -9
- package/lib/chevre/service/notification/triggerWebhook/getGoogleIdTokenClient.d.ts +5 -0
- package/lib/chevre/service/notification/triggerWebhook/getGoogleIdTokenClient.js +39 -0
- package/lib/chevre/service/notification/triggerWebhook.js +33 -16
- package/lib/chevre/service/offer/event/searchOfferCatalogItems.d.ts +1 -1
- package/package.json +3 -2
|
@@ -34,12 +34,6 @@ export declare class AdminAcceptedOfferRepo extends AcceptedOfferInReserveRepo {
|
|
|
34
34
|
* 索条件を最小化(2026-06-05~)
|
|
35
35
|
*/
|
|
36
36
|
params: Pick<factory.order.ISearchConditions, 'limit' | 'orderNumbers' | 'page' | 'project' | 'provider' | 'sort' | 'orderDate'>, projection: IProjection4searchWithUnwoundAcceptedOffers, options: {
|
|
37
|
-
/**
|
|
38
|
-
* reservationForをid属性のみにするオプション
|
|
39
|
-
* 2026-08-31~
|
|
40
|
-
* always true(2026-10-08~)
|
|
41
|
-
*/
|
|
42
|
-
minimizeReservationFor: true;
|
|
43
37
|
/**
|
|
44
38
|
* reservedTicket以外の属性を除外するオプション
|
|
45
39
|
* 2026-10-08~
|
|
@@ -67,17 +61,12 @@ export declare class AdminAcceptedOfferRepo extends AcceptedOfferInReserveRepo {
|
|
|
67
61
|
id: string;
|
|
68
62
|
};
|
|
69
63
|
}, options: {
|
|
70
|
-
/**
|
|
71
|
-
* reservationForをid属性のみにするオプション
|
|
72
|
-
* 2026-08-31~
|
|
73
|
-
* always true(2026-10-08~)
|
|
74
|
-
*/
|
|
75
|
-
minimizeReservationFor: true;
|
|
76
64
|
/**
|
|
77
65
|
* reservedTicket以外の属性を除外するオプション
|
|
78
66
|
* 2026-10-08~
|
|
67
|
+
* always true(2026-10-23~)
|
|
79
68
|
*/
|
|
80
|
-
onlyReservedTicket:
|
|
69
|
+
onlyReservedTicket: true;
|
|
81
70
|
/**
|
|
82
71
|
* reservedTicketからticketTypeを除外するオプション
|
|
83
72
|
* 2026-10-23~
|
|
@@ -7,45 +7,40 @@ const settings_1 = require("../settings");
|
|
|
7
7
|
const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
|
|
8
8
|
const order_2 = require("./order");
|
|
9
9
|
function minimizeItemOffered(itemOffered, options) {
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return {
|
|
34
|
-
id, reservationNumber, reservedTicket,
|
|
35
|
-
typeOf: itemOfferedWithoutEvent.typeOf,
|
|
36
|
-
reservationFor: { id: reservationFor.id, typeOf: reservationFor.typeOf }
|
|
37
|
-
};
|
|
38
|
-
}
|
|
10
|
+
const { onlyReservedTicket, minimizeReservedTicket } = options;
|
|
11
|
+
const { reservationFor, ...itemOfferedWithoutEvent } = itemOffered;
|
|
12
|
+
if (onlyReservedTicket) {
|
|
13
|
+
const { id, reservationNumber, reservedTicket } = itemOfferedWithoutEvent;
|
|
14
|
+
// support minimizeReservedTicket(2026-10-23~)
|
|
15
|
+
if (minimizeReservedTicket) {
|
|
16
|
+
const { coaReserveAmount, coaTicketInfo, ticketToken, identifier, ticketedSeat } = reservedTicket;
|
|
17
|
+
return {
|
|
18
|
+
id, reservationNumber,
|
|
19
|
+
reservedTicket: {
|
|
20
|
+
typeOf: reservedTicket.typeOf,
|
|
21
|
+
identifier,
|
|
22
|
+
...(typeof ticketedSeat?.typeOf === 'string') && { ticketedSeat },
|
|
23
|
+
...(coaReserveAmount !== undefined) && { coaReserveAmount },
|
|
24
|
+
...(coaTicketInfo !== undefined) && { coaTicketInfo },
|
|
25
|
+
...(typeof ticketToken === 'string') && { ticketToken },
|
|
26
|
+
},
|
|
27
|
+
typeOf: itemOfferedWithoutEvent.typeOf,
|
|
28
|
+
reservationFor: { id: reservationFor.id, typeOf: reservationFor.typeOf }
|
|
29
|
+
};
|
|
39
30
|
}
|
|
40
31
|
else {
|
|
41
32
|
return {
|
|
42
|
-
|
|
33
|
+
id, reservationNumber, reservedTicket,
|
|
34
|
+
typeOf: itemOfferedWithoutEvent.typeOf,
|
|
43
35
|
reservationFor: { id: reservationFor.id, typeOf: reservationFor.typeOf }
|
|
44
36
|
};
|
|
45
37
|
}
|
|
46
38
|
}
|
|
47
39
|
else {
|
|
48
|
-
return
|
|
40
|
+
return {
|
|
41
|
+
...itemOfferedWithoutEvent,
|
|
42
|
+
reservationFor: { id: reservationFor.id, typeOf: reservationFor.typeOf }
|
|
43
|
+
};
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
46
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.minimizeReservationFor = minimizeReservationFor;
|
|
4
|
-
const USE_DEPRECATED_RESERVATION_FOR = process.env.USE_DEPRECATED_RESERVATION_FOR === '1';
|
|
5
4
|
function minimizeWorkPerformed(params) {
|
|
6
5
|
const { identifier, id, typeOf, version } = params;
|
|
7
6
|
return {
|
|
@@ -29,10 +28,6 @@ function minimizeRoom(params) {
|
|
|
29
28
|
return { branchCode, typeOf };
|
|
30
29
|
}
|
|
31
30
|
function minimizeReservationFor(params) {
|
|
32
|
-
if (USE_DEPRECATED_RESERVATION_FOR) {
|
|
33
|
-
// 互換性維持対応として
|
|
34
|
-
return { minimizedReservationFor: params }; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
35
|
-
}
|
|
36
31
|
const { name: _name, doorTime: _doorTime, superEvent, location, ...reservationForNoName } = params;
|
|
37
32
|
const minimizedReservationFor = {
|
|
38
33
|
...reservationForNoName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import { IVirtuals } from '../virtuals';
|
|
3
3
|
import { factory } from '../../../factory';
|
|
4
|
-
export type IDocType =
|
|
4
|
+
export type IDocType = Pick<factory.offerCatalog.IOfferCatalog, 'description' | 'identifier' | 'itemListElement' | 'itemOffered' | 'name' | 'project' | 'typeOf'> & {
|
|
5
5
|
_id: string;
|
|
6
6
|
dateSynced?: Date;
|
|
7
7
|
};
|
|
@@ -13,11 +13,10 @@ const schemaDefinition = {
|
|
|
13
13
|
identifier: { type: String, required: true },
|
|
14
14
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
15
15
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
16
|
-
// alternateName: SchemaTypes.Mixed,
|
|
17
16
|
typeOf: { type: String, required: true },
|
|
18
17
|
itemListElement: [mongoose_1.SchemaTypes.Mixed],
|
|
19
18
|
itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
20
|
-
additionalProperty: [
|
|
19
|
+
// additionalProperty: [SchemaTypes.Mixed], // TODO discontinue(2026-10-31~)
|
|
21
20
|
dateSynced: Date // 追加(2023-09-13~)
|
|
22
21
|
};
|
|
23
22
|
const schemaOptions = {
|
|
@@ -78,24 +77,6 @@ const indexes = [
|
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
],
|
|
81
|
-
[
|
|
82
|
-
{ 'itemOffered.serviceType.codeValue': 1, identifier: 1 },
|
|
83
|
-
{
|
|
84
|
-
name: 'searchByItemOfferedServiceTypeCodeValue',
|
|
85
|
-
partialFilterExpression: {
|
|
86
|
-
'itemOffered.serviceType.codeValue': { $exists: true }
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
{ additionalProperty: 1, identifier: 1 },
|
|
92
|
-
{
|
|
93
|
-
name: 'searchByAdditionalProperty',
|
|
94
|
-
partialFilterExpression: {
|
|
95
|
-
additionalProperty: { $exists: true }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
],
|
|
99
80
|
[
|
|
100
81
|
// add unique index(2024-11-12~)
|
|
101
82
|
{ 'project.id': 1, identifier: 1 },
|
|
@@ -104,6 +85,25 @@ const indexes = [
|
|
|
104
85
|
name: 'uniqueIdentifier'
|
|
105
86
|
}
|
|
106
87
|
]
|
|
88
|
+
// 以下廃止(2026-10-31~)
|
|
89
|
+
// [
|
|
90
|
+
// { 'itemOffered.serviceType.codeValue': 1, identifier: 1 },
|
|
91
|
+
// {
|
|
92
|
+
// name: 'searchByItemOfferedServiceTypeCodeValue',
|
|
93
|
+
// partialFilterExpression: {
|
|
94
|
+
// 'itemOffered.serviceType.codeValue': { $exists: true }
|
|
95
|
+
// }
|
|
96
|
+
// }
|
|
97
|
+
// ],
|
|
98
|
+
// [
|
|
99
|
+
// { additionalProperty: 1, identifier: 1 },
|
|
100
|
+
// {
|
|
101
|
+
// name: 'searchByAdditionalProperty',
|
|
102
|
+
// partialFilterExpression: {
|
|
103
|
+
// additionalProperty: { $exists: true }
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
106
|
+
// ],
|
|
107
107
|
];
|
|
108
108
|
exports.indexes = indexes;
|
|
109
109
|
/**
|
|
@@ -69,6 +69,10 @@ interface ITriggerWebhookSettings {
|
|
|
69
69
|
headerIdentifier?: string;
|
|
70
70
|
retryCountMax?: number;
|
|
71
71
|
retryIntervalInMS?: number;
|
|
72
|
+
/**
|
|
73
|
+
* support(2026-10-30~)
|
|
74
|
+
*/
|
|
75
|
+
googleTargetAudience?: string;
|
|
72
76
|
}
|
|
73
77
|
export interface IWaiterSettings {
|
|
74
78
|
disabled?: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Connection, FilterQuery, mongo } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
3
|
import { IDocType } from './mongoose/schemas/offerCatalog';
|
|
4
|
-
export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered'
|
|
4
|
+
export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered'> & {
|
|
5
5
|
numberOfItems?: number;
|
|
6
6
|
itemListElementTypeOf: factory.offerType.Offer | 'OfferCatalog';
|
|
7
7
|
};
|
|
8
|
-
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | '
|
|
8
|
+
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced';
|
|
9
9
|
/**
|
|
10
10
|
* カタログリポジトリ
|
|
11
11
|
*/
|
|
@@ -168,14 +168,14 @@ export declare class OfferCatalogRepo {
|
|
|
168
168
|
id: string;
|
|
169
169
|
};
|
|
170
170
|
}): Promise<void>;
|
|
171
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> &
|
|
171
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.offerCatalog.IOfferCatalog, "identifier" | "name" | "typeOf" | "description" | "itemOffered" | "project" | "itemListElement"> & {
|
|
172
172
|
_id: string;
|
|
173
173
|
dateSynced?: Date;
|
|
174
174
|
} & Required<{
|
|
175
175
|
_id: string;
|
|
176
176
|
}> & {
|
|
177
177
|
__v: number;
|
|
178
|
-
}, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> &
|
|
178
|
+
}, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Pick<factory.offerCatalog.IOfferCatalog, "identifier" | "name" | "typeOf" | "description" | "itemOffered" | "project" | "itemListElement"> & {
|
|
179
179
|
_id: string;
|
|
180
180
|
dateSynced?: Date;
|
|
181
181
|
} & Required<{
|
|
@@ -10,7 +10,7 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
10
10
|
'typeOf',
|
|
11
11
|
'identifier',
|
|
12
12
|
'itemOffered',
|
|
13
|
-
'additionalProperty',
|
|
13
|
+
// 'additionalProperty',
|
|
14
14
|
'numberOfItems',
|
|
15
15
|
'itemListElementTypeOf',
|
|
16
16
|
'dateSynced'
|
|
@@ -104,24 +104,24 @@ class OfferCatalogRepo {
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
const itemOfferedServiceTypeCodeValueEq = params.itemOffered?.serviceType?.codeValue?.$eq;
|
|
108
|
-
if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
|
|
117
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
107
|
+
// const itemOfferedServiceTypeCodeValueEq = params.itemOffered?.serviceType?.codeValue?.$eq;
|
|
108
|
+
// if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
|
|
109
|
+
// andConditions.push({
|
|
110
|
+
// 'itemOffered.serviceType.codeValue': {
|
|
111
|
+
// $exists: true,
|
|
112
|
+
// $eq: itemOfferedServiceTypeCodeValueEq
|
|
113
|
+
// }
|
|
114
|
+
// });
|
|
115
|
+
// }
|
|
116
|
+
// const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
|
|
117
|
+
// if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
118
|
+
// andConditions.push({
|
|
119
|
+
// additionalProperty: {
|
|
120
|
+
// $exists: true,
|
|
121
|
+
// $elemMatch: additionalPropertyElemMatch
|
|
122
|
+
// }
|
|
123
|
+
// });
|
|
124
|
+
// }
|
|
125
125
|
return andConditions;
|
|
126
126
|
}
|
|
127
127
|
async save(params) {
|
|
@@ -6,7 +6,7 @@ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, '
|
|
|
6
6
|
numberOfItems?: number;
|
|
7
7
|
itemListElementTypeOf: factory.offerType.Offer;
|
|
8
8
|
};
|
|
9
|
-
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | '
|
|
9
|
+
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced' | 'relatedOffer';
|
|
10
10
|
/**
|
|
11
11
|
* サブカタログリポジトリ
|
|
12
12
|
*/
|
|
@@ -11,7 +11,7 @@ const AVAILABLE_PROJECT_FIELDS = [
|
|
|
11
11
|
'typeOf',
|
|
12
12
|
'identifier',
|
|
13
13
|
'itemOffered',
|
|
14
|
-
'additionalProperty',
|
|
14
|
+
// 'additionalProperty',
|
|
15
15
|
'numberOfItems',
|
|
16
16
|
'itemListElementTypeOf',
|
|
17
17
|
'dateSynced',
|
|
@@ -81,14 +81,14 @@ class OfferCatalogItemRepo {
|
|
|
81
81
|
if (typeof itemOfferedTypeOfEq === 'string') {
|
|
82
82
|
andConditions.push({ 'itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq } });
|
|
83
83
|
}
|
|
84
|
-
const itemOfferedServiceTypeCodeValueEq = params.itemOffered?.serviceType?.codeValue?.$eq;
|
|
85
|
-
if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
|
|
89
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
90
|
-
|
|
91
|
-
}
|
|
84
|
+
// const itemOfferedServiceTypeCodeValueEq = params.itemOffered?.serviceType?.codeValue?.$eq;
|
|
85
|
+
// if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
|
|
86
|
+
// andConditions.push({ 'itemOffered.serviceType.codeValue': { $exists: true, $eq: itemOfferedServiceTypeCodeValueEq } });
|
|
87
|
+
// }
|
|
88
|
+
// const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
|
|
89
|
+
// if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
90
|
+
// andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
|
|
91
|
+
// }
|
|
92
92
|
const appliesToMovieTicketServiceOutputTypeOfIn = params.relatedOffer?.priceSpecification?.appliesToMovieTicket?.serviceOutput?.typeOf?.$in;
|
|
93
93
|
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfIn)) {
|
|
94
94
|
andConditions.push({
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGoogleIdTokenClient = getGoogleIdTokenClient;
|
|
4
|
+
const google_auth_library_1 = require("google-auth-library");
|
|
5
|
+
// GoogleAuth のベースインスタンスは 1 つで共有
|
|
6
|
+
let auth;
|
|
7
|
+
// Audience ごとに生成したクライアントを保持するキャッシュ
|
|
8
|
+
const idTokenClients = new Map();
|
|
9
|
+
const initPromises = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* 指定した targetAudience に対応する IdTokenClient を取得(キャッシュ対応)
|
|
12
|
+
*/
|
|
13
|
+
async function getGoogleIdTokenClient(targetAudience) {
|
|
14
|
+
if (typeof targetAudience !== 'string' || targetAudience === '') {
|
|
15
|
+
throw new Error('targetAudience is required.');
|
|
16
|
+
}
|
|
17
|
+
// 1. 既に生成済みのインスタンスがあれば即座に返す(メモリ参照のみ、負荷ゼロ)
|
|
18
|
+
const cachedClient = idTokenClients.get(targetAudience);
|
|
19
|
+
if (cachedClient !== undefined) {
|
|
20
|
+
return cachedClient;
|
|
21
|
+
}
|
|
22
|
+
if (auth === undefined) {
|
|
23
|
+
auth = new google_auth_library_1.GoogleAuth();
|
|
24
|
+
}
|
|
25
|
+
// 2. 起動直後など、同一 Audience への多重初期化を防ぐ(Promise キャッシュ)
|
|
26
|
+
let promise = initPromises.get(targetAudience);
|
|
27
|
+
if (promise === undefined) {
|
|
28
|
+
promise = auth.getIdTokenClient(targetAudience)
|
|
29
|
+
.then((client) => {
|
|
30
|
+
idTokenClients.set(targetAudience, client);
|
|
31
|
+
return client;
|
|
32
|
+
}).finally(() => {
|
|
33
|
+
// 成功・失敗にかかわらず進行中フラグ(Promise)を掃除する
|
|
34
|
+
initPromises.delete(targetAudience);
|
|
35
|
+
});
|
|
36
|
+
initPromises.set(targetAudience, promise);
|
|
37
|
+
}
|
|
38
|
+
return promise;
|
|
39
|
+
}
|
|
@@ -37,6 +37,7 @@ exports.triggerWebhook = triggerWebhook;
|
|
|
37
37
|
const crypto = __importStar(require("crypto"));
|
|
38
38
|
const http_status_1 = require("http-status");
|
|
39
39
|
const factory_1 = require("../../factory");
|
|
40
|
+
const getGoogleIdTokenClient_1 = require("./triggerWebhook/getGoogleIdTokenClient");
|
|
40
41
|
const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
|
|
41
42
|
function triggerWebhook(params) {
|
|
42
43
|
return async (repos) => {
|
|
@@ -141,11 +142,40 @@ function signRequest(params) {
|
|
|
141
142
|
.update(payload)
|
|
142
143
|
.digest('hex');
|
|
143
144
|
}
|
|
145
|
+
async function makeRequestHeaders(action, options, requestBody) {
|
|
146
|
+
const secretKey = options?.triggerWebhook?.secretKey;
|
|
147
|
+
const headerIdentifier = options?.triggerWebhook?.headerIdentifier;
|
|
148
|
+
const googleTargetAudience = options?.triggerWebhook?.googleTargetAudience;
|
|
149
|
+
const timestamp = action.startDate.valueOf();
|
|
150
|
+
// sign request(2024-10-28~)
|
|
151
|
+
let signature;
|
|
152
|
+
if (typeof secretKey === 'string' && secretKey !== ''
|
|
153
|
+
&& typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
154
|
+
signature = signRequest({ requestBody, timestamp, secretKey });
|
|
155
|
+
}
|
|
156
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
157
|
+
if (typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
158
|
+
headers.append(`X-${headerIdentifier}-Webhook-Timestamp`, String(timestamp));
|
|
159
|
+
if (typeof signature === 'string') {
|
|
160
|
+
headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// support googleAuth(2026-10-30~)
|
|
164
|
+
if (typeof googleTargetAudience === 'string' && googleTargetAudience !== '') {
|
|
165
|
+
const idTokenClient = await (0, getGoogleIdTokenClient_1.getGoogleIdTokenClient)(googleTargetAudience);
|
|
166
|
+
// getRequestHeaders() からキャッシュ済みの "Bearer eyJhbG..." を取得
|
|
167
|
+
const requestHeaders = await idTokenClient.getRequestHeaders();
|
|
168
|
+
const idToken = requestHeaders.get('authorization'); // "Bearer eyJhbG..."
|
|
169
|
+
if (typeof idToken === 'string') {
|
|
170
|
+
// IAPを通過するための認証(Googleが認識するヘッダー)
|
|
171
|
+
headers.append('Proxy-Authorization', idToken);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return headers;
|
|
175
|
+
}
|
|
144
176
|
function processInformAction(params, options) {
|
|
145
177
|
return async (repos) => {
|
|
146
178
|
const timeout = options?.triggerWebhook?.timeout;
|
|
147
|
-
const secretKey = options?.triggerWebhook?.secretKey;
|
|
148
|
-
const headerIdentifier = options?.triggerWebhook?.headerIdentifier;
|
|
149
179
|
const { identifier } = params;
|
|
150
180
|
const informActionAttributes = await createInformActionAttributes(params)(repos);
|
|
151
181
|
const action = await repos.actions.inform.startInformAction(informActionAttributes);
|
|
@@ -161,20 +191,7 @@ function processInformAction(params, options) {
|
|
|
161
191
|
? { identifier }
|
|
162
192
|
: undefined
|
|
163
193
|
});
|
|
164
|
-
const
|
|
165
|
-
// sign request(2024-10-28~)
|
|
166
|
-
let signature;
|
|
167
|
-
if (typeof secretKey === 'string' && secretKey !== ''
|
|
168
|
-
&& typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
169
|
-
signature = signRequest({ requestBody, timestamp, secretKey });
|
|
170
|
-
}
|
|
171
|
-
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
172
|
-
if (typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
173
|
-
headers.append(`X-${headerIdentifier}-Webhook-Timestamp`, String(timestamp));
|
|
174
|
-
if (typeof signature === 'string') {
|
|
175
|
-
headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
194
|
+
const headers = await makeRequestHeaders(action, options, requestBody);
|
|
178
195
|
const res = await fetch(urlTemplate, {
|
|
179
196
|
method: 'POST',
|
|
180
197
|
headers,
|
|
@@ -3,7 +3,7 @@ import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
|
3
3
|
import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
4
4
|
import type { ProductRepo } from '../../../repo/product';
|
|
5
5
|
import { factory } from '../../../factory';
|
|
6
|
-
type ISearchOfferCatalogItemResult = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | '
|
|
6
|
+
type ISearchOfferCatalogItemResult = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'relatedOffer'> & {
|
|
7
7
|
elementIndex: number;
|
|
8
8
|
};
|
|
9
9
|
/**
|
package/package.json
CHANGED
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "11.
|
|
14
|
+
"@chevre/factory": "11.2.0-alpha.0",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
18
18
|
"@surfrock/sdk": "2.0.0",
|
|
19
19
|
"debug": "4.4.3",
|
|
20
|
+
"google-auth-library": "11.3.2",
|
|
20
21
|
"http-status": "2.1.0",
|
|
21
22
|
"jsonwebtoken": "9.0.0",
|
|
22
23
|
"libphonenumber-js": "1.13.8",
|
|
@@ -88,5 +89,5 @@
|
|
|
88
89
|
"postversion": "git push origin --tags",
|
|
89
90
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
91
|
},
|
|
91
|
-
"version": "28.1.0-alpha.
|
|
92
|
+
"version": "28.1.0-alpha.2"
|
|
92
93
|
}
|