@chevre/domain 22.7.0-alpha.8 → 22.7.0
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/aggregateOfferCatalogItemList.ts +36 -0
- package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +1 -1
- package/example/src/chevre/aggregation/searchAggregateReservations.ts +1 -1
- package/example/src/chevre/deleteDiscontinuedPeople.ts +153 -0
- package/example/src/chevre/deleteDiscontinuedPeopleByFetch.ts +38 -0
- package/example/src/chevre/findJWTSetting.ts +19 -0
- package/example/src/chevre/person/checkUserPoolClients.ts +119 -0
- package/example/src/chevre/person/cleanUpCognitoUsers.ts +73 -23
- package/example/src/chevre/person/cleanUpCognitoUsersByFetch.ts +162 -0
- package/example/src/chevre/person/cleanUpCreditCard.ts +113 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +3 -29
- package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +152 -150
- package/lib/chevre/credentials.d.ts +0 -5
- package/lib/chevre/credentials.js +0 -13
- package/lib/chevre/repo/action.d.ts +4 -20
- package/lib/chevre/repo/action.js +61 -160
- package/lib/chevre/repo/additionalProperty.js +1 -1
- package/lib/chevre/repo/aggregateOffer.js +1 -1
- package/lib/chevre/repo/aggregateReservation.d.ts +2 -2
- package/lib/chevre/repo/aggregateReservation.js +1 -1
- package/lib/chevre/repo/categoryCode.d.ts +6 -2
- package/lib/chevre/repo/categoryCode.js +15 -8
- package/lib/chevre/repo/comment.js +1 -1
- package/lib/chevre/repo/creativeWork.js +1 -1
- package/lib/chevre/repo/customer.js +1 -1
- package/lib/chevre/repo/emailMessage.js +1 -1
- package/lib/chevre/repo/event.d.ts +10 -7
- package/lib/chevre/repo/event.js +40 -80
- package/lib/chevre/repo/mongoose/schemas/account.js +4 -12
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +18 -23
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +0 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/event.js +0 -1
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +26 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
- package/lib/chevre/repo/offerCatalog.d.ts +9 -0
- package/lib/chevre/repo/offerCatalog.js +37 -3
- package/lib/chevre/repo/offerCatalogItem.d.ts +9 -0
- package/lib/chevre/repo/offerCatalogItem.js +37 -1
- package/lib/chevre/repo/offerItemCondition.js +1 -1
- package/lib/chevre/repo/ownershipInfo.js +1 -1
- package/lib/chevre/repo/passport.js +4 -1
- package/lib/chevre/repo/person.d.ts +5 -3
- package/lib/chevre/repo/person.js +0 -1
- package/lib/chevre/repo/priceSpecification.js +1 -1
- package/lib/chevre/repo/seller.js +1 -1
- package/lib/chevre/repo/setting/jwt.d.ts +10 -0
- package/lib/chevre/repo/setting/jwt.js +65 -0
- package/lib/chevre/repo/task.js +1 -1
- package/lib/chevre/repository.d.ts +7 -0
- package/lib/chevre/repository.js +17 -1
- package/lib/chevre/service/aggregation/event.d.ts +1 -2
- package/lib/chevre/service/aggregation/event.js +1 -3
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/pay/factory.js +4 -10
- package/lib/chevre/service/assetTransaction/pay.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +14 -18
- package/lib/chevre/service/assetTransaction/reserve/start/factory/price.js +8 -19
- package/lib/chevre/service/code.d.ts +3 -34
- package/lib/chevre/service/code.js +18 -136
- package/lib/chevre/service/offer/event/authorize/factory.js +19 -14
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +0 -5
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +43 -39
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -4
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +12 -4
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -4
- package/lib/chevre/service/offer/event/authorize.js +6 -2
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +10 -4
- package/lib/chevre/service/offer/factory.js +22 -5
- package/lib/chevre/service/offer.d.ts +7 -9
- package/lib/chevre/service/offer.js +25 -24
- package/lib/chevre/service/order/deleteOrder.d.ts +4 -0
- package/lib/chevre/service/order/deleteOrder.js +48 -5
- package/lib/chevre/service/payment/any/factory.d.ts +1 -1
- package/lib/chevre/service/payment/any.d.ts +1 -4
- package/lib/chevre/service/payment/any.js +35 -22
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +3 -0
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +32 -14
- package/lib/chevre/service/payment/factory.d.ts +3 -0
- package/lib/chevre/service/payment/movieTicket/validation.js +1 -22
- package/lib/chevre/service/payment.d.ts +1 -3
- package/lib/chevre/service/payment.js +26 -3
- package/lib/chevre/service/report/telemetry.js +3 -3
- package/lib/chevre/service/reserve/verifyToken4reservation.js +1 -16
- package/lib/chevre/service/task/acceptCOAOffer.js +24 -14
- package/lib/chevre/service/task/authorizePayment.js +7 -5
- package/lib/chevre/service/task/createEvent/createEventSeries.js +5 -2
- package/lib/chevre/service/task/deletePerson.js +57 -56
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/task/pay.js +1 -0
- package/lib/chevre/service/task.d.ts +0 -2
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +1 -6
- package/lib/chevre/service/transaction/moneyTransfer.js +57 -36
- package/package.json +9 -5
- package/example/src/chevre/findValidAuthorization.ts +0 -56
- package/example/src/chevre/saveAggregateReservation.ts +0 -43
- package/lib/chevre/credentials/jwt.d.ts +0 -23
- package/lib/chevre/credentials/jwt.js +0 -18
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +0 -19
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +0 -145
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +0 -6
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +0 -37
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const GMO = require("@motionpicture/gmo-service");
|
|
14
|
+
const createDebug = require("debug");
|
|
14
15
|
const factory = require("../../factory");
|
|
15
|
-
// import { Settings } from '../../settings';
|
|
16
16
|
const person2username_1 = require("../payment/any/person2username");
|
|
17
17
|
const account_1 = require("../../repo/account");
|
|
18
18
|
const action_1 = require("../../repo/action");
|
|
@@ -20,10 +20,11 @@ const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
|
20
20
|
const creditCard_1 = require("../../repo/paymentMethod/creditCard");
|
|
21
21
|
const paymentService_1 = require("../../repo/paymentService");
|
|
22
22
|
const person_1 = require("../../repo/person");
|
|
23
|
-
|
|
23
|
+
// import { ProjectRepo } from '../../repo/project';
|
|
24
24
|
const setting_1 = require("../../repo/setting");
|
|
25
25
|
const task_1 = require("../../repo/task");
|
|
26
|
-
const
|
|
26
|
+
const debug = createDebug('chevre-domain:service:task:deletePerson');
|
|
27
|
+
const ADMIN_PROVIDER_NAME = 'Google';
|
|
27
28
|
let cognitoIdentityServiceProvider;
|
|
28
29
|
/**
|
|
29
30
|
* タスク実行関数
|
|
@@ -54,24 +55,27 @@ function call(params) {
|
|
|
54
55
|
cognitoIdentityServiceProvider
|
|
55
56
|
});
|
|
56
57
|
const paymentServiceRepo = new paymentService_1.PaymentServiceRepo(connection);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
let creditCardRepo;
|
|
59
|
+
if (typeof params.data.paymentMethodType4creditCard === 'string' && params.data.paymentMethodType4creditCard.length > 0) {
|
|
60
|
+
const credentials = yield getCreditCardPaymentServiceChannel({
|
|
61
|
+
project: { id: params.project.id },
|
|
62
|
+
paymentMethodType: params.data.paymentMethodType4creditCard
|
|
63
|
+
})({ paymentService: paymentServiceRepo });
|
|
64
|
+
creditCardRepo = new creditCard_1.CreditCardRepo({
|
|
65
|
+
siteId: credentials.siteId,
|
|
66
|
+
sitePass: credentials.sitePass,
|
|
67
|
+
cardService: new GMO.service.Card({
|
|
68
|
+
endpoint: credentials.endpoint,
|
|
69
|
+
useFetch: settings.gmo.useFetch
|
|
70
|
+
}, {
|
|
71
|
+
timeout: (params.data.executeBackground)
|
|
72
|
+
? settings.gmo.timeout
|
|
73
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
74
|
+
: 20000 // cronで実行の場合は長めに(2024-10-05~)
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
yield deleteById(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id } }), setting)({
|
|
75
79
|
account: new account_1.AccountRepo(connection),
|
|
76
80
|
action: new action_1.ActionRepo(connection),
|
|
77
81
|
creditCard: creditCardRepo,
|
|
@@ -79,7 +83,7 @@ function call(params) {
|
|
|
79
83
|
paymentService: paymentServiceRepo,
|
|
80
84
|
newPerson: newPersonRepo,
|
|
81
85
|
oldPerson: oldPersonRepo,
|
|
82
|
-
project: new
|
|
86
|
+
// project: new ProjectRepo(connection),
|
|
83
87
|
task: new task_1.TaskRepo(connection),
|
|
84
88
|
cognitoIdentityServiceProvider
|
|
85
89
|
}
|
|
@@ -96,6 +100,7 @@ function deleteById(params, setting) {
|
|
|
96
100
|
return (repos
|
|
97
101
|
// settings: Settings
|
|
98
102
|
) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
var _a;
|
|
99
104
|
const deleteMemberAction = {
|
|
100
105
|
agent: params.agent,
|
|
101
106
|
object: Object.assign({ id: params.id, typeOf: factory.personType.Person, migrate: params.migrate, physically: params.physically }, (typeof params.migratePersonRecipientUrl === 'string')
|
|
@@ -106,16 +111,22 @@ function deleteById(params, setting) {
|
|
|
106
111
|
const action = yield repos.action.start(deleteMemberAction);
|
|
107
112
|
let existingPeople;
|
|
108
113
|
try {
|
|
109
|
-
const project =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
+
// const project = <Pick<factory.project.IProject, 'settings' | 'id'>>await repos.project.findById({
|
|
115
|
+
// id: params.project.id,
|
|
116
|
+
// inclusion: ['settings']
|
|
117
|
+
// });
|
|
118
|
+
existingPeople = yield repos.newPerson.search({ id: params.id });
|
|
119
|
+
// exclude ADMIN_PROVIDER_NAME
|
|
120
|
+
const username = (_a = existingPeople.at(0)) === null || _a === void 0 ? void 0 : _a.Username;
|
|
121
|
+
const isAdminPerson = typeof username === 'string' && username.startsWith(ADMIN_PROVIDER_NAME, 0);
|
|
122
|
+
if (isAdminPerson) {
|
|
123
|
+
throw new factory.errors.Argument('id', `${ADMIN_PROVIDER_NAME} people cannot be deleted`);
|
|
124
|
+
}
|
|
114
125
|
// 移行の場合、全所有権情報通知タスクを作成
|
|
115
126
|
if (params.migrate && typeof params.migratePersonRecipientUrl === 'string') {
|
|
116
127
|
yield createInformTask({
|
|
117
128
|
id: params.id,
|
|
118
|
-
project: { id: project.id },
|
|
129
|
+
project: { id: params.project.id },
|
|
119
130
|
now: action.startDate,
|
|
120
131
|
migratePersonRecipientUrl: params.migratePersonRecipientUrl
|
|
121
132
|
})(repos);
|
|
@@ -124,38 +135,33 @@ function deleteById(params, setting) {
|
|
|
124
135
|
// 移行でなければDeleteTransactionタスクを作成(2023-07-03~)
|
|
125
136
|
yield createDeleteTransactionTask({
|
|
126
137
|
id: params.id,
|
|
127
|
-
project: { id: project.id },
|
|
138
|
+
project: { id: params.project.id },
|
|
128
139
|
now: action.startDate
|
|
129
140
|
})({ task: repos.task });
|
|
130
141
|
}
|
|
131
|
-
existingPeople = yield repos.newPerson.search({ id: params.id });
|
|
132
|
-
// tslint:disable-next-line:no-console
|
|
133
|
-
console.log('admin:people:deleteById: existingPeople:', JSON.stringify(existingPeople));
|
|
134
142
|
if (existingPeople.length > 0) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
if (repos.creditCard !== undefined) {
|
|
144
|
+
// クレジットカード削除
|
|
145
|
+
yield deleteCreditCardsById({
|
|
146
|
+
id: params.id,
|
|
147
|
+
useUsernameAsGMOMemberId: params.useUsernameAsGMOMemberId
|
|
148
|
+
}, setting)({
|
|
149
|
+
person: repos.newPerson,
|
|
150
|
+
creditCard: repos.creditCard,
|
|
151
|
+
cognitoIdentityServiceProvider: repos.cognitoIdentityServiceProvider
|
|
152
|
+
});
|
|
143
153
|
}
|
|
144
|
-
// settings
|
|
145
|
-
);
|
|
146
154
|
}
|
|
147
155
|
// 所有権削除
|
|
148
|
-
|
|
149
|
-
console.log('admin:people:deleteById: deleteOwnershipInfosById processing... personId:', params.id);
|
|
156
|
+
debug('task:deletePerson:deleteById: deleteOwnershipInfosById processing... personId:', params.id);
|
|
150
157
|
yield deleteOwnershipInfosById({
|
|
151
158
|
id: params.id,
|
|
152
|
-
project: { id: project.id }
|
|
159
|
+
project: { id: params.project.id }
|
|
153
160
|
})({ ownershipInfo: repos.ownershipInfo });
|
|
154
161
|
if (existingPeople.length > 0) {
|
|
155
162
|
// 会員削除
|
|
156
163
|
if (params.physically === true) {
|
|
157
|
-
|
|
158
|
-
console.log('admin:people:deleteById: deleteById processing...userId:', params.id);
|
|
164
|
+
debug('task:deletePerson:deleteById: deleteById processing...userId:', params.id);
|
|
159
165
|
yield repos.newPerson.deleteById({ userId: params.id });
|
|
160
166
|
}
|
|
161
167
|
else {
|
|
@@ -376,9 +382,7 @@ function sleep(waitTime) {
|
|
|
376
382
|
const DELETE_CREDIT_CARD_MAX_RETRY_COUNT = 2;
|
|
377
383
|
const DELETE_CREDIT_CARD_RETRY_INTERVAL_IN_MS = 1000;
|
|
378
384
|
function deleteCreditCardsById(params, setting) {
|
|
379
|
-
return (repos
|
|
380
|
-
// settings: Settings
|
|
381
|
-
) => __awaiter(this, void 0, void 0, function* () {
|
|
385
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
382
386
|
let retry = true;
|
|
383
387
|
let numberOfTry = 0;
|
|
384
388
|
while (numberOfTry >= 0) {
|
|
@@ -404,8 +408,7 @@ function deleteCreditCardsById(params, setting) {
|
|
|
404
408
|
let throwsPerson2usernameError = true;
|
|
405
409
|
// oldUserが存在しないケースをハンドル
|
|
406
410
|
if (error instanceof factory.errors.NotFound && error.entityName === 'User') {
|
|
407
|
-
|
|
408
|
-
console.log('admin:people:deleteById: deleteCreditCardsById oldUsername not found', 'personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
411
|
+
debug('task:deletePerson:deleteById: deleteCreditCardsById oldUsername not found', 'personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
409
412
|
throwsPerson2usernameError = false;
|
|
410
413
|
}
|
|
411
414
|
if (throwsPerson2usernameError) {
|
|
@@ -413,16 +416,14 @@ function deleteCreditCardsById(params, setting) {
|
|
|
413
416
|
}
|
|
414
417
|
}
|
|
415
418
|
if (typeof oldUsername === 'string') {
|
|
416
|
-
|
|
417
|
-
console.log('admin:people:deleteById: deleteCreditCardsById processing... oldUsername:', oldUsername, 'personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
419
|
+
debug('task:deletePerson:deleteById: deleteCreditCardsById processing... oldUsername:', oldUsername, 'personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
418
420
|
yield repos.creditCard.deleteAll({ personId: oldUsername });
|
|
419
421
|
}
|
|
420
422
|
}
|
|
421
423
|
else {
|
|
422
424
|
yield repos.creditCard.deleteAll({ personId: params.id });
|
|
423
425
|
}
|
|
424
|
-
|
|
425
|
-
console.log('admin:people:deleteById: deleteCreditCardsById processed. personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
426
|
+
debug('task:deletePerson:deleteById: deleteCreditCardsById processed. personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
426
427
|
break;
|
|
427
428
|
}
|
|
428
429
|
catch (error) {
|
|
@@ -20,6 +20,7 @@ const note_1 = require("../../repo/note");
|
|
|
20
20
|
const order_1 = require("../../repo/order");
|
|
21
21
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
22
22
|
const reservation_1 = require("../../repo/reservation");
|
|
23
|
+
const setting_1 = require("../../repo/setting");
|
|
23
24
|
const task_1 = require("../../repo/task");
|
|
24
25
|
const transaction_1 = require("../../repo/transaction");
|
|
25
26
|
const TransactionService = require("../transaction");
|
|
@@ -39,6 +40,7 @@ function call(data) {
|
|
|
39
40
|
order: new order_1.OrderRepo(connection),
|
|
40
41
|
ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
|
|
41
42
|
reservation: new reservation_1.ReservationRepo(connection),
|
|
43
|
+
setting: new setting_1.SettingRepo(connection),
|
|
42
44
|
task: new task_1.TaskRepo(connection),
|
|
43
45
|
transaction: new transaction_1.TransactionRepo(connection)
|
|
44
46
|
});
|
|
@@ -37,6 +37,7 @@ function call(params) {
|
|
|
37
37
|
let payActionAttributes;
|
|
38
38
|
payActionAttributes = yield (0, payment_1.payTask2payActionAttributes)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id, typeOf: 'Task' } // タスクIDを関連付け(2024-04-20~)
|
|
39
39
|
}))({
|
|
40
|
+
action: new action_1.ActionRepo(connection),
|
|
40
41
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
41
42
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
42
43
|
order: new order_1.OrderRepo(connection)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
2
|
import type { RedisClientType } from 'redis';
|
|
3
|
-
import { JWTCredentials } from '../credentials/jwt';
|
|
4
3
|
import { LINENotifyCredentials } from '../credentials/lineNotify';
|
|
5
4
|
import { SendGridCredentials } from '../credentials/sendGrid';
|
|
6
5
|
import * as factory from '../factory';
|
|
@@ -9,7 +8,6 @@ import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/tas
|
|
|
9
8
|
import { Settings } from '../settings';
|
|
10
9
|
import { AggregationSettings } from '../settings/aggregation';
|
|
11
10
|
interface ICredentialSettings {
|
|
12
|
-
jwt?: JWTCredentials;
|
|
13
11
|
sendGrid: SendGridCredentials;
|
|
14
12
|
}
|
|
15
13
|
interface IExecuteSettings {
|
|
@@ -9,6 +9,7 @@ import type { NoteRepo } from '../../repo/note';
|
|
|
9
9
|
import type { OrderRepo } from '../../repo/order';
|
|
10
10
|
import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
11
11
|
import type { ReservationRepo } from '../../repo/reservation';
|
|
12
|
+
import type { SettingRepo } from '../../repo/setting';
|
|
12
13
|
import type { TaskRepo } from '../../repo/task';
|
|
13
14
|
import type { TransactionRepo } from '../../repo/transaction';
|
|
14
15
|
/**
|
|
@@ -26,6 +27,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
|
|
|
26
27
|
order: OrderRepo;
|
|
27
28
|
ownershipInfo: OwnershipInfoRepo;
|
|
28
29
|
reservation: ReservationRepo;
|
|
30
|
+
setting: SettingRepo;
|
|
29
31
|
task: TaskRepo;
|
|
30
32
|
transaction: TransactionRepo;
|
|
31
33
|
}) => Promise<void>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { JWTCredentials } from '../../credentials/jwt';
|
|
2
1
|
import type { ActionRepo } from '../../repo/action';
|
|
3
2
|
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
3
|
import type { AuthorizationRepo } from '../../repo/authorization';
|
|
@@ -26,9 +25,7 @@ export interface IStartOperationRepos {
|
|
|
26
25
|
transactionNumber: TransactionNumberRepo;
|
|
27
26
|
assetTransaction: AssetTransactionRepo;
|
|
28
27
|
}
|
|
29
|
-
export type IStartOperation<T> = (repos: IStartOperationRepos
|
|
30
|
-
jwt: JWTCredentials;
|
|
31
|
-
}) => Promise<T>;
|
|
28
|
+
export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
32
29
|
export type ITaskAndTransactionOperation<T> = (repos: {
|
|
33
30
|
setting: SettingRepo;
|
|
34
31
|
task: TaskRepo;
|
|
@@ -53,8 +50,6 @@ export type IAuthorizeOperation<T> = (repos: {
|
|
|
53
50
|
ticket: TicketRepo;
|
|
54
51
|
transaction: TransactionRepo;
|
|
55
52
|
assetTransaction: AssetTransactionRepo;
|
|
56
|
-
}, credentials: {
|
|
57
|
-
jwt: JWTCredentials;
|
|
58
53
|
}) => Promise<T>;
|
|
59
54
|
/**
|
|
60
55
|
* 取引確定
|
|
@@ -21,13 +21,16 @@ const factory_1 = require("./moneyTransfer/exportTasks/factory");
|
|
|
21
21
|
const factory_2 = require("./moneyTransfer/factory");
|
|
22
22
|
const potentialActions_1 = require("./moneyTransfer/potentialActions");
|
|
23
23
|
const MoneyTransferAssetTransactionService = require("../assetTransaction/moneyTransfer");
|
|
24
|
-
const CodeService = require("../code");
|
|
25
24
|
/**
|
|
26
25
|
* 取引開始
|
|
27
26
|
* 通貨転送資産取引サービスを利用して転送取引を開始する
|
|
28
27
|
*/
|
|
29
28
|
function start(params) {
|
|
30
|
-
return (repos
|
|
29
|
+
return (repos
|
|
30
|
+
// credentials: {
|
|
31
|
+
// jwt: JWTCredentials;
|
|
32
|
+
// }
|
|
33
|
+
) => __awaiter(this, void 0, void 0, function* () {
|
|
31
34
|
const { passport } = yield repos.passport.validatePassportTokenIfExist(params);
|
|
32
35
|
const sellers = yield repos.seller.projectFields({
|
|
33
36
|
limit: 1,
|
|
@@ -55,7 +58,7 @@ function start(params) {
|
|
|
55
58
|
transaction = yield repos.transaction.start(startParams);
|
|
56
59
|
yield authorizePaymentCard({
|
|
57
60
|
transaction: Object.assign(Object.assign({}, transaction), { object: startParams.object, seller: startParams.seller, agent: startParams.agent, project: startParams.project, typeOf: startParams.typeOf })
|
|
58
|
-
})(repos
|
|
61
|
+
})(repos);
|
|
59
62
|
}
|
|
60
63
|
catch (error) {
|
|
61
64
|
throw error;
|
|
@@ -65,7 +68,11 @@ function start(params) {
|
|
|
65
68
|
}
|
|
66
69
|
exports.start = start;
|
|
67
70
|
function authorizePaymentCard(params) {
|
|
68
|
-
return (repos
|
|
71
|
+
return (repos
|
|
72
|
+
// credentials: {
|
|
73
|
+
// jwt: JWTCredentials;
|
|
74
|
+
// }
|
|
75
|
+
) => __awaiter(this, void 0, void 0, function* () {
|
|
69
76
|
var _a;
|
|
70
77
|
const transaction = params.transaction;
|
|
71
78
|
const fromLocation = transaction.object.fromLocation;
|
|
@@ -96,7 +103,7 @@ function authorizePaymentCard(params) {
|
|
|
96
103
|
: String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
|
|
97
104
|
}, price: 0, priceCurrency: factory.priceCurrency.JPY }, (typeof transaction.object.description === 'string') ? { description: transaction.object.description } : undefined),
|
|
98
105
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
99
|
-
})(repos
|
|
106
|
+
})(repos);
|
|
100
107
|
}
|
|
101
108
|
else {
|
|
102
109
|
throw new factory.errors.NotImplemented('Withdraw transaction not implemented');
|
|
@@ -161,7 +168,11 @@ function fixToLocation(params) {
|
|
|
161
168
|
* 口座取引は、出金取引あるいは転送取引のどちらかを選択できます
|
|
162
169
|
*/
|
|
163
170
|
function processAuthorizePaymentCard(params) {
|
|
164
|
-
return (repos
|
|
171
|
+
return (repos
|
|
172
|
+
// credentials: {
|
|
173
|
+
// jwt: JWTCredentials;
|
|
174
|
+
// }
|
|
175
|
+
) => __awaiter(this, void 0, void 0, function* () {
|
|
165
176
|
var _a;
|
|
166
177
|
const transaction = yield repos.transaction.projectFieldsInProgressById({
|
|
167
178
|
typeOf: factory.transactionType.MoneyTransfer,
|
|
@@ -196,7 +207,7 @@ function processAuthorizePaymentCard(params) {
|
|
|
196
207
|
recipient: recipient,
|
|
197
208
|
transaction: transaction,
|
|
198
209
|
transactionNumber
|
|
199
|
-
})(repos
|
|
210
|
+
})(repos);
|
|
200
211
|
// アクションにchevre取引情報を保管
|
|
201
212
|
yield repos.action.findByIdAndUpdate({
|
|
202
213
|
id: action.id,
|
|
@@ -277,7 +288,11 @@ function createAuthorizeMoneyTransferOfferActionAttributes(params) {
|
|
|
277
288
|
}
|
|
278
289
|
function processMoneyTransferTransaction(params) {
|
|
279
290
|
// tslint:disable-next-line:max-func-body-length
|
|
280
|
-
return (repos
|
|
291
|
+
return (repos
|
|
292
|
+
// credentials: {
|
|
293
|
+
// jwt: JWTCredentials;
|
|
294
|
+
// }
|
|
295
|
+
) => __awaiter(this, void 0, void 0, function* () {
|
|
281
296
|
var _a, _b;
|
|
282
297
|
let pendingTransaction;
|
|
283
298
|
const transaction = params.transaction;
|
|
@@ -305,7 +320,7 @@ function processMoneyTransferTransaction(params) {
|
|
|
305
320
|
throw new factory.errors.NotImplemented('Withdraw transaction not implemented');
|
|
306
321
|
}
|
|
307
322
|
else if (params.object.fromLocation !== undefined && params.object.itemOffered.toLocation !== undefined) {
|
|
308
|
-
const { fromLocation } = yield validateFromLocation({ id: params.project.id }, params.object.fromLocation, { id: issuedThroughId })(repos
|
|
323
|
+
const { fromLocation } = yield validateFromLocation({ id: params.project.id }, params.object.fromLocation, { id: issuedThroughId })(repos);
|
|
309
324
|
const { toLocation } = yield validateToLocation({ id: params.project.id }, {
|
|
310
325
|
typeOf: factory.permit.PermitType.Permit,
|
|
311
326
|
identifier: params.object.itemOffered.toLocation.identifier,
|
|
@@ -371,34 +386,40 @@ function processMoneyTransferTransaction(params) {
|
|
|
371
386
|
}
|
|
372
387
|
// tslint:disable-next-line:max-func-body-length
|
|
373
388
|
function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
374
|
-
return (repos
|
|
375
|
-
|
|
389
|
+
return (repos
|
|
390
|
+
// credentials: {
|
|
391
|
+
// jwt: JWTCredentials;
|
|
392
|
+
// }
|
|
393
|
+
) => __awaiter(this, void 0, void 0, function* () {
|
|
394
|
+
var _a, _b;
|
|
376
395
|
let fromLocation = fromLocationBeforeStart;
|
|
377
|
-
//
|
|
396
|
+
// discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
|
|
378
397
|
if (typeof fromLocation === 'string') {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
fromLocation
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
398
|
+
throw new factory.errors.NotImplemented('fromLocation as string not implemented');
|
|
399
|
+
// トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
|
|
400
|
+
// const { authorizedObject } = await CodeService.verifyToken({
|
|
401
|
+
// project: { id: project.id },
|
|
402
|
+
// agent: { id: project.id, typeOf: factory.organizationType.Project },
|
|
403
|
+
// token: fromLocation
|
|
404
|
+
// })(repos);
|
|
405
|
+
// const paymentCardOwnershipInfo = authorizedObject;
|
|
406
|
+
// if (Array.isArray(paymentCardOwnershipInfo)) {
|
|
407
|
+
// throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
|
|
408
|
+
// }
|
|
409
|
+
// if (paymentCardOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
410
|
+
// throw new factory.errors.Argument('fromLocation', 'must be OwnershipInfo');
|
|
411
|
+
// }
|
|
412
|
+
// if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
413
|
+
// throw new factory.errors.Argument('fromLocation', 'must be Permit');
|
|
414
|
+
// }
|
|
415
|
+
// if (paymentCardOwnershipInfo.typeOfGood.issuedThrough?.typeOf !== factory.product.ProductType.PaymentCard) {
|
|
416
|
+
// throw new factory.errors.Argument('fromLocation', 'must be issued through PaymentCard');
|
|
417
|
+
// }
|
|
418
|
+
// fromLocation = {
|
|
419
|
+
// typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
|
|
420
|
+
// identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
|
|
421
|
+
// issuedThrough: { id: paymentCardOwnershipInfo.typeOfGood.issuedThrough.id }
|
|
422
|
+
// };
|
|
402
423
|
}
|
|
403
424
|
else {
|
|
404
425
|
// fromLocationが注文の場合に対応
|
|
@@ -423,7 +444,7 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
|
423
444
|
throw new factory.errors.Argument('fromLocation', `Invalid order status '${order.orderStatus}''`);
|
|
424
445
|
}
|
|
425
446
|
let awardAccounts = [];
|
|
426
|
-
const awardAccounsValue = (
|
|
447
|
+
const awardAccounsValue = (_b = (_a = order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === order_1.AWARD_ACCOUNTS_IDENTIFIER_NAME)) === null || _b === void 0 ? void 0 : _b.value;
|
|
427
448
|
if (typeof awardAccounsValue === 'string' && awardAccounsValue.length > 0) {
|
|
428
449
|
awardAccounts = JSON.parse(awardAccounsValue);
|
|
429
450
|
}
|
package/package.json
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.
|
|
15
|
-
"@cinerino/sdk": "10.19.0-alpha.
|
|
16
|
-
"@motionpicture/coa-service": "9.6.0
|
|
14
|
+
"@chevre/factory": "4.391.0",
|
|
15
|
+
"@cinerino/sdk": "10.19.0-alpha.2",
|
|
16
|
+
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
19
19
|
"@surfrock/sdk": "1.4.0-alpha.1",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"description": "Chevre Domain Library for Node.js",
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@eslint/js": "9.16.0",
|
|
35
36
|
"@types/debug": "0.0.30",
|
|
36
37
|
"@types/google-libphonenumber": "^7.4.19",
|
|
37
38
|
"@types/http-status": "^0.2.30",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@types/uuid": "^3.4.10",
|
|
50
51
|
"coveralls": "^3.1.0",
|
|
51
52
|
"csvtojson": "^2.0.10",
|
|
53
|
+
"eslint": "9.16.0",
|
|
52
54
|
"googleapis": "^85.0.0",
|
|
53
55
|
"json2csv": "4.5.4",
|
|
54
56
|
"mocha": "10.6.0",
|
|
@@ -62,7 +64,8 @@
|
|
|
62
64
|
"ts-node": "^10.9.1",
|
|
63
65
|
"tslint": "^6.1.3",
|
|
64
66
|
"tslint-microsoft-contrib": "^6.2.0",
|
|
65
|
-
"typescript": "5.0.3"
|
|
67
|
+
"typescript": "5.0.3",
|
|
68
|
+
"typescript-eslint": "8.18.0"
|
|
66
69
|
},
|
|
67
70
|
"peerDependencies": {
|
|
68
71
|
"mongoose": "^7.4.0",
|
|
@@ -103,10 +106,11 @@
|
|
|
103
106
|
"coverage": "npm run nyc && nyc report --reporter=text-lcov | coveralls",
|
|
104
107
|
"test": "npm run check && npm run coverage",
|
|
105
108
|
"tslint": "tslint --project tsconfig.json -c tslint.json --exclude \"**/*.spec.ts\" \"src/**/*.ts\"",
|
|
109
|
+
"eslint": "eslint src/**/*.ts",
|
|
106
110
|
"preversion": "npm run clean && npm run build && npm test && npm run doc",
|
|
107
111
|
"version": "git add -A",
|
|
108
112
|
"postversion": "git push origin --tags",
|
|
109
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
110
114
|
},
|
|
111
|
-
"version": "22.7.0
|
|
115
|
+
"version": "22.7.0"
|
|
112
116
|
}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
const CODE = '85de7dc1-3761-4317-80d6-b36bf0b2788f';
|
|
8
|
-
// const ID = '6631d754c20be0772c217b90';
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const authorizationRepo = await chevre.repository.Authorization.createInstance(mongoose.connection);
|
|
14
|
-
const ticketRepo = await chevre.repository.Ticket.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const result = await authorizationRepo.findValidOneByCode({
|
|
17
|
-
project,
|
|
18
|
-
code: CODE
|
|
19
|
-
});
|
|
20
|
-
console.log('result:', result);
|
|
21
|
-
|
|
22
|
-
// const result = await authorizationRepo.findValidOneById({
|
|
23
|
-
// project,
|
|
24
|
-
// id: ID
|
|
25
|
-
// });
|
|
26
|
-
// console.log('result:', result);
|
|
27
|
-
|
|
28
|
-
const token = await (await chevre.service.code.createService()).getToken({
|
|
29
|
-
agent: { id: 'xxx', typeOf: chevre.factory.personType.Person },
|
|
30
|
-
project,
|
|
31
|
-
code: CODE,
|
|
32
|
-
expiresIn: 18000,
|
|
33
|
-
issuer: 'https://example.com',
|
|
34
|
-
audience: 'https://example.com'
|
|
35
|
-
})(
|
|
36
|
-
{
|
|
37
|
-
authorization: authorizationRepo,
|
|
38
|
-
ticket: ticketRepo
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
jwt: await chevre.credentials.JWT.createInstance({
|
|
42
|
-
secret: <string>process.env.TOKEN_SECRET,
|
|
43
|
-
issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
|
|
44
|
-
? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
|
|
45
|
-
: [],
|
|
46
|
-
version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
|
|
47
|
-
payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
console.log('token:', token);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
main()
|
|
55
|
-
.then(console.log)
|
|
56
|
-
.catch(console.error);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
// const now = new Date();
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const aggregateReservationRepo = await chevre.repository.AggregateReservation.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const result = await aggregateReservationRepo.save(
|
|
15
|
-
{
|
|
16
|
-
project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
|
|
17
|
-
reservationFor: {
|
|
18
|
-
id: 'blxonxv24',
|
|
19
|
-
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
20
|
-
startDate: moment('2024-08-07T10:10:00.000+00:00')
|
|
21
|
-
.toDate()
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
$set: {
|
|
26
|
-
// aggregateOffer: {
|
|
27
|
-
// typeOf: chevre.factory.offerType.AggregateOffer,
|
|
28
|
-
// aggregateDate: now
|
|
29
|
-
// },
|
|
30
|
-
// aggregateEntranceGate: {
|
|
31
|
-
// typeOf: chevre.factory.placeType.AggregatePlace,
|
|
32
|
-
// aggregateDate: now,
|
|
33
|
-
// places: []
|
|
34
|
-
// }
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
console.log(result);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
main()
|
|
42
|
-
.then(console.log)
|
|
43
|
-
.catch(console.error);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
interface IOptions {
|
|
2
|
-
secret: string;
|
|
3
|
-
/**
|
|
4
|
-
* トークン検証時の発行者リスト
|
|
5
|
-
*/
|
|
6
|
-
issuers: string[];
|
|
7
|
-
version: string;
|
|
8
|
-
payloadTypPrefix: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* トークン認証情報
|
|
12
|
-
*/
|
|
13
|
-
declare class JWTCredentials {
|
|
14
|
-
readonly secret: string;
|
|
15
|
-
/**
|
|
16
|
-
* トークン検証時の発行者リスト
|
|
17
|
-
*/
|
|
18
|
-
readonly issuers: string[];
|
|
19
|
-
readonly version: string;
|
|
20
|
-
readonly payloadTypPrefix: string;
|
|
21
|
-
constructor(options: IOptions);
|
|
22
|
-
}
|
|
23
|
-
export { JWTCredentials };
|