UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

74 lines (73 loc) 4.31 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.call = call; const factory = require("../../factory"); const acceptedOffer_1 = require("../../repo/acceptedOffer"); const accountingReport_1 = require("../../repo/accountingReport"); const action_1 = require("../../repo/action"); const assetTransaction_1 = require("../../repo/assetTransaction"); const credentials_1 = require("../../repo/credentials"); const event_1 = require("../../repo/event"); const order_1 = require("../../repo/order"); const paymentService_1 = require("../../repo/paymentService"); const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider"); const product_1 = require("../../repo/product"); const project_1 = require("../../repo/project"); const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted"); const task_1 = require("../../repo/task"); const payByTask_1 = require("./payment/payByTask"); /** * タスク実行関数 */ function call(params) { return (_a) => __awaiter(this, [_a], void 0, function* ({ connection, redisClient, settings }) { var _b; if (redisClient === undefined) { throw new factory.errors.Argument('settings', 'redisClient required'); } let payActionAttributes; payActionAttributes = yield (0, payByTask_1.payTask2payActionAttributes)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id, typeOf: 'Task' } // タスクIDを関連付け(2024-04-20~) }))({ action: new action_1.ActionRepo(connection), acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection), assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection), order: new order_1.OrderRepo(connection) }); const paymentServiceId = (_b = payActionAttributes.object.at(0)) === null || _b === void 0 ? void 0 : _b.id; const credentialsExpireInSeconds = settings.movieticketReserve.credentialsExpireInSeconds; const useCredentialsRepo = typeof paymentServiceId === 'string' && paymentServiceId !== '' && typeof credentialsExpireInSeconds === 'number' && credentialsExpireInSeconds > 0; yield (0, payByTask_1.payByTask)( // { // ...params.data, // sameAs: { id: params.id, typeOf: 'Task' } // タスクIDを関連付け(2024-04-20~) // } payActionAttributes)({ acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection), accountingReport: new accountingReport_1.AccountingReportRepo(connection), action: new action_1.ActionRepo(connection), assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection), credentials: new credentials_1.CredentialsRepo(redisClient, { scope: `${factory.service.paymentService.PaymentServiceType.MovieTicket}:${paymentServiceId}`, expireInSeconds: (useCredentialsRepo) ? credentialsExpireInSeconds : 0 }), event: new event_1.EventRepo(connection), order: new order_1.OrderRepo(connection), paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection), paymentService: new paymentService_1.PaymentServiceRepo(connection), paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection), product: new product_1.ProductRepo(connection), project: new project_1.ProjectRepo(connection), task: new task_1.TaskRepo(connection) }, settings); }); }