@chevre/domain 25.0.0-alpha.10 → 25.0.0-alpha.11

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.
@@ -1,7 +1,7 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import { factory } from '../factory';
3
3
  import { AcceptedOfferInReserveRepo } from './acceptedOfferInReserve';
4
- type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'> & {
4
+ type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project' | 'broker'> & {
5
5
  typeOf: factory.transactionType.PlaceOrder;
6
6
  orderDate: Date;
7
7
  /**
@@ -57,6 +57,7 @@ export type IMinimizedAcceptedOffer = Pick<factory.order.IOptimizedAcceptedOffer
57
57
  export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
58
58
  private readonly orderModel;
59
59
  constructor(connection: Connection);
60
+ createPlaceOrderIfNotExists(params: Pick<IOrderInTransaction, 'orderNumber' | 'project' | 'identifier' | 'broker'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
60
61
  /**
61
62
  * 取引進行中の注文からacceptedOffersを検索する
62
63
  * 予約取引から予約ごとの価格仕様も参照する
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderInTransactionRepo = void 0;
4
4
  // import { isDeepStrictEqual } from 'util';
5
+ const errorHandler_1 = require("../errorHandler");
5
6
  const factory_1 = require("../factory");
6
7
  const order_1 = require("./mongoose/schemas/order");
7
8
  const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
@@ -15,6 +16,33 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
15
16
  super(connection);
16
17
  this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
17
18
  }
19
+ async createPlaceOrderIfNotExists(params) {
20
+ const { orderNumber, project, identifier, broker } = params;
21
+ const setOnInsert = {
22
+ typeOf: factory_1.factory.transactionType.PlaceOrder,
23
+ orderDate: new Date(), // orderDate required(2024-12-09~)
24
+ orderNumber,
25
+ project,
26
+ identifier, // 取引ID(2026-06-22~)
27
+ ...((broker !== undefined) && { broker })
28
+ };
29
+ try {
30
+ return this.orderModel.updateOne({
31
+ identifier: { $eq: identifier }, // 取引IDに対してユニークネスを保証する
32
+ }, { $setOnInsert: setOnInsert }, { upsert: true })
33
+ .exec();
34
+ }
35
+ catch (error) {
36
+ let throwsError = true;
37
+ if (await (0, errorHandler_1.isMongoDuplicateError)(error)) {
38
+ // すでにidentifierが存在する場合ok
39
+ throwsError = false;
40
+ }
41
+ if (throwsError) {
42
+ throw error;
43
+ }
44
+ }
45
+ }
18
46
  /**
19
47
  * 取引進行中の注文からacceptedOffersを検索する
20
48
  * 予約取引から予約ごとの価格仕様も参照する
@@ -59,26 +87,6 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
59
87
  };
60
88
  });
61
89
  }
62
- // /**
63
- // * 取引進行中の注文からacceptedOffersを検索する
64
- // */
65
- // public async findAcceptedOffersByOrderNumber(
66
- // params: { orderNumber: { $eq: string } }
67
- // ): Promise<Pick<factory.order.IAcceptedOffer, 'itemOffered' | 'serialNumber'>[]> {
68
- // const doc = await this.orderModel.findOne<HydratedDocument<Pick<factory.order.IAcceptedOffer, 'itemOffered' | 'serialNumber'>>>(
69
- // {
70
- // orderNumber: { $eq: params.orderNumber.$eq },
71
- // typeOf: { $eq: factory.transactionType.PlaceOrder }
72
- // },
73
- // { acceptedOffers: 1 }
74
- // )
75
- // .lean<Pick<IOrderInTransaction, 'acceptedOffers'>>()
76
- // .exec();
77
- // if (doc === null) {
78
- // throw new factory.errors.NotFound('orderInTransaction');
79
- // }
80
- // return doc.acceptedOffers;
81
- // }
82
90
  /**
83
91
  * 注文を受注する
84
92
  * typeOf: PlaceOrder -> typeOf: Order
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * 注文取引サービス
3
3
  */
4
- import { POINT_AWARD_IDENTIFIER_NAME } from '../../factory/order';
5
4
  import { confirm } from './placeOrder/confirm';
6
5
  import { exportTasksById } from './placeOrder/exportTasksById';
7
6
  import { start, IStartPlaceOrderParams } from './placeOrder/start';
8
7
  import { updateAgent } from './placeOrder/updateAgent';
9
- export { confirm, POINT_AWARD_IDENTIFIER_NAME, start, IStartPlaceOrderParams, exportTasksById, updateAgent };
8
+ import { issueOrderNumberIfNotExist } from './placeOrder/issueOrderNumberIfNotExist';
9
+ export { confirm, start, IStartPlaceOrderParams, exportTasksById, updateAgent, issueOrderNumberIfNotExist };
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateAgent = exports.exportTasksById = exports.start = exports.POINT_AWARD_IDENTIFIER_NAME = exports.confirm = void 0;
3
+ exports.issueOrderNumberIfNotExist = exports.updateAgent = exports.exportTasksById = exports.start = exports.confirm = void 0;
4
4
  /**
5
5
  * 注文取引サービス
6
6
  */
7
- const order_1 = require("../../factory/order");
8
- Object.defineProperty(exports, "POINT_AWARD_IDENTIFIER_NAME", { enumerable: true, get: function () { return order_1.POINT_AWARD_IDENTIFIER_NAME; } });
9
7
  const confirm_1 = require("./placeOrder/confirm");
10
8
  Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return confirm_1.confirm; } });
11
9
  const exportTasksById_1 = require("./placeOrder/exportTasksById");
@@ -14,3 +12,5 @@ const start_1 = require("./placeOrder/start");
14
12
  Object.defineProperty(exports, "start", { enumerable: true, get: function () { return start_1.start; } });
15
13
  const updateAgent_1 = require("./placeOrder/updateAgent");
16
14
  Object.defineProperty(exports, "updateAgent", { enumerable: true, get: function () { return updateAgent_1.updateAgent; } });
15
+ const issueOrderNumberIfNotExist_1 = require("./placeOrder/issueOrderNumberIfNotExist");
16
+ Object.defineProperty(exports, "issueOrderNumberIfNotExist", { enumerable: true, get: function () { return issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist; } });
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import * as AccountTransactionIdentifierFactory from './factory/accountTransactionIdentifier';
5
5
  import * as EventFactory from './factory/event';
6
- import * as OrderFactory from './factory/order';
7
6
  import * as ReservedAgentIdentifireNamesFactory from './factory/reservedAgentIdentifireNames';
8
7
  import * as TaskIdentifierFactory from './factory/taskIdentifier';
9
8
  import * as TransactionFactory from './factory/transaction';
@@ -60,7 +59,6 @@ export declare namespace transaction {
60
59
  export declare namespace factory {
61
60
  export import accountTransactionIdentifier = AccountTransactionIdentifierFactory;
62
61
  export import event = EventFactory;
63
- export import order = OrderFactory;
64
62
  export import reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
65
63
  export import taskIdentifier = TaskIdentifierFactory;
66
64
  export import transaction = TransactionFactory;
@@ -40,7 +40,6 @@ exports.factory = exports.transaction = exports.task = exports.reserve = exports
40
40
  */
41
41
  const AccountTransactionIdentifierFactory = __importStar(require("./factory/accountTransactionIdentifier"));
42
42
  const EventFactory = __importStar(require("./factory/event"));
43
- const OrderFactory = __importStar(require("./factory/order"));
44
43
  const ReservedAgentIdentifireNamesFactory = __importStar(require("./factory/reservedAgentIdentifireNames"));
45
44
  const TaskIdentifierFactory = __importStar(require("./factory/taskIdentifier"));
46
45
  const TransactionFactory = __importStar(require("./factory/transaction"));
@@ -183,7 +182,6 @@ var factory;
183
182
  (function (factory) {
184
183
  factory.accountTransactionIdentifier = AccountTransactionIdentifierFactory;
185
184
  factory.event = EventFactory;
186
- factory.order = OrderFactory;
187
185
  factory.reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
188
186
  factory.taskIdentifier = TaskIdentifierFactory;
189
187
  factory.transaction = TransactionFactory;
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "25.0.0-alpha.10"
94
+ "version": "25.0.0-alpha.11"
95
95
  }
@@ -1,2 +0,0 @@
1
- export declare const POINT_AWARD_IDENTIFIER_NAME = "pointAwardIdentifiers";
2
- export declare const AWARD_ACCOUNTS_IDENTIFIER_NAME = "awardAccounts";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = exports.POINT_AWARD_IDENTIFIER_NAME = void 0;
4
- exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
5
- exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = 'awardAccounts';