@chevre/domain 20.4.0-alpha.4 → 20.4.0-alpha.6
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/unsetUnnecessaryFields.ts +26 -0
- package/lib/chevre/repo/account.d.ts +4 -0
- package/lib/chevre/repo/account.js +6 -0
- package/lib/chevre/repo/event.js +4 -13
- package/lib/chevre/repo/serviceOutput.d.ts +4 -0
- package/lib/chevre/repo/serviceOutput.js +6 -0
- package/lib/chevre/service/assetTransaction/pay.js +11 -5
- package/lib/chevre/service/payment/paymentCard.d.ts +2 -1
- package/lib/chevre/service/payment/paymentCard.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const accountRepo = new chevre.repository.Account(mongoose.connection);
|
|
10
|
+
const permitRepo = new chevre.repository.ServiceOutput(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
let updateResult = await accountRepo.unsetUnnecessaryFields({
|
|
13
|
+
filter: { status: { $exists: true } },
|
|
14
|
+
$unset: { status: 1 }
|
|
15
|
+
});
|
|
16
|
+
console.log('accounts unset.', updateResult);
|
|
17
|
+
updateResult = await permitRepo.unsetUnnecessaryFields({
|
|
18
|
+
filter: { 'paymentAccount.accountType': { $exists: true } },
|
|
19
|
+
$unset: { 'paymentAccount.accountType': 1 }
|
|
20
|
+
});
|
|
21
|
+
console.log('permits unset', updateResult);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
main()
|
|
25
|
+
.then()
|
|
26
|
+
.catch(console.error);
|
|
@@ -124,4 +124,8 @@ export declare class MongoRepository {
|
|
|
124
124
|
* 口座を検索する
|
|
125
125
|
*/
|
|
126
126
|
search(params: factory.account.ISearchConditions): Promise<factory.account.IAccount[]>;
|
|
127
|
+
unsetUnnecessaryFields(params: {
|
|
128
|
+
filter: any;
|
|
129
|
+
$unset: any;
|
|
130
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
127
131
|
}
|
|
@@ -425,5 +425,11 @@ class MongoRepository {
|
|
|
425
425
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
|
+
unsetUnnecessaryFields(params) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
+
return this.accountModel.updateMany(params.filter, { $unset: params.$unset })
|
|
431
|
+
.exec();
|
|
432
|
+
});
|
|
433
|
+
}
|
|
428
434
|
}
|
|
429
435
|
exports.MongoRepository = MongoRepository;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -473,11 +473,11 @@ class MongoRepository {
|
|
|
473
473
|
if (typeof additionalPropertyValue !== 'string') {
|
|
474
474
|
throw new factory.errors.NotFound('additionalProperty.value');
|
|
475
475
|
}
|
|
476
|
-
const _c = creatingEventParams.attributes, {
|
|
476
|
+
const _c = creatingEventParams.attributes, { eventStatus } = _c, setOnInsertFields = __rest(_c, ["eventStatus"]);
|
|
477
477
|
bulkWriteOps.push({
|
|
478
478
|
updateOne: {
|
|
479
479
|
filter: {
|
|
480
|
-
typeOf,
|
|
480
|
+
typeOf: creatingEventParams.attributes.typeOf,
|
|
481
481
|
// 追加特性をキーに更新
|
|
482
482
|
additionalProperty: {
|
|
483
483
|
$exists: true,
|
|
@@ -485,18 +485,9 @@ class MongoRepository {
|
|
|
485
485
|
}
|
|
486
486
|
},
|
|
487
487
|
update: {
|
|
488
|
-
$setOnInsert: {
|
|
489
|
-
_id: uniqid(),
|
|
490
|
-
typeOf,
|
|
491
|
-
project,
|
|
492
|
-
superEvent,
|
|
493
|
-
workPerformed,
|
|
494
|
-
location,
|
|
495
|
-
name
|
|
496
|
-
// ...creatingEventParams.attributes
|
|
497
|
-
},
|
|
488
|
+
$setOnInsert: Object.assign(Object.assign({}, setOnInsertFields), { _id: uniqid() }),
|
|
498
489
|
// 変更可能な属性のみ上書き
|
|
499
|
-
$set:
|
|
490
|
+
$set: { eventStatus }
|
|
500
491
|
},
|
|
501
492
|
upsert: true
|
|
502
493
|
}
|
|
@@ -169,5 +169,11 @@ class MongoRepository {
|
|
|
169
169
|
.exec();
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
+
unsetUnnecessaryFields(params) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
return this.serviceOutputModel.updateMany(params.filter, { $unset: params.$unset })
|
|
175
|
+
.exec();
|
|
176
|
+
});
|
|
177
|
+
}
|
|
172
178
|
}
|
|
173
179
|
exports.MongoRepository = MongoRepository;
|
|
@@ -220,20 +220,26 @@ function validateSeller(params) {
|
|
|
220
220
|
}
|
|
221
221
|
function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
222
222
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a;
|
|
224
|
+
const amount = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
|
|
225
|
+
if (typeof amount !== 'number') {
|
|
226
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod?.amount');
|
|
227
|
+
}
|
|
223
228
|
yield (0, validation_1.validateAccount)(params)(repos);
|
|
224
|
-
const { pendingTransaction, currency } = yield PaymentCardPayment.authorize(params, paymentServiceId)(repos);
|
|
229
|
+
const { pendingTransaction, currency, accountNumber } = yield PaymentCardPayment.authorize(params, paymentServiceId)(repos);
|
|
225
230
|
const totalPaymentDue = {
|
|
226
231
|
typeOf: 'MonetaryAmount',
|
|
227
232
|
currency,
|
|
228
|
-
value:
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
value: amount
|
|
234
|
+
// value: (typeof pendingTransaction.object.amount === 'number')
|
|
235
|
+
// ? pendingTransaction.object.amount
|
|
236
|
+
// : pendingTransaction.object.amount.value
|
|
231
237
|
};
|
|
232
238
|
const savingPendingTransaction = {
|
|
233
239
|
typeOf: pendingTransaction.typeOf,
|
|
234
240
|
id: pendingTransaction.id,
|
|
235
241
|
transactionNumber: pendingTransaction.transactionNumber,
|
|
236
|
-
object: { fromLocation: { accountNumber
|
|
242
|
+
object: { fromLocation: { accountNumber } }
|
|
237
243
|
};
|
|
238
244
|
return saveAuthorizeResult({
|
|
239
245
|
id: transaction.id,
|
|
@@ -6,13 +6,14 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
|
|
|
6
6
|
import { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
8
8
|
import { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
|
|
9
|
-
declare type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | '
|
|
9
|
+
declare type IPendingTransaction = Pick<factory.account.transaction.withdraw.ITransaction, 'id' | 'transactionNumber' | 'typeOf'>;
|
|
10
10
|
declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string): (repos: {
|
|
11
11
|
product: ProductRepo;
|
|
12
12
|
project: ProjectRepo;
|
|
13
13
|
}) => Promise<{
|
|
14
14
|
pendingTransaction: IPendingTransaction;
|
|
15
15
|
currency: string;
|
|
16
|
+
accountNumber: string;
|
|
16
17
|
}>;
|
|
17
18
|
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
18
19
|
product: ProductRepo;
|
|
@@ -55,7 +55,7 @@ function authorize(params, paymentServiceId) {
|
|
|
55
55
|
// PecorinoAPIのエラーをハンドリング
|
|
56
56
|
throw (0, errorHandler_1.handlePecorinoError)(error);
|
|
57
57
|
}
|
|
58
|
-
return { pendingTransaction, currency };
|
|
58
|
+
return { pendingTransaction, currency, accountNumber };
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
exports.authorize = authorize;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@chevre/factory": "4.289.0-alpha.6",
|
|
13
|
-
"@cinerino/sdk": "3.140.0-alpha.
|
|
13
|
+
"@cinerino/sdk": "3.140.0-alpha.8",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.4.0-alpha.
|
|
123
|
+
"version": "20.4.0-alpha.6"
|
|
124
124
|
}
|