@chevre/domain 21.33.0-alpha.3 → 21.33.0-alpha.5
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/findTransactionInProgressById.ts +23 -0
- package/lib/chevre/repo/task.d.ts +3 -1
- package/lib/chevre/repo/task.js +4 -4
- package/lib/chevre/repo/transaction.d.ts +3 -1
- package/lib/chevre/repo/transaction.js +21 -3
- package/lib/chevre/service/offer/event/factory.d.ts +2 -2
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
- package/lib/chevre/service/offer/product/factory.d.ts +2 -2
- package/lib/chevre/service/payment/any/factory.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
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, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const transaction = await transactionRepo.findInProgressById(
|
|
12
|
+
{
|
|
13
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
14
|
+
id: '6656d35dd1f13f8c658be102'
|
|
15
|
+
}
|
|
16
|
+
// ['_id']
|
|
17
|
+
);
|
|
18
|
+
console.log('transaction:', transaction);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.then(console.log)
|
|
23
|
+
.catch(console.error);
|
|
@@ -58,7 +58,9 @@ export declare class MongoRepository {
|
|
|
58
58
|
readonly taskModel: typeof Model;
|
|
59
59
|
constructor(connection: Connection);
|
|
60
60
|
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
|
|
61
|
-
saveOne(savingTask: factory.task.IAttributes<factory.taskName>, options: IOptionOnCreate): Promise<
|
|
61
|
+
saveOne(savingTask: factory.task.IAttributes<factory.taskName>, options: IOptionOnCreate): Promise<{
|
|
62
|
+
id: string;
|
|
63
|
+
}>;
|
|
62
64
|
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[], options: IOptionOnCreate): Promise<{
|
|
63
65
|
id: string;
|
|
64
66
|
}[]>;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -144,18 +144,18 @@ class MongoRepository {
|
|
|
144
144
|
var _a, _b;
|
|
145
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
146
|
const result = yield this.taskModel.insertMany(savingTask, { rawResult: true });
|
|
147
|
-
const
|
|
148
|
-
if (typeof
|
|
147
|
+
const id = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
148
|
+
if (typeof id !== 'string') {
|
|
149
149
|
throw new factory.errors.ServiceUnavailable('task not saved');
|
|
150
150
|
}
|
|
151
151
|
const { emitImmediately } = options;
|
|
152
152
|
if (emitImmediately) {
|
|
153
153
|
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
154
|
-
id
|
|
154
|
+
id,
|
|
155
155
|
status: factory.taskStatus.Ready
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
return
|
|
158
|
+
return { id };
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
saveMany(taskAttributes, options) {
|
|
@@ -48,6 +48,8 @@ interface IStatus {
|
|
|
48
48
|
export interface IAggregatePlaceOrder {
|
|
49
49
|
statuses: IStatus[];
|
|
50
50
|
}
|
|
51
|
+
type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
|
|
52
|
+
type ITransactionInProgress<T extends factory.transactionType> = T extends factory.transactionType.MoneyTransfer ? Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.PlaceOrder ? Omit<factory.transaction.placeOrder.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.ReturnOrder ? Omit<factory.transaction.returnOrder.ITransaction, IOmittedFieldsInProgress> : never;
|
|
51
53
|
/**
|
|
52
54
|
* 取引リポジトリ
|
|
53
55
|
*/
|
|
@@ -74,7 +76,7 @@ export declare class MongoRepository {
|
|
|
74
76
|
findInProgressById<T extends factory.transactionType>(params: {
|
|
75
77
|
typeOf: T;
|
|
76
78
|
id: string;
|
|
77
|
-
}): Promise<
|
|
79
|
+
}, inclusion?: IKeyOfProjection<T>[]): Promise<ITransactionInProgress<T>>;
|
|
78
80
|
/**
|
|
79
81
|
* 取引の注文番号を検索する
|
|
80
82
|
*/
|
|
@@ -293,15 +293,33 @@ class MongoRepository {
|
|
|
293
293
|
/**
|
|
294
294
|
* 進行中の取引を取得する
|
|
295
295
|
*/
|
|
296
|
-
findInProgressById(params) {
|
|
296
|
+
findInProgressById(params, inclusion) {
|
|
297
297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
-
|
|
298
|
+
let projection = {};
|
|
299
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
300
|
+
inclusion.forEach((field) => {
|
|
301
|
+
projection[field] = 1;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// minimize(2024-05-29~)
|
|
306
|
+
projection = {
|
|
307
|
+
__v: 0,
|
|
308
|
+
createdAt: 0,
|
|
309
|
+
updatedAt: 0,
|
|
310
|
+
tasksExportAction: 0,
|
|
311
|
+
tasksExportedAt: 0,
|
|
312
|
+
tasksExportationStatus: 0
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const filter = {
|
|
299
316
|
_id: { $eq: params.id },
|
|
300
317
|
typeOf: { $eq: params.typeOf },
|
|
301
318
|
status: { $eq: factory.transactionStatusType.InProgress },
|
|
302
319
|
// expiresを条件に追加(2023-05-12~),
|
|
303
320
|
expires: { $gt: new Date() }
|
|
304
|
-
}
|
|
321
|
+
};
|
|
322
|
+
const doc = yield this.transactionModel.findOne(filter, projection)
|
|
305
323
|
.exec();
|
|
306
324
|
if (doc === null) {
|
|
307
325
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -10,14 +10,14 @@ export declare function createReserveTransactionStartParams(params: {
|
|
|
10
10
|
id: string;
|
|
11
11
|
};
|
|
12
12
|
broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
13
|
-
transaction: factory.transaction.ITransaction<factory.transactionType>;
|
|
13
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
14
14
|
transactionNumber: string;
|
|
15
15
|
}): factory.assetTransaction.reserve.IStartParamsWithoutDetail;
|
|
16
16
|
export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
17
17
|
acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
|
|
18
18
|
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
19
19
|
pendingTransaction: factory.action.authorize.offer.eventService.IChevrePendingTransaction;
|
|
20
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
20
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
21
21
|
broker?: factory.reservation.IBroker<factory.reservationType.EventReservation>;
|
|
22
22
|
}): factory.action.authorize.offer.eventService.IAttributes<factory.service.webAPI.Identifier.Chevre>;
|
|
23
23
|
export declare function acceptedOffers2amount(params: {
|
|
@@ -22,7 +22,7 @@ declare function processStartReserve4chevre(params: {
|
|
|
22
22
|
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
23
23
|
broker?: factory.reservation.IBroker<factory.reservationType>;
|
|
24
24
|
transactionNumber?: string;
|
|
25
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
25
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
26
26
|
availableAtOrFrom: {
|
|
27
27
|
id: string;
|
|
28
28
|
};
|
|
@@ -5,7 +5,7 @@ export type IAcceptedOffer4COA = factory.action.authorize.offer.eventService.IAc
|
|
|
5
5
|
export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
6
6
|
acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
|
|
7
7
|
event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id' | 'typeOf'>;
|
|
8
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
8
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
9
9
|
pendingTransaction: factory.action.authorize.offer.eventService.ICOAPendingTransaction;
|
|
10
10
|
}): factory.action.authorize.offer.eventService.IAttributes<WebAPIIdentifier.COA>;
|
|
11
11
|
/**
|
|
@@ -5,12 +5,12 @@ export declare function createRegisterServiceStartParams(params: {
|
|
|
5
5
|
typeOf: factory.organizationType.Project;
|
|
6
6
|
};
|
|
7
7
|
object: factory.action.authorize.offer.product.IObject;
|
|
8
|
-
transaction: factory.transaction.ITransaction<factory.transactionType>;
|
|
8
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType>, 'seller' | 'expires'>;
|
|
9
9
|
transactionNumber: string;
|
|
10
10
|
}): factory.assetTransaction.registerService.IStartParamsWithoutDetail;
|
|
11
11
|
export declare function createActionAttributes(params: {
|
|
12
12
|
acceptedOffer: factory.action.authorize.offer.product.IObject;
|
|
13
|
-
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
13
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
|
|
14
14
|
transactionNumber: string;
|
|
15
15
|
}): factory.action.authorize.offer.product.IAttributes;
|
|
16
16
|
export declare function acceptedOffers2amount(params: {
|
|
@@ -14,7 +14,7 @@ export declare function creatPayTransactionStartParams(params: {
|
|
|
14
14
|
accountId?: string;
|
|
15
15
|
object: factory.action.authorize.paymentMethod.any.IObject;
|
|
16
16
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
17
|
-
transaction: factory.transaction.ITransaction<factory.transactionType>;
|
|
17
|
+
transaction: Omit<factory.transaction.ITransaction<factory.transactionType>, 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus'>;
|
|
18
18
|
transactionNumber: string;
|
|
19
19
|
location?: factory.action.trade.pay.ILocation;
|
|
20
20
|
}): factory.assetTransaction.pay.IStartParamsWithoutDetail;
|
package/package.json
CHANGED