@chevre/domain 21.18.0-alpha.34 → 21.18.0-alpha.35
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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
/**
|
|
4
|
+
* 決済サービスリポジトリ
|
|
5
|
+
*/
|
|
6
|
+
export declare class MongoRepository {
|
|
7
|
+
private readonly productModel;
|
|
8
|
+
constructor(connection: Connection);
|
|
9
|
+
/**
|
|
10
|
+
* 決済サービスを保管する
|
|
11
|
+
*/
|
|
12
|
+
savePaymentService(params: {
|
|
13
|
+
/**
|
|
14
|
+
* idを指定すれば更新
|
|
15
|
+
*/
|
|
16
|
+
id?: string;
|
|
17
|
+
$set: factory.service.paymentService.IService;
|
|
18
|
+
$unset: {
|
|
19
|
+
[key in keyof factory.service.paymentService.IService]?: 1;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 指定プロジェクトの指定プロダクトタイプが存在しなければ作成する
|
|
23
|
+
*/
|
|
24
|
+
createIfNotExist?: boolean;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = void 0;
|
|
24
|
+
const product_1 = require("./mongoose/schemas/product");
|
|
25
|
+
const factory = require("../factory");
|
|
26
|
+
/**
|
|
27
|
+
* 決済サービスリポジトリ
|
|
28
|
+
*/
|
|
29
|
+
class MongoRepository {
|
|
30
|
+
constructor(connection) {
|
|
31
|
+
this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 決済サービスを保管する
|
|
35
|
+
*/
|
|
36
|
+
savePaymentService(params) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
let doc;
|
|
39
|
+
if (typeof params.id === 'string') {
|
|
40
|
+
// 上書き禁止属性を除外
|
|
41
|
+
const _a = params.$set, { id, productID, project, typeOf, provider } = _a, setFields = __rest(_a, ["id", "productID", "project", "typeOf", "provider"]);
|
|
42
|
+
switch (typeOf) {
|
|
43
|
+
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
44
|
+
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
45
|
+
doc = yield this.productModel.findOneAndUpdate({
|
|
46
|
+
_id: { $eq: params.id },
|
|
47
|
+
typeOf: { $eq: typeOf }
|
|
48
|
+
}, { $set: setFields }, { upsert: false, new: true, projection: { _id: 1 } })
|
|
49
|
+
.exec();
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const _b = params.$set, { id } = _b, createParams = __rest(_b, ["id"]);
|
|
57
|
+
if (params.createIfNotExist === true) {
|
|
58
|
+
doc = yield this.productModel.findOneAndUpdate({
|
|
59
|
+
'project.id': { $eq: createParams.project.id },
|
|
60
|
+
typeOf: { $eq: createParams.typeOf }
|
|
61
|
+
}, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
|
|
62
|
+
.exec();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
doc = yield this.productModel.create(createParams);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (doc === null) {
|
|
69
|
+
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
70
|
+
}
|
|
71
|
+
return doc.toObject();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -55,19 +55,23 @@ export declare class MongoRepository {
|
|
|
55
55
|
searchPaymentServicesByProvider(params: Pick<factory.product.ISearchConditions, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPaymentServiceByProvider[]>;
|
|
56
56
|
/**
|
|
57
57
|
* プロダクトを保管する
|
|
58
|
-
* 作成 or 更新
|
|
59
58
|
*/
|
|
60
|
-
|
|
59
|
+
saveProduct(params: {
|
|
61
60
|
/**
|
|
62
61
|
* idを指定すれば更新
|
|
63
62
|
*/
|
|
64
63
|
id?: string;
|
|
65
|
-
|
|
64
|
+
$set: factory.product.IProduct;
|
|
65
|
+
$unset: {
|
|
66
|
+
[key in keyof factory.product.IProduct]?: 1;
|
|
67
|
+
};
|
|
66
68
|
/**
|
|
67
69
|
* 指定プロジェクトの指定プロダクトタイプが存在しなければ作成する
|
|
68
70
|
*/
|
|
69
71
|
createIfNotExist?: boolean;
|
|
70
|
-
}): Promise<
|
|
72
|
+
}): Promise<{
|
|
73
|
+
id: string;
|
|
74
|
+
}>;
|
|
71
75
|
deleteByHasOfferCatalog(params: {
|
|
72
76
|
project: {
|
|
73
77
|
id: string;
|
|
@@ -315,60 +315,48 @@ class MongoRepository {
|
|
|
315
315
|
}
|
|
316
316
|
/**
|
|
317
317
|
* プロダクトを保管する
|
|
318
|
-
* 作成 or 更新
|
|
319
318
|
*/
|
|
320
|
-
|
|
319
|
+
saveProduct(params) {
|
|
321
320
|
return __awaiter(this, void 0, void 0, function* () {
|
|
322
321
|
let doc;
|
|
323
|
-
// Documentにidは不要なので念のため除外
|
|
324
|
-
if (params.attributes.id !== undefined && params.attributes.id !== null) {
|
|
325
|
-
delete params.attributes.id;
|
|
326
|
-
}
|
|
327
322
|
if (typeof params.id === 'string') {
|
|
328
|
-
|
|
329
|
-
|
|
323
|
+
// 上書き禁止属性を除外
|
|
324
|
+
const _a = params.$set, { id, productID, project, typeOf, offers } = _a, setFields = __rest(_a, ["id", "productID", "project", "typeOf", "offers"]);
|
|
325
|
+
switch (typeOf) {
|
|
330
326
|
case factory.product.ProductType.EventService:
|
|
331
327
|
case factory.product.ProductType.MembershipService:
|
|
332
328
|
case factory.product.ProductType.PaymentCard:
|
|
333
329
|
case factory.product.ProductType.Product:
|
|
334
330
|
case factory.product.ProductType.Transportation:
|
|
335
|
-
// 上書き禁止属性を除外(2022-08-24~)
|
|
336
|
-
const { offers } = updateFields, updateProductFields = __rest(updateFields, ["offers"]);
|
|
337
|
-
doc = yield this.productModel.findOneAndUpdate({
|
|
338
|
-
_id: { $eq: params.id },
|
|
339
|
-
typeOf: { $eq: updateProductFields.typeOf }
|
|
340
|
-
}, updateProductFields, { upsert: false, new: true })
|
|
341
|
-
.exec();
|
|
342
|
-
break;
|
|
343
|
-
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
344
|
-
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
345
|
-
// 上書き禁止属性を除外(2022-08-24~)
|
|
346
|
-
const { provider } = updateFields, updatePaymentServiceFields = __rest(updateFields, ["provider"]);
|
|
347
331
|
doc = yield this.productModel.findOneAndUpdate({
|
|
348
332
|
_id: { $eq: params.id },
|
|
349
|
-
typeOf: { $eq:
|
|
350
|
-
},
|
|
333
|
+
typeOf: { $eq: typeOf }
|
|
334
|
+
}, {
|
|
335
|
+
$set: setFields,
|
|
336
|
+
$unset: params.$unset
|
|
337
|
+
}, { upsert: false, new: true, projection: { _id: 1 } })
|
|
351
338
|
.exec();
|
|
352
339
|
break;
|
|
353
340
|
default:
|
|
354
|
-
throw new factory.errors.NotImplemented(`${
|
|
355
|
-
}
|
|
356
|
-
if (doc === null) {
|
|
357
|
-
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
341
|
+
throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
|
|
358
342
|
}
|
|
359
343
|
}
|
|
360
344
|
else {
|
|
345
|
+
const _b = params.$set, { id } = _b, createParams = __rest(_b, ["id"]);
|
|
361
346
|
if (params.createIfNotExist === true) {
|
|
362
347
|
doc = yield this.productModel.findOneAndUpdate({
|
|
363
|
-
'project.id': { $eq:
|
|
364
|
-
typeOf: { $eq:
|
|
365
|
-
}, { $setOnInsert:
|
|
348
|
+
'project.id': { $eq: createParams.project.id },
|
|
349
|
+
typeOf: { $eq: createParams.typeOf }
|
|
350
|
+
}, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
|
|
366
351
|
.exec();
|
|
367
352
|
}
|
|
368
353
|
else {
|
|
369
|
-
doc = yield this.productModel.create(
|
|
354
|
+
doc = yield this.productModel.create(createParams);
|
|
370
355
|
}
|
|
371
356
|
}
|
|
357
|
+
if (doc === null) {
|
|
358
|
+
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
359
|
+
}
|
|
372
360
|
return doc.toObject();
|
|
373
361
|
});
|
|
374
362
|
}
|
|
@@ -26,6 +26,7 @@ import type { MongoRepository as OfferCatalogItemRepo } from './repo/offerCatalo
|
|
|
26
26
|
import type { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
|
|
27
27
|
import type { MongoRepository as OrderRepo } from './repo/order';
|
|
28
28
|
import type { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
|
|
29
|
+
import type { MongoRepository as PaymentServiceRepo } from './repo/paymentService';
|
|
29
30
|
import type { MongoRepository as PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
|
|
30
31
|
import type { MongoRepository as PermitRepo } from './repo/permit';
|
|
31
32
|
import type { MongoRepository as PlaceRepo } from './repo/place';
|
|
@@ -159,6 +160,10 @@ export type OwnershipInfo = OwnershipInfoRepo;
|
|
|
159
160
|
export declare namespace OwnershipInfo {
|
|
160
161
|
function createInstance(...params: ConstructorParameters<typeof OwnershipInfoRepo>): Promise<OwnershipInfoRepo>;
|
|
161
162
|
}
|
|
163
|
+
export type PaymentService = PaymentServiceRepo;
|
|
164
|
+
export declare namespace PaymentService {
|
|
165
|
+
function createInstance(...params: ConstructorParameters<typeof PaymentServiceRepo>): Promise<PaymentServiceRepo>;
|
|
166
|
+
}
|
|
162
167
|
export type PaymentServiceProvider = PaymentServiceProviderRepo;
|
|
163
168
|
export declare namespace PaymentServiceProvider {
|
|
164
169
|
function createInstance(...params: ConstructorParameters<typeof PaymentServiceProviderRepo>): Promise<PaymentServiceProviderRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = void 0;
|
|
13
14
|
var AcceptedOffer;
|
|
14
15
|
(function (AcceptedOffer) {
|
|
15
16
|
let repo;
|
|
@@ -361,6 +362,19 @@ var OwnershipInfo;
|
|
|
361
362
|
}
|
|
362
363
|
OwnershipInfo.createInstance = createInstance;
|
|
363
364
|
})(OwnershipInfo = exports.OwnershipInfo || (exports.OwnershipInfo = {}));
|
|
365
|
+
var PaymentService;
|
|
366
|
+
(function (PaymentService) {
|
|
367
|
+
let repo;
|
|
368
|
+
function createInstance(...params) {
|
|
369
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
370
|
+
if (repo === undefined) {
|
|
371
|
+
repo = (yield Promise.resolve().then(() => require('./repo/paymentService'))).MongoRepository;
|
|
372
|
+
}
|
|
373
|
+
return new repo(...params);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
PaymentService.createInstance = createInstance;
|
|
377
|
+
})(PaymentService = exports.PaymentService || (exports.PaymentService = {}));
|
|
364
378
|
var PaymentServiceProvider;
|
|
365
379
|
(function (PaymentServiceProvider) {
|
|
366
380
|
let repo;
|
package/package.json
CHANGED