@chevre/domain 21.32.0-alpha.1 → 21.32.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/findAuthorizePaymentAction.ts +34 -0
- package/example/src/chevre/report2developers.ts +20 -17
- package/example/src/chevre/transaction/acceptCOAOffer.ts +75 -0
- package/lib/chevre/credentials.d.ts +4 -3
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/errorHandler.d.ts +4 -0
- package/lib/chevre/errorHandler.js +33 -1
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/action.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -12
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/task.js +7 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +14 -2
- package/lib/chevre/service/assetTransaction/pay.js +10 -6
- package/lib/chevre/service/notification.d.ts +8 -10
- package/lib/chevre/service/notification.js +26 -13
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +23 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +255 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +15 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +20 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +31 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +215 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +41 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +66 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +3 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +6 -1
- package/lib/chevre/service/payment/any.d.ts +122 -1
- package/lib/chevre/service/payment/any.js +184 -5
- package/lib/chevre/service/payment/movieTicket.js +26 -15
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +6 -0
- package/lib/chevre/service/task/acceptCOAOffer.js +91 -0
- package/lib/chevre/service/task/checkMovieTicket.d.ts +6 -0
- package/lib/chevre/service/task/checkMovieTicket.js +66 -0
- package/lib/chevre/service/task/publishPaymentUrl.d.ts +6 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +70 -0
- package/lib/chevre/service/task.js +13 -5
- package/package.json +3 -3
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const result = await (await chevre.service.payment.any.createService()).findAuthorizeAction({
|
|
15
|
+
project: {
|
|
16
|
+
id: project.id
|
|
17
|
+
},
|
|
18
|
+
sameAs: {
|
|
19
|
+
id: '6649277cd22032e3e7b6d0fa'
|
|
20
|
+
},
|
|
21
|
+
purpose: {
|
|
22
|
+
id: '66492757d22032e3e7b6d013'
|
|
23
|
+
// id: '66492757d22032e3e7b63'
|
|
24
|
+
}
|
|
25
|
+
})({
|
|
26
|
+
action: actionRepo,
|
|
27
|
+
task: taskRepo
|
|
28
|
+
});
|
|
29
|
+
console.log('result:', result);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main()
|
|
33
|
+
.then(console.log)
|
|
34
|
+
.catch(console.error);
|
|
@@ -3,32 +3,35 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
11
|
const notificationService = await chevre.service.notification.createService();
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
await notificationService.triggerWebhook({
|
|
19
|
-
typeOf: chevre.factory.actionType.InformAction,
|
|
20
|
-
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
21
|
-
agent: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
22
|
-
recipient: {
|
|
23
|
-
id: 'xxx',
|
|
24
|
-
url: 'https://example.com',
|
|
25
|
-
typeOf: chevre.factory.creativeWorkType.WebApplication
|
|
26
|
-
},
|
|
27
|
-
object: { sample: 'sample' }
|
|
13
|
+
await notificationService.lineNotify({
|
|
14
|
+
subject: 'sample notification',
|
|
15
|
+
content: 'sample conent\nsample conent\nsample conent\nsample conent\nsample conent\nsample conent\nsample conent',
|
|
16
|
+
logLevel: 'log'
|
|
28
17
|
})({
|
|
29
|
-
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
30
18
|
useFetchAPI: true
|
|
31
19
|
});
|
|
20
|
+
|
|
21
|
+
// await notificationService.triggerWebhook({
|
|
22
|
+
// typeOf: chevre.factory.actionType.InformAction,
|
|
23
|
+
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
24
|
+
// agent: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
25
|
+
// recipient: {
|
|
26
|
+
// id: 'xxx',
|
|
27
|
+
// url: 'https://example.com',
|
|
28
|
+
// typeOf: chevre.factory.creativeWorkType.WebApplication
|
|
29
|
+
// },
|
|
30
|
+
// object: { sample: 'sample' }
|
|
31
|
+
// })({
|
|
32
|
+
// action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
33
|
+
// useFetchAPI: true
|
|
34
|
+
// });
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
main()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as COA from '@motionpicture/coa-service';
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const coaAuthClient = new COA.auth.RefreshToken({
|
|
14
|
+
endpoint: chevre.credentials.coa.endpoint,
|
|
15
|
+
refreshToken: chevre.credentials.coa.refreshToken,
|
|
16
|
+
useFetch: true
|
|
17
|
+
});
|
|
18
|
+
const acceptAction = await (await chevre.service.offer.createService()).eventServiceByCOA.acceptOffer({
|
|
19
|
+
object: {
|
|
20
|
+
event: { id: '120162210202405231201850' },
|
|
21
|
+
acceptedOffer: [
|
|
22
|
+
{
|
|
23
|
+
seatSection: ' ',
|
|
24
|
+
seatNumber: 'b-36',
|
|
25
|
+
ticketInfo: {
|
|
26
|
+
ticketCode: '10',
|
|
27
|
+
mvtkAppPrice: 0,
|
|
28
|
+
ticketCount: 1,
|
|
29
|
+
addGlasses: 0,
|
|
30
|
+
kbnEisyahousiki: '00',
|
|
31
|
+
mvtkNum: '',
|
|
32
|
+
mvtkKbnDenshiken: '00',
|
|
33
|
+
mvtkKbnMaeuriken: '00',
|
|
34
|
+
mvtkKbnKensyu: '00',
|
|
35
|
+
mvtkSalesPrice: 0,
|
|
36
|
+
kbnMgtk: ''
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
agent: {
|
|
42
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication
|
|
43
|
+
},
|
|
44
|
+
purpose: { id: '664e80c79801179aabb0476f' },
|
|
45
|
+
appliesToSurfrock: {
|
|
46
|
+
identifier: '',
|
|
47
|
+
serviceOutput: { typeOf: '' }
|
|
48
|
+
},
|
|
49
|
+
flgMember: COA.factory.reserve.FlgMember.NonMember,
|
|
50
|
+
sameAs: { id: 'xxx' }
|
|
51
|
+
})({
|
|
52
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
53
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
54
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection),
|
|
55
|
+
reserveService: new COA.service.Reserve(
|
|
56
|
+
{
|
|
57
|
+
endpoint: chevre.credentials.coa.endpoint,
|
|
58
|
+
auth: coaAuthClient
|
|
59
|
+
},
|
|
60
|
+
{ timeout: chevre.credentials.coa.timeout }
|
|
61
|
+
),
|
|
62
|
+
masterService: new COA.service.Master(
|
|
63
|
+
{
|
|
64
|
+
endpoint: chevre.credentials.coa.endpoint,
|
|
65
|
+
auth: coaAuthClient
|
|
66
|
+
},
|
|
67
|
+
{ timeout: chevre.credentials.coa.timeout }
|
|
68
|
+
)
|
|
69
|
+
});
|
|
70
|
+
console.log('acceptAction:', acceptAction);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then(console.log)
|
|
75
|
+
.catch(console.error);
|
|
@@ -29,9 +29,10 @@ export declare const credentials: {
|
|
|
29
29
|
useFetch: boolean;
|
|
30
30
|
};
|
|
31
31
|
lineNotify: {
|
|
32
|
-
url: string;
|
|
33
|
-
accessToken: string;
|
|
34
|
-
accessTokenAlert: string;
|
|
32
|
+
url: string | undefined;
|
|
33
|
+
accessToken: string | undefined;
|
|
34
|
+
accessTokenAlert: string | undefined;
|
|
35
|
+
accessTokenInfo: string | undefined;
|
|
35
36
|
};
|
|
36
37
|
movieticketReserve: {
|
|
37
38
|
/**
|
|
@@ -38,7 +38,8 @@ exports.credentials = {
|
|
|
38
38
|
lineNotify: {
|
|
39
39
|
url: process.env.LINE_NOTIFY_URL,
|
|
40
40
|
accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN,
|
|
41
|
-
accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT
|
|
41
|
+
accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT,
|
|
42
|
+
accessTokenInfo: process.env.LINE_NOTIFY_ACCESS_TOKEN_INFO
|
|
42
43
|
},
|
|
43
44
|
movieticketReserve: {
|
|
44
45
|
/**
|
|
@@ -9,6 +9,10 @@ export declare function handleMongoError(error: unknown): Promise<unknown>;
|
|
|
9
9
|
* 汎用的なCOAエラーハンドリング
|
|
10
10
|
*/
|
|
11
11
|
export declare function handleCOAError(error: any): Error;
|
|
12
|
+
/**
|
|
13
|
+
* COA仮予約エラーハンドリング
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleCOAReserveTemporarilyError(error: any): Error;
|
|
12
16
|
/**
|
|
13
17
|
* Pecorinoサービスエラーをハンドリングする
|
|
14
18
|
* 可能であればChevreエラーへ変換します
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.handleAWSError = exports.handleMvtkReserveError = exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = exports.handlePecorinoError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
12
|
+
exports.handleAWSError = exports.handleMvtkReserveError = exports.MOVIE_TICKET_RESERVE_REQUEST_ERROR_NAME = exports.handlePecorinoError = exports.handleCOAReserveTemporarilyError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* エラーハンドラー
|
|
15
15
|
* 外部サービスと連携している場合に、サービス(API)のエラーを本ドメインのエラーに変換する責任を担います。
|
|
@@ -81,6 +81,38 @@ function handleCOAError(error) {
|
|
|
81
81
|
return handledError;
|
|
82
82
|
}
|
|
83
83
|
exports.handleCOAError = handleCOAError;
|
|
84
|
+
/**
|
|
85
|
+
* COA仮予約エラーハンドリング
|
|
86
|
+
*/
|
|
87
|
+
// tslint:disable-next-line:no-any
|
|
88
|
+
function handleCOAReserveTemporarilyError(error) {
|
|
89
|
+
var _a;
|
|
90
|
+
let handledError = error;
|
|
91
|
+
// if (error.message === '座席取得失敗') {
|
|
92
|
+
// }
|
|
93
|
+
// メッセージ「既に予約済みです」の場合は、座席の重複とみなす
|
|
94
|
+
if (error.message === '既に予約済みです') {
|
|
95
|
+
handledError = new factory_1.errors.AlreadyInUse('offer', ['seatNumber'], 'Seat not available');
|
|
96
|
+
}
|
|
97
|
+
// Chevreが500未満であればクライアントエラーとみなす
|
|
98
|
+
const reserveServiceHttpStatusCode = error.code;
|
|
99
|
+
if (Number.isInteger(reserveServiceHttpStatusCode)) {
|
|
100
|
+
if (reserveServiceHttpStatusCode < http_status_1.INTERNAL_SERVER_ERROR) {
|
|
101
|
+
handledError = new factory_1.errors.Argument('Event', error.message);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const uri = (_a = error.requestOptions) === null || _a === void 0 ? void 0 : _a.uri;
|
|
105
|
+
if (error.message === 'ETIMEDOUT' || error.message === 'ESOCKETTIMEDOUT') {
|
|
106
|
+
handledError = new factory_1.errors.GatewayTimeout(`Gateway Timeout. name:${error.name} code:${error.code} message:${error.message} uri:${uri}`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
handledError = new factory_1.errors.ServiceUnavailable(`Reserve service temporarily unavailable. name:${error.name} code:${error.code} message:${error.message} uri:${uri}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return handledError;
|
|
114
|
+
}
|
|
115
|
+
exports.handleCOAReserveTemporarilyError = handleCOAReserveTemporarilyError;
|
|
84
116
|
/**
|
|
85
117
|
* Pecorinoサービスエラーをハンドリングする
|
|
86
118
|
* 可能であればChevreエラーへ変換します
|
|
@@ -174,7 +174,7 @@ export declare class MongoRepository {
|
|
|
174
174
|
$eq: string;
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
|
-
}): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error'>[]>;
|
|
177
|
+
}): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
|
|
178
178
|
deleteByProject(params: {
|
|
179
179
|
project: {
|
|
180
180
|
id: string;
|
|
@@ -684,7 +684,7 @@ class MongoRepository {
|
|
|
684
684
|
const query = this.actionModel.find(Object.assign({ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
|
|
685
685
|
? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
|
|
686
686
|
: undefined))
|
|
687
|
-
.select({ _id: 1, actionStatus: 1, error: 1 })
|
|
687
|
+
.select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
|
|
688
688
|
.limit(1);
|
|
689
689
|
return query.exec()
|
|
690
690
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
@@ -38,10 +38,8 @@ const schemaOptions = {
|
|
|
38
38
|
writeConcern: writeConcern_1.writeConcern,
|
|
39
39
|
strict: true,
|
|
40
40
|
strictQuery: false,
|
|
41
|
-
timestamps:
|
|
42
|
-
|
|
43
|
-
updatedAt: 'updatedAt'
|
|
44
|
-
},
|
|
41
|
+
timestamps: false,
|
|
42
|
+
versionKey: false,
|
|
45
43
|
toJSON: {
|
|
46
44
|
getters: false,
|
|
47
45
|
virtuals: false,
|
|
@@ -56,14 +54,6 @@ const schemaOptions = {
|
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
56
|
const indexes = [
|
|
59
|
-
[
|
|
60
|
-
{ createdAt: 1 },
|
|
61
|
-
{ name: 'searchByCreatedAt' }
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
{ updatedAt: 1 },
|
|
65
|
-
{ name: 'searchByUpdatedAt' }
|
|
66
|
-
],
|
|
67
57
|
[
|
|
68
58
|
{ 'project.id': 1, startDate: -1 },
|
|
69
59
|
{
|
|
@@ -49,7 +49,7 @@ export type IExecutableTask<T extends factory.taskName> = Pick<factory.task.ITas
|
|
|
49
49
|
type IDelayedTask = Pick<factory.task.ITask<factory.taskName>, 'id' | 'name' | 'status'>;
|
|
50
50
|
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName> | '_id';
|
|
51
51
|
type IProjection = {
|
|
52
|
-
[key in IKeyOfProjection]?: 0;
|
|
52
|
+
[key in IKeyOfProjection]?: 0 | 1;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* タスクリポジトリ
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -577,7 +577,13 @@ class MongoRepository {
|
|
|
577
577
|
var _a;
|
|
578
578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
579
579
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
580
|
-
const
|
|
580
|
+
const positiveProjectionExists = (projection !== undefined && projection !== null)
|
|
581
|
+
? Object.values(projection)
|
|
582
|
+
.some((value) => value !== 0)
|
|
583
|
+
: false;
|
|
584
|
+
const query = this.taskModel.find((conditions.length > 0) ? { $and: conditions } : {}, (positiveProjectionExists)
|
|
585
|
+
? projection
|
|
586
|
+
: Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
|
|
581
587
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
582
588
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
583
589
|
query.limit(params.limit)
|
|
@@ -76,8 +76,20 @@ export type IPublishPaymentUrlResult = CreditCardPayment.IPaymentAgencyTransacti
|
|
|
76
76
|
/**
|
|
77
77
|
* 外部決済ロケーション発行
|
|
78
78
|
*/
|
|
79
|
-
export declare function publishPaymentUrl(params: factory.assetTransaction.pay.IStartParamsWithoutDetail,
|
|
80
|
-
|
|
79
|
+
export declare function publishPaymentUrl(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, options: {
|
|
80
|
+
purposeAsTransaction: {
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 実行者
|
|
85
|
+
*/
|
|
86
|
+
executor?: {
|
|
87
|
+
/**
|
|
88
|
+
* task ID
|
|
89
|
+
* taskによって実行されている場合値が存在する
|
|
90
|
+
*/
|
|
91
|
+
id?: string;
|
|
92
|
+
};
|
|
81
93
|
}): IPublishPaymentUrlOperation<IPublishPaymentUrlResult>;
|
|
82
94
|
/**
|
|
83
95
|
* 決済ロケーションを無効化する
|
|
@@ -23,9 +23,9 @@ const debug = createDebug('chevre-domain:service:assetTransaction');
|
|
|
23
23
|
* 外部決済ロケーション発行
|
|
24
24
|
*/
|
|
25
25
|
// tslint:disable-next-line:max-func-body-length
|
|
26
|
-
function publishPaymentUrl(params,
|
|
26
|
+
function publishPaymentUrl(params, options) {
|
|
27
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b, _c;
|
|
28
|
+
var _a, _b, _c, _d, _e;
|
|
29
29
|
const paymentServiceType = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
30
30
|
// 金額をfix
|
|
31
31
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
@@ -40,22 +40,26 @@ function publishPaymentUrl(params, purposeAsTransaction) {
|
|
|
40
40
|
// 決済サービス確認
|
|
41
41
|
const paymentServiceId = getPaymentServiceId(params);
|
|
42
42
|
// 決済受入アクション生成(2024-03-28~)
|
|
43
|
+
const taskId = (_c = options === null || options === void 0 ? void 0 : options.executor) === null || _c === void 0 ? void 0 : _c.id;
|
|
43
44
|
const actionAttributes = Object.assign({ project: params.project, typeOf: factory.actionType.AcceptAction, agent: params.agent, object: {
|
|
44
45
|
object: params.object,
|
|
45
46
|
transactionNumber,
|
|
46
47
|
typeOf: params.typeOf
|
|
47
|
-
}
|
|
48
|
-
? {
|
|
48
|
+
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id } }, (typeof taskId === 'string')
|
|
49
|
+
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-05-22~)
|
|
49
50
|
: undefined);
|
|
50
51
|
const action = yield repos.action.start(actionAttributes);
|
|
51
52
|
let result;
|
|
52
53
|
try {
|
|
53
54
|
switch (paymentServiceType) {
|
|
54
55
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
55
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, {
|
|
56
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, {
|
|
57
|
+
processPublishPaymentUrl: true,
|
|
58
|
+
executor: (typeof ((_d = options.executor) === null || _d === void 0 ? void 0 : _d.id) === 'string') ? { id: options.executor.id } : {} // タスク関連付け(2024-05-22~)
|
|
59
|
+
})(repos);
|
|
56
60
|
let paymentUrl;
|
|
57
61
|
// 3DS拡張(2024-01-02~)
|
|
58
|
-
const retUrl = (
|
|
62
|
+
const retUrl = (_e = params.object.paymentMethod.creditCard) === null || _e === void 0 ? void 0 : _e.retUrl;
|
|
59
63
|
if (typeof retUrl === 'string' && retUrl.length > 0) {
|
|
60
64
|
paymentUrl = authorizeResult.execTranResult.redirectUrl;
|
|
61
65
|
}
|
|
@@ -2,30 +2,28 @@ import * as factory from '../factory';
|
|
|
2
2
|
import type { MongoRepository as ActionRepo } from '../repo/action';
|
|
3
3
|
import type { MessageRepo } from '../repo/message';
|
|
4
4
|
import type { MongoRepository as ProjectRepo } from '../repo/project';
|
|
5
|
-
|
|
6
|
-
accessToken: string;
|
|
5
|
+
type ILineNotifyOperation<T> = (repos: {
|
|
7
6
|
useFetchAPI: boolean;
|
|
8
7
|
}) => Promise<T>;
|
|
9
8
|
/**
|
|
10
9
|
* Eメールメッセージを送信する
|
|
11
10
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
12
11
|
*/
|
|
13
|
-
|
|
12
|
+
declare function sendEmailMessage(params: factory.action.transfer.send.message.email.IAttributes): (repos: {
|
|
14
13
|
action: ActionRepo;
|
|
15
14
|
message: MessageRepo;
|
|
16
15
|
project: ProjectRepo;
|
|
17
16
|
}) => Promise<void>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* https://notify-bot.line.me/doc/ja/
|
|
21
|
-
*/
|
|
22
|
-
export declare function report2developers({ subject, content, imageThumbnail, imageFullsize }: {
|
|
17
|
+
type LineNotifyLogLevel = 'log' | 'error' | 'info';
|
|
18
|
+
declare function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }: {
|
|
23
19
|
subject: string;
|
|
24
20
|
content: string;
|
|
25
21
|
imageThumbnail?: string;
|
|
26
22
|
imageFullsize?: string;
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
logLevel: LineNotifyLogLevel;
|
|
24
|
+
}): ILineNotifyOperation<void>;
|
|
25
|
+
declare function triggerWebhook(params: factory.task.IData<factory.taskName.TriggerWebhook>): (repos: {
|
|
29
26
|
action: ActionRepo;
|
|
30
27
|
useFetchAPI: boolean;
|
|
31
28
|
}) => Promise<void>;
|
|
29
|
+
export { lineNotify, sendEmailMessage, triggerWebhook };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.triggerWebhook = exports.
|
|
12
|
+
exports.triggerWebhook = exports.sendEmailMessage = exports.lineNotify = void 0;
|
|
13
13
|
const sgMail = require("@sendgrid/mail");
|
|
14
14
|
const http_status_1 = require("http-status");
|
|
15
15
|
// import * as request from 'request';
|
|
@@ -120,21 +120,34 @@ function sendEmailMessage(params) {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
exports.sendEmailMessage = sendEmailMessage;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* https://notify-bot.line.me/doc/ja/
|
|
126
|
-
*/
|
|
127
|
-
function report2developers({ subject, content, imageThumbnail, imageFullsize }) {
|
|
123
|
+
const MAX_LINE_NOTIFY_SUBJECT_LENGTH = 100;
|
|
124
|
+
function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }) {
|
|
128
125
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
129
126
|
var _a;
|
|
130
127
|
const LINE_NOTIFY_URL = credentials_1.credentials.lineNotify.url;
|
|
131
|
-
if (LINE_NOTIFY_URL
|
|
128
|
+
if (typeof LINE_NOTIFY_URL !== 'string') {
|
|
132
129
|
throw new Error('Environment variable LINE_NOTIFY_URL not set');
|
|
133
130
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
let accessToken;
|
|
132
|
+
switch (logLevel) {
|
|
133
|
+
case 'error':
|
|
134
|
+
accessToken = credentials_1.credentials.lineNotify.accessTokenAlert;
|
|
135
|
+
break;
|
|
136
|
+
case 'info':
|
|
137
|
+
accessToken = credentials_1.credentials.lineNotify.accessTokenInfo;
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
accessToken = credentials_1.credentials.lineNotify.accessToken;
|
|
141
|
+
}
|
|
142
|
+
if (typeof accessToken !== 'string') {
|
|
143
|
+
throw new Error('credentials.lineNotify.accessToken not set');
|
|
144
|
+
}
|
|
145
|
+
const shortSubject = (subject.length > MAX_LINE_NOTIFY_SUBJECT_LENGTH)
|
|
146
|
+
? `${subject.slice(0, MAX_LINE_NOTIFY_SUBJECT_LENGTH)}...`
|
|
147
|
+
: subject;
|
|
148
|
+
const message = util.format('\n%s\n%s\n%s\n%s\n%s\n\n%s', `[${logLevel}] ${shortSubject}`, `now:${(new Date()).toISOString()}`, `pid:${process.pid}`, `GAE_APPLICATION:${process.env.GAE_APPLICATION}`,
|
|
149
|
+
// `GAE_INSTANCE:${process.env.GAE_INSTANCE}`,
|
|
150
|
+
`GAE_SERVICE:${process.env.GAE_SERVICE}`, content);
|
|
138
151
|
if (repos.useFetchAPI) {
|
|
139
152
|
try {
|
|
140
153
|
const form = new FormData();
|
|
@@ -146,7 +159,7 @@ ${content}`;
|
|
|
146
159
|
form.set('imageFullsize', imageFullsize);
|
|
147
160
|
}
|
|
148
161
|
const res = yield fetch(LINE_NOTIFY_URL, Object.assign({ method: 'POST', headers: {
|
|
149
|
-
Authorization: `Bearer ${
|
|
162
|
+
Authorization: `Bearer ${accessToken}`
|
|
150
163
|
}, body: form }, (typeof ((_a = settings_1.settings.webhook) === null || _a === void 0 ? void 0 : _a.timeout) === 'number')
|
|
151
164
|
? { signal: AbortSignal.timeout(settings_1.settings.webhook.timeout) }
|
|
152
165
|
: undefined));
|
|
@@ -173,7 +186,7 @@ ${content}`;
|
|
|
173
186
|
}
|
|
174
187
|
});
|
|
175
188
|
}
|
|
176
|
-
exports.
|
|
189
|
+
exports.lineNotify = lineNotify;
|
|
177
190
|
const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
|
|
178
191
|
function triggerWebhook(params) {
|
|
179
192
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as COA from '@motionpicture/coa-service';
|
|
2
|
+
import { IAcceptedOfferWithoutDetail } from './factory';
|
|
3
|
+
import * as factory from '../../../../factory';
|
|
4
|
+
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
5
|
+
export type IMembershipOwnershipInfo = factory.ownershipInfo.IOwnershipInfo<factory.permit.IPermit>;
|
|
6
|
+
export interface IAppliesToSurfrock {
|
|
7
|
+
identifier: string;
|
|
8
|
+
serviceOutput: {
|
|
9
|
+
typeOf: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function createAcceptedOffersWithoutDetails(params: {
|
|
13
|
+
object: factory.action.authorize.offer.eventService.IObjectWithoutDetail<WebAPIIdentifier.COA>;
|
|
14
|
+
coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>;
|
|
15
|
+
}): (repos: {
|
|
16
|
+
reserveService: COA.service.Reserve;
|
|
17
|
+
}) => Promise<IAcceptedOfferWithoutDetail[]>;
|
|
18
|
+
type IAcceptedOfferBeforeAuthorize4COA = factory.action.authorize.offer.eventService.IAcceptedOfferBeforeAuthorize4COA;
|
|
19
|
+
export declare function validateOffers(coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>, offers: IAcceptedOfferWithoutDetail[], appliesToSurfrock: IAppliesToSurfrock, isMember: boolean, flgMember: COA.factory.reserve.FlgMember): (repos: {
|
|
20
|
+
reserveService: COA.service.Reserve;
|
|
21
|
+
masterService: COA.service.Master;
|
|
22
|
+
}) => Promise<IAcceptedOfferBeforeAuthorize4COA[]>;
|
|
23
|
+
export {};
|