@chevre/domain 25.2.0-alpha.3 → 25.2.0-alpha.30
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/factory/customerTelephone2COATelNum.d.ts +3 -0
- package/lib/chevre/factory/customerTelephone2COATelNum.js +23 -0
- package/lib/chevre/repo/action/acceptPay.d.ts +15 -0
- package/lib/chevre/repo/action/acceptPay.js +47 -19
- package/lib/chevre/repo/action/actionProcess.js +57 -57
- package/lib/chevre/repo/action.d.ts +16 -9
- package/lib/chevre/repo/action.js +99 -180
- package/lib/chevre/repo/message.d.ts +1 -1
- package/lib/chevre/repo/message.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +67 -66
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
- package/lib/chevre/repo/order.d.ts +735 -0
- package/lib/chevre/repo/order.js +13 -20
- package/lib/chevre/repo/orderInTransaction.d.ts +45 -0
- package/lib/chevre/repo/orderInTransaction.js +175 -0
- package/lib/chevre/repo/person.d.ts +0 -15
- package/lib/chevre/repo/person.js +122 -108
- package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -45
- package/lib/chevre/repo/transaction/placeOrder.js +43 -83
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +5 -5
- package/lib/chevre/service/offer/event/authorize/factory.js +30 -20
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +6 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +10 -10
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +17 -14
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +2 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +5 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +95 -33
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +2 -6
- package/lib/chevre/service/order/payOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder.d.ts +2 -0
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
- package/lib/chevre/service/payment/any/authorize.js +13 -37
- package/lib/chevre/service/payment/any/factory.d.ts +6 -6
- package/lib/chevre/service/payment/any/factory.js +19 -22
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +3 -1
- package/lib/chevre/service/payment/any/findAcceptAction.js +14 -6
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +4 -66
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +4 -18
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +17 -8
- package/lib/chevre/service/reserve/searchByOrder.js +2 -6
- package/lib/chevre/service/task/confirmReserveTransaction.js +2 -7
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +2 -2
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -0
- package/lib/chevre/service/task/placeOrder.js +2 -2
- package/lib/chevre/service/task/publishPaymentUrl.js +7 -3
- package/lib/chevre/service/task/voidPayTransaction.js +3 -7
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +64 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +7 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +16 -12
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +11 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +112 -91
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrder/confirm.js +31 -74
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +2 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +19 -9
- package/package.json +5 -4
package/lib/chevre/repo/order.js
CHANGED
|
@@ -848,26 +848,19 @@ class OrderRepo {
|
|
|
848
848
|
})
|
|
849
849
|
.exec();
|
|
850
850
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
// $set: {
|
|
865
|
-
// ...(typeof identifier === 'string') ? { identifier } : undefined
|
|
866
|
-
// }
|
|
867
|
-
// }
|
|
868
|
-
// )
|
|
869
|
-
// .exec();
|
|
870
|
-
// }
|
|
851
|
+
async savePaymentMethodId4migaration(params) {
|
|
852
|
+
const { paymentMethodId } = params.paymentMethod;
|
|
853
|
+
if (typeof paymentMethodId !== 'string' || paymentMethodId === '') {
|
|
854
|
+
throw new factory_1.factory.errors.ArgumentNull('paymentMethod.paymentMethodId');
|
|
855
|
+
}
|
|
856
|
+
// 注文ドキュメントにも保管する(2026-07-12~)
|
|
857
|
+
return this.orderModel.findOneAndUpdate({
|
|
858
|
+
identifier: { $eq: params.id },
|
|
859
|
+
paymentMethodId: { $exists: false }
|
|
860
|
+
}, { $set: { paymentMethodId } }, { projection: { _id: 1 } })
|
|
861
|
+
.lean()
|
|
862
|
+
.exec();
|
|
863
|
+
}
|
|
871
864
|
async aggregateOrder(params) {
|
|
872
865
|
const matchConditions = {
|
|
873
866
|
orderDate: {
|
|
@@ -11,6 +11,7 @@ export type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'pr
|
|
|
11
11
|
acceptedOffers: factory.order.IAcceptedOffer[];
|
|
12
12
|
customer?: factory.order.ICustomer;
|
|
13
13
|
seller?: factory.order.ISeller;
|
|
14
|
+
confirmationNumber?: string;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* typeOf: Orderへドキュメント変換時の編集フィールド
|
|
@@ -61,6 +62,7 @@ export type IMinimizedAcceptedOffer = Pick<factory.order.IOptimizedAcceptedOffer
|
|
|
61
62
|
*/
|
|
62
63
|
export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
63
64
|
private readonly orderModel;
|
|
65
|
+
private readonly transactionModel;
|
|
64
66
|
constructor(connection: Connection);
|
|
65
67
|
createPlaceOrderIfNotExists(params: Pick<IOrderInTransaction, 'orderNumber' | 'project' | 'identifier' | 'broker' | 'seller' | 'customer'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
66
68
|
/**
|
|
@@ -127,6 +129,49 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
127
129
|
setCustomerByIdentifier(params: Pick<IOrderInTransaction, 'project' | 'identifier'> & {
|
|
128
130
|
customer: factory.order.ICustomer;
|
|
129
131
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
132
|
+
/**
|
|
133
|
+
* 確認番号を参照する
|
|
134
|
+
*/
|
|
135
|
+
findConfirmationNumberByIdentifier(params: {
|
|
136
|
+
identifier: string;
|
|
137
|
+
}): Promise<string | undefined>;
|
|
138
|
+
/**
|
|
139
|
+
* 注文ドキュメントに確認番号を保管する
|
|
140
|
+
* 確認番号未発行の場合のみ保管される
|
|
141
|
+
*/
|
|
142
|
+
saveConfirmationNumberIfNotExist(params: {
|
|
143
|
+
identifier: string;
|
|
144
|
+
confirmationNumber: string;
|
|
145
|
+
}, options: {
|
|
146
|
+
/**
|
|
147
|
+
* 注文取引タイプのドキュメントのみを参照対象にするかどうか
|
|
148
|
+
*/
|
|
149
|
+
onlyPlaceOrder: boolean;
|
|
150
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
151
|
+
/**
|
|
152
|
+
* 特定の進行中取引の決済方法IDを保管する
|
|
153
|
+
* transactionsへの保管としてひとまず定義(2026-07-11~)
|
|
154
|
+
*/
|
|
155
|
+
savePaymentMethodId(params: {
|
|
156
|
+
id: string;
|
|
157
|
+
paymentMethod: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
158
|
+
}, options: {
|
|
159
|
+
savePaymentMethodIdInTransaction: boolean;
|
|
160
|
+
}): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* 進行中取引に保管された採用済決済方法を検索する
|
|
163
|
+
* 注文ドキュメントから参照する(2026-07-13~)
|
|
164
|
+
*/
|
|
165
|
+
findInProgressPaymentMethodId(params: {
|
|
166
|
+
id: string;
|
|
167
|
+
}): Promise<string | undefined>;
|
|
168
|
+
/**
|
|
169
|
+
* 保管された採用済決済方法を検索する
|
|
170
|
+
* 注文ドキュメントから参照する(2026-07-13~)
|
|
171
|
+
*/
|
|
172
|
+
findPaymentMethodId(params: {
|
|
173
|
+
id: string;
|
|
174
|
+
}): Promise<string | undefined>;
|
|
130
175
|
deleteByIdentifier(params: {
|
|
131
176
|
identifier: string;
|
|
132
177
|
}): Promise<import("mongodb").DeleteResult>;
|
|
@@ -5,6 +5,7 @@ exports.OrderInTransactionRepo = void 0;
|
|
|
5
5
|
const errorHandler_1 = require("../errorHandler");
|
|
6
6
|
const factory_1 = require("../factory");
|
|
7
7
|
const order_1 = require("./mongoose/schemas/order");
|
|
8
|
+
const transaction_1 = require("./mongoose/schemas/transaction");
|
|
8
9
|
const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
|
|
9
10
|
// const debug = createDebug('chevre-domain:repo:orderInTransaction');
|
|
10
11
|
/**
|
|
@@ -12,9 +13,11 @@ const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
|
|
|
12
13
|
*/
|
|
13
14
|
class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInReserveRepo {
|
|
14
15
|
orderModel;
|
|
16
|
+
transactionModel;
|
|
15
17
|
constructor(connection) {
|
|
16
18
|
super(connection);
|
|
17
19
|
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
20
|
+
this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
|
|
18
21
|
}
|
|
19
22
|
async createPlaceOrderIfNotExists(params) {
|
|
20
23
|
const { orderNumber, project, identifier, broker, seller, customer } = params;
|
|
@@ -241,6 +244,178 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
241
244
|
}
|
|
242
245
|
return result;
|
|
243
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* 確認番号を参照する
|
|
249
|
+
*/
|
|
250
|
+
async findConfirmationNumberByIdentifier(params) {
|
|
251
|
+
const { identifier } = params;
|
|
252
|
+
const doc = await this.orderModel.findOne({
|
|
253
|
+
identifier: { $eq: identifier },
|
|
254
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder }, // 取引確定の冪等性確保のためtypeOfを検証しない
|
|
255
|
+
}, { confirmationNumber: 1 })
|
|
256
|
+
.lean()
|
|
257
|
+
.exec();
|
|
258
|
+
if (doc === null) {
|
|
259
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
260
|
+
}
|
|
261
|
+
return doc.confirmationNumber;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* 注文ドキュメントに確認番号を保管する
|
|
265
|
+
* 確認番号未発行の場合のみ保管される
|
|
266
|
+
*/
|
|
267
|
+
async saveConfirmationNumberIfNotExist(params, options) {
|
|
268
|
+
const { identifier, confirmationNumber } = params;
|
|
269
|
+
const onlyPlaceOrder = options.onlyPlaceOrder === true;
|
|
270
|
+
if (typeof confirmationNumber !== 'string' || confirmationNumber === '') {
|
|
271
|
+
throw new factory_1.factory.errors.ArgumentNull('confirmationNumber');
|
|
272
|
+
}
|
|
273
|
+
return this.orderModel.updateOne({
|
|
274
|
+
identifier: { $eq: identifier },
|
|
275
|
+
confirmationNumber: { $exists: false },
|
|
276
|
+
...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
|
|
277
|
+
}, { $set: { confirmationNumber } })
|
|
278
|
+
.exec();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* 特定の進行中取引の決済方法IDを保管する
|
|
282
|
+
* transactionsへの保管としてひとまず定義(2026-07-11~)
|
|
283
|
+
*/
|
|
284
|
+
async savePaymentMethodId(params, options) {
|
|
285
|
+
const { savePaymentMethodIdInTransaction } = options;
|
|
286
|
+
const { paymentMethodId } = params.paymentMethod;
|
|
287
|
+
if (typeof paymentMethodId !== 'string' || paymentMethodId === '') {
|
|
288
|
+
throw new factory_1.factory.errors.ArgumentNull('paymentMethod.paymentMethodId');
|
|
289
|
+
}
|
|
290
|
+
if (savePaymentMethodIdInTransaction) {
|
|
291
|
+
await this.transactionModel.findOneAndUpdate({
|
|
292
|
+
_id: { $eq: params.id },
|
|
293
|
+
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
294
|
+
}, {
|
|
295
|
+
$set: { 'object.paymentMethods': { paymentMethodId } }
|
|
296
|
+
}, {
|
|
297
|
+
projection: { _id: 1 }
|
|
298
|
+
})
|
|
299
|
+
.lean()
|
|
300
|
+
.exec()
|
|
301
|
+
.then((doc) => {
|
|
302
|
+
if (doc === null) {
|
|
303
|
+
throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
// 注文ドキュメントにも保管する(2026-07-12~)
|
|
308
|
+
await this.orderModel.findOneAndUpdate({
|
|
309
|
+
identifier: { $eq: params.id },
|
|
310
|
+
paymentMethodId: { $exists: false },
|
|
311
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
|
|
312
|
+
}, { $set: { paymentMethodId } }, { projection: { _id: 1 } })
|
|
313
|
+
.lean()
|
|
314
|
+
.exec()
|
|
315
|
+
.then((doc) => {
|
|
316
|
+
if (doc === null) {
|
|
317
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 進行中取引に保管された採用済決済方法を検索する
|
|
323
|
+
* 注文ドキュメントから参照する(2026-07-13~)
|
|
324
|
+
*/
|
|
325
|
+
async findInProgressPaymentMethodId(params) {
|
|
326
|
+
// const doc = await this.transactionModel.findOne(
|
|
327
|
+
// {
|
|
328
|
+
// _id: { $eq: params.id },
|
|
329
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder },
|
|
330
|
+
// status: { $eq: factory.transactionStatusType.InProgress }
|
|
331
|
+
// },
|
|
332
|
+
// {
|
|
333
|
+
// 'object.paymentMethods': 1,
|
|
334
|
+
// _id: 0
|
|
335
|
+
// }
|
|
336
|
+
// )
|
|
337
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>()
|
|
338
|
+
// .exec();
|
|
339
|
+
// if (doc === null) {
|
|
340
|
+
// throw new factory.errors.NotFound(
|
|
341
|
+
// this.transactionModel.modelName,
|
|
342
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
343
|
+
// );
|
|
344
|
+
// }
|
|
345
|
+
// return (typeof doc.object.paymentMethods?.paymentMethodId === 'string') ? doc.object.paymentMethods.paymentMethodId : undefined;
|
|
346
|
+
const doc = await this.orderModel.findOne({
|
|
347
|
+
identifier: { $eq: params.id },
|
|
348
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
|
|
349
|
+
}, {
|
|
350
|
+
paymentMethodId: 1,
|
|
351
|
+
_id: 0
|
|
352
|
+
})
|
|
353
|
+
.lean()
|
|
354
|
+
.exec();
|
|
355
|
+
if (doc === null) {
|
|
356
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
357
|
+
}
|
|
358
|
+
return (typeof doc.paymentMethodId === 'string') ? doc.paymentMethodId : undefined;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 保管された採用済決済方法を検索する
|
|
362
|
+
* 注文ドキュメントから参照する(2026-07-13~)
|
|
363
|
+
*/
|
|
364
|
+
async findPaymentMethodId(params) {
|
|
365
|
+
// const doc = await this.transactionModel.findOne(
|
|
366
|
+
// {
|
|
367
|
+
// _id: { $eq: params.id },
|
|
368
|
+
// typeOf: { $eq: factory.transactionType.PlaceOrder }
|
|
369
|
+
// },
|
|
370
|
+
// {
|
|
371
|
+
// 'object.paymentMethods': 1,
|
|
372
|
+
// _id: 0
|
|
373
|
+
// }
|
|
374
|
+
// )
|
|
375
|
+
// .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>()
|
|
376
|
+
// .exec();
|
|
377
|
+
// if (doc === null) {
|
|
378
|
+
// throw new factory.errors.NotFound(
|
|
379
|
+
// this.transactionModel.modelName,
|
|
380
|
+
// `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
|
|
381
|
+
// );
|
|
382
|
+
// }
|
|
383
|
+
// const paymentMethodId = doc.object.paymentMethods?.paymentMethodId;
|
|
384
|
+
// if (typeof paymentMethodId === 'string') {
|
|
385
|
+
// // 注文ドキュメントにも発行済の場合、同一性を検証(2026-07-12~)
|
|
386
|
+
// const orderDoc = await this.orderModel.findOne(
|
|
387
|
+
// { identifier: { $eq: params.id } },
|
|
388
|
+
// {
|
|
389
|
+
// paymentMethodId: 1,
|
|
390
|
+
// _id: 0
|
|
391
|
+
// }
|
|
392
|
+
// )
|
|
393
|
+
// .lean<Pick<IDocType, 'paymentMethodId'>>()
|
|
394
|
+
// .exec();
|
|
395
|
+
// if (orderDoc === null) {
|
|
396
|
+
// throw new factory.errors.NotFound('orderInTransaction');
|
|
397
|
+
// }
|
|
398
|
+
// const paymentMethodIdByOrder = orderDoc.paymentMethodId;
|
|
399
|
+
// if (typeof paymentMethodIdByOrder === 'string') {
|
|
400
|
+
// // console.log('paymentMethodId matched?', JSON.stringify(doc), JSON.stringify(orderDoc));
|
|
401
|
+
// if (paymentMethodId !== paymentMethodIdByOrder) {
|
|
402
|
+
// throw new factory.errors.Internal('paymentMethodId not matched unexpectedly');
|
|
403
|
+
// }
|
|
404
|
+
// }
|
|
405
|
+
// }
|
|
406
|
+
// return (typeof paymentMethodId === 'string') ? paymentMethodId : undefined;
|
|
407
|
+
const doc = await this.orderModel.findOne({ identifier: { $eq: params.id } }, {
|
|
408
|
+
paymentMethodId: 1,
|
|
409
|
+
_id: 0
|
|
410
|
+
})
|
|
411
|
+
.lean()
|
|
412
|
+
.exec();
|
|
413
|
+
if (doc === null) {
|
|
414
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
415
|
+
}
|
|
416
|
+
const paymentMethodId = doc.paymentMethodId;
|
|
417
|
+
return (typeof paymentMethodId === 'string') ? paymentMethodId : undefined;
|
|
418
|
+
}
|
|
244
419
|
async deleteByIdentifier(params) {
|
|
245
420
|
return this.orderModel.deleteOne({
|
|
246
421
|
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
@@ -21,20 +21,12 @@ export declare class PersonRepo {
|
|
|
21
21
|
userPoolId?: string;
|
|
22
22
|
attributes?: AttributeType[];
|
|
23
23
|
}): factory.person.IPerson;
|
|
24
|
-
static PROFILE2ATTRIBUTE(params: factory.person.IProfile): AttributeType[];
|
|
25
24
|
/**
|
|
26
25
|
* 管理者権限でユーザー属性を取得する
|
|
27
26
|
*/
|
|
28
27
|
getUserAttributes(params: {
|
|
29
28
|
username: string;
|
|
30
29
|
}): Promise<factory.person.IProfile>;
|
|
31
|
-
/**
|
|
32
|
-
* 管理者権限でプロフィール更新
|
|
33
|
-
*/
|
|
34
|
-
updateProfile(params: {
|
|
35
|
-
username: string;
|
|
36
|
-
profile: factory.person.IProfile;
|
|
37
|
-
}): Promise<void>;
|
|
38
30
|
/**
|
|
39
31
|
* 管理者権限でsubでユーザーを検索する
|
|
40
32
|
*/
|
|
@@ -45,13 +37,6 @@ export declare class PersonRepo {
|
|
|
45
37
|
* アクセストークンでユーザー属性を取得する
|
|
46
38
|
*/
|
|
47
39
|
getUserAttributesByAccessToken(accessToken: string): Promise<factory.person.IProfile>;
|
|
48
|
-
/**
|
|
49
|
-
* 会員プロフィール更新
|
|
50
|
-
*/
|
|
51
|
-
updateProfileByAccessToken(params: {
|
|
52
|
-
accessToken: string;
|
|
53
|
-
profile: factory.person.IProfile;
|
|
54
|
-
}): Promise<void>;
|
|
55
40
|
/**
|
|
56
41
|
* 削除
|
|
57
42
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PersonRepo = void 0;
|
|
4
|
-
// import { fromEnv } from '@aws-sdk/credential-providers';
|
|
5
|
-
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
6
4
|
const factory_1 = require("../factory");
|
|
7
5
|
/**
|
|
8
6
|
* 会員リポジトリ
|
|
@@ -92,73 +90,81 @@ class PersonRepo {
|
|
|
92
90
|
}
|
|
93
91
|
return person;
|
|
94
92
|
}
|
|
95
|
-
static PROFILE2ATTRIBUTE(params) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
93
|
+
// public static PROFILE2ATTRIBUTE(params: factory.person.IProfile): AttributeType[] {
|
|
94
|
+
// let formatedPhoneNumber: string | undefined;
|
|
95
|
+
// if (typeof params.telephone === 'string' && params.telephone.length > 0) {
|
|
96
|
+
// try {
|
|
97
|
+
// // const phoneUtil = PhoneNumberUtil.getInstance();
|
|
98
|
+
// // const phoneNumber = phoneUtil.parse(params.telephone);
|
|
99
|
+
// // /* istanbul ignore if */
|
|
100
|
+
// // if (!phoneUtil.isValidNumber(phoneNumber)) {
|
|
101
|
+
// // throw new factory.errors.Argument('telephone', 'Invalid phone number');
|
|
102
|
+
// // }
|
|
103
|
+
// // formatedPhoneNumber = phoneUtil.format(phoneNumber, PhoneNumberFormat.E164);
|
|
104
|
+
// const phoneNumber = parsePhoneNumberFromString(params.telephone);
|
|
105
|
+
// if (phoneNumber === undefined || !phoneNumber.isValid()) {
|
|
106
|
+
// throw new factory.errors.Argument('telephone', 'Invalid phone number');
|
|
107
|
+
// }
|
|
108
|
+
// formatedPhoneNumber = phoneNumber.format('E.164');
|
|
109
|
+
// } catch (_error) {
|
|
110
|
+
// throw new factory.errors.Argument('telephone', 'Invalid phone number');
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// const userAttributes: AttributeType[] = [];
|
|
114
|
+
// if (typeof params.givenName === 'string') {
|
|
115
|
+
// userAttributes.push({
|
|
116
|
+
// Name: 'given_name',
|
|
117
|
+
// Value: params.givenName
|
|
118
|
+
// });
|
|
119
|
+
// }
|
|
120
|
+
// if (typeof params.familyName === 'string') {
|
|
121
|
+
// userAttributes.push({
|
|
122
|
+
// Name: 'family_name',
|
|
123
|
+
// Value: params.familyName
|
|
124
|
+
// });
|
|
125
|
+
// }
|
|
126
|
+
// if (typeof params.email === 'string') {
|
|
127
|
+
// userAttributes.push({
|
|
128
|
+
// Name: 'email',
|
|
129
|
+
// Value: params.email
|
|
130
|
+
// });
|
|
131
|
+
// }
|
|
132
|
+
// if (typeof formatedPhoneNumber === 'string') {
|
|
133
|
+
// userAttributes.push({
|
|
134
|
+
// Name: 'phone_number',
|
|
135
|
+
// Value: formatedPhoneNumber
|
|
136
|
+
// });
|
|
137
|
+
// }
|
|
138
|
+
// if (Array.isArray(params.additionalProperty)) {
|
|
139
|
+
// userAttributes.push(...params.additionalProperty.map((a) => {
|
|
140
|
+
// let userAttributesValue: string = a.value;
|
|
141
|
+
// // custom:telephoneに関してもtelephoneと同様のバリデーションを追加
|
|
142
|
+
// if (a.name === 'custom:telephone') {
|
|
143
|
+
// try {
|
|
144
|
+
// // const phoneUtil = PhoneNumberUtil.getInstance();
|
|
145
|
+
// // const phoneNumber = phoneUtil.parse(String(a.value));
|
|
146
|
+
// // /* istanbul ignore if */
|
|
147
|
+
// // if (!phoneUtil.isValidNumber(phoneNumber)) {
|
|
148
|
+
// // throw new factory.errors.Argument('custom:telephone', 'Invalid phone number');
|
|
149
|
+
// // }
|
|
150
|
+
// // userAttributesValue = phoneUtil.format(phoneNumber, PhoneNumberFormat.E164);
|
|
151
|
+
// const phoneNumber = parsePhoneNumberFromString(String(a.value));
|
|
152
|
+
// if (phoneNumber === undefined || !phoneNumber.isValid()) {
|
|
153
|
+
// throw new factory.errors.Argument('telephone', 'Invalid phone number');
|
|
154
|
+
// }
|
|
155
|
+
// userAttributesValue = phoneNumber.format('E.164');
|
|
156
|
+
// } catch (_error) {
|
|
157
|
+
// throw new factory.errors.Argument('custome:telephone', 'Invalid phone number');
|
|
158
|
+
// }
|
|
159
|
+
// }
|
|
160
|
+
// return {
|
|
161
|
+
// Name: a.name,
|
|
162
|
+
// Value: userAttributesValue
|
|
163
|
+
// };
|
|
164
|
+
// }));
|
|
165
|
+
// }
|
|
166
|
+
// return userAttributes;
|
|
167
|
+
// }
|
|
162
168
|
/**
|
|
163
169
|
* 管理者権限でユーザー属性を取得する
|
|
164
170
|
*/
|
|
@@ -177,26 +183,30 @@ class PersonRepo {
|
|
|
177
183
|
});
|
|
178
184
|
});
|
|
179
185
|
}
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
async updateProfile(params
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
186
|
+
// /**
|
|
187
|
+
// * 管理者権限でプロフィール更新
|
|
188
|
+
// */
|
|
189
|
+
// public async updateProfile(params: {
|
|
190
|
+
// username: string;
|
|
191
|
+
// profile: factory.person.IProfile;
|
|
192
|
+
// }): Promise<void> {
|
|
193
|
+
// return new Promise<void>((resolve, reject) => {
|
|
194
|
+
// const userAttributes = PersonRepo.PROFILE2ATTRIBUTE(params.profile);
|
|
195
|
+
// this.cognitoIdentityServiceProvider.adminUpdateUserAttributes(
|
|
196
|
+
// {
|
|
197
|
+
// UserPoolId: this.userPoolId,
|
|
198
|
+
// Username: params.username,
|
|
199
|
+
// UserAttributes: userAttributes
|
|
200
|
+
// },
|
|
201
|
+
// (err) => {
|
|
202
|
+
// if (err instanceof Error) {
|
|
203
|
+
// reject(new factory.errors.Argument('profile', err.message));
|
|
204
|
+
// } else {
|
|
205
|
+
// resolve();
|
|
206
|
+
// }
|
|
207
|
+
// });
|
|
208
|
+
// });
|
|
209
|
+
// }
|
|
200
210
|
/**
|
|
201
211
|
* 管理者権限でsubでユーザーを検索する
|
|
202
212
|
*/
|
|
@@ -249,25 +259,29 @@ class PersonRepo {
|
|
|
249
259
|
});
|
|
250
260
|
});
|
|
251
261
|
}
|
|
252
|
-
/**
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
async updateProfileByAccessToken(params
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
262
|
+
// /**
|
|
263
|
+
// * 会員プロフィール更新
|
|
264
|
+
// */
|
|
265
|
+
// public async updateProfileByAccessToken(params: {
|
|
266
|
+
// accessToken: string;
|
|
267
|
+
// profile: factory.person.IProfile;
|
|
268
|
+
// }): Promise<void> {
|
|
269
|
+
// return new Promise<void>((resolve, reject) => {
|
|
270
|
+
// const userAttributes = PersonRepo.PROFILE2ATTRIBUTE(params.profile);
|
|
271
|
+
// this.cognitoIdentityServiceProvider.updateUserAttributes(
|
|
272
|
+
// {
|
|
273
|
+
// AccessToken: params.accessToken,
|
|
274
|
+
// UserAttributes: userAttributes
|
|
275
|
+
// },
|
|
276
|
+
// (err) => {
|
|
277
|
+
// if (err instanceof Error) {
|
|
278
|
+
// reject(new factory.errors.Argument('profile', err.message));
|
|
279
|
+
// } else {
|
|
280
|
+
// resolve();
|
|
281
|
+
// }
|
|
282
|
+
// });
|
|
283
|
+
// });
|
|
284
|
+
// }
|
|
271
285
|
/**
|
|
272
286
|
* 削除
|
|
273
287
|
*/
|