@chevre/domain 24.0.0-alpha.77 → 24.0.0-alpha.79

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.
Files changed (74) hide show
  1. package/lib/chevre/repo/action/actionProcess.d.ts +4 -4
  2. package/lib/chevre/repo/action/authorizeOffer.d.ts +2 -3
  3. package/lib/chevre/repo/action/authorizeOffer.js +2 -2
  4. package/lib/chevre/repo/action.d.ts +2 -2
  5. package/lib/chevre/repo/assetTransaction.d.ts +3 -51
  6. package/lib/chevre/repo/assetTransaction.js +51 -51
  7. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
  8. package/lib/chevre/repo/product.d.ts +0 -10
  9. package/lib/chevre/repo/product.js +28 -22
  10. package/lib/chevre/repo/task.d.ts +1 -1
  11. package/lib/chevre/repository.d.ts +0 -5
  12. package/lib/chevre/repository.js +0 -11
  13. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
  14. package/lib/chevre/service/assetTransaction/pay/start/factory.js +7 -7
  15. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +18 -16
  16. package/lib/chevre/service/assetTransaction/refund.js +19 -17
  17. package/lib/chevre/service/assetTransaction/reserve/start.js +8 -8
  18. package/lib/chevre/service/assetTransaction.d.ts +0 -2
  19. package/lib/chevre/service/assetTransaction.js +8 -10
  20. package/lib/chevre/service/delivery/factory.js +13 -13
  21. package/lib/chevre/service/offer/any.d.ts +1 -1
  22. package/lib/chevre/service/offer/event/authorize.js +7 -32
  23. package/lib/chevre/service/offer/product.d.ts +0 -62
  24. package/lib/chevre/service/offer/product.js +0 -409
  25. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +1 -1
  26. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +48 -43
  27. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +38 -37
  28. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  29. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  30. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -96
  31. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  32. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
  33. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +0 -1
  34. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +3 -28
  35. package/lib/chevre/service/order/placeOrder/factory.js +5 -5
  36. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +1 -1
  37. package/lib/chevre/service/payment/factory.js +23 -23
  38. package/lib/chevre/service/product.js +16 -16
  39. package/lib/chevre/service/reserve/confirmReservation.js +19 -17
  40. package/lib/chevre/service/reserve/factory.d.ts +0 -6
  41. package/lib/chevre/service/reserve/factory.js +0 -59
  42. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +16 -15
  43. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +0 -1
  44. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +2 -2
  45. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -2
  46. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +3 -3
  47. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +16 -12
  48. package/lib/chevre/service/transaction/placeOrder/confirm.js +21 -23
  49. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -21
  50. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +4 -4
  51. package/lib/chevre/service/validation/validateOrder.js +11 -10
  52. package/package.json +2 -2
  53. package/lib/chevre/repo/action/authorizeProductOffer.d.ts +0 -26
  54. package/lib/chevre/repo/action/authorizeProductOffer.js +0 -32
  55. package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +0 -21
  56. package/lib/chevre/service/assetTransaction/registerService/factory.js +0 -171
  57. package/lib/chevre/service/assetTransaction/registerService/potentialActions.d.ts +0 -8
  58. package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -148
  59. package/lib/chevre/service/assetTransaction/registerService.d.ts +0 -54
  60. package/lib/chevre/service/assetTransaction/registerService.js +0 -273
  61. package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.d.ts +0 -15
  62. package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +0 -44
  63. package/lib/chevre/service/delivery/product/factory.d.ts +0 -13
  64. package/lib/chevre/service/delivery/product/factory.js +0 -81
  65. package/lib/chevre/service/offer/product/factory.d.ts +0 -37
  66. package/lib/chevre/service/offer/product/factory.js +0 -208
  67. package/lib/chevre/service/task/confirmRegisterService.d.ts +0 -6
  68. package/lib/chevre/service/task/confirmRegisterService.js +0 -19
  69. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +0 -17
  70. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +0 -116
  71. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +0 -6
  72. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +0 -23
  73. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -8
  74. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +0 -89
@@ -1,51 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
37
3
  exports.search = search;
38
- exports.authorize = authorize;
39
- exports.voidTransaction = voidTransaction;
40
4
  const factory_1 = require("../../factory");
41
- const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
42
- const availableProductTypes_1 = require("../../factory/availableProductTypes");
43
- const RegisterServiceTransaction = __importStar(require("../assetTransaction/registerService"));
44
- const issueOrderNumberIfNotExist_1 = require("../transaction/placeOrder/issueOrderNumberIfNotExist");
45
- const any_1 = require("./any");
46
- const factory_2 = require("./product/factory");
47
5
  const searchProductOffers_1 = require("./product/searchProductOffers");
48
- exports.ERROR_MESSAGE_ALREADY_REGISTERED = 'Already registered';
49
6
  /**
50
7
  * プロダクトオファーを検索する
51
8
  */
@@ -64,31 +21,6 @@ function search(params) {
64
21
  if (product === undefined) {
65
22
  throw new factory_1.factory.errors.NotFound('Product');
66
23
  }
67
- // 販売者指定の場合、検証
68
- if (product.typeOf === factory_1.factory.product.ProductType.MembershipService
69
- || product.typeOf === factory_1.factory.product.ProductType.PaymentCard) {
70
- const sellerId = params.seller?.id;
71
- if (typeof sellerId === 'string') {
72
- // productsドキュメント参照のoffers検証は廃止(2025-09-22~)
73
- // const productOffers = await repos.productOffer.search({
74
- // project: { id: { $eq: params.project.id } },
75
- // itemOffered: { id: { $eq: params.itemOffered.id } },
76
- // seller: { id: { $eq: sellerId } }
77
- // });
78
- // const hasValidOffer = productOffers.some((o) => {
79
- // return o.seller?.id === sellerId
80
- // && o.validFrom !== undefined
81
- // && moment(o.validFrom)
82
- // .isSameOrBefore(now)
83
- // && o.validThrough !== undefined
84
- // && moment(o.validThrough)
85
- // .isSameOrAfter(now);
86
- // });
87
- // if (!hasValidOffer) {
88
- // return { offers: [], product };
89
- // }
90
- }
91
- }
92
24
  const offers = await (0, searchProductOffers_1.searchProductOffers)({
93
25
  ids: params.ids,
94
26
  itemOffered: { id: params.itemOffered.id },
@@ -103,344 +35,3 @@ function search(params) {
103
35
  return { offers, product };
104
36
  };
105
37
  }
106
- /**
107
- * サービス(Chevreプロダクト)オファー承認
108
- */
109
- function authorize(params) {
110
- return async (repos) => {
111
- const now = new Date();
112
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
113
- typeOf: factory_1.factory.transactionType.PlaceOrder,
114
- id: params.transaction.id
115
- }, ['agent', 'project', 'seller', 'typeOf', 'expires']);
116
- if (transaction.agent.id !== params.agent.id) {
117
- throw new factory_1.factory.errors.Forbidden('Transaction not yours');
118
- }
119
- const { product, availableOffers } = await fixProductAndOffers(params)(repos);
120
- // 会員の場合のみ既登録か確認
121
- if (params.agent.typeOf === factory_1.factory.personType.Person) {
122
- await checkIfRegistered({
123
- agent: { id: params.agent.id },
124
- product: { id: String(product.id), typeOf: product.typeOf },
125
- now: now
126
- // iss: params.iss
127
- })(repos);
128
- }
129
- // ポイント特典の識別子に利用するため注文番号を先に発行
130
- const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
131
- project: { id: transaction.project.id },
132
- id: transaction.id,
133
- object: { orderDate: new Date() }
134
- })(repos);
135
- let acceptedOffer = await validateAcceptedOffers({
136
- object: params.object,
137
- product,
138
- availableOffers,
139
- seller: transaction.seller,
140
- orderNumber
141
- })({});
142
- acceptedOffer = await createServiceOutputIdentifier({ acceptedOffer, product })(repos);
143
- let requestBody;
144
- let responseBody;
145
- let result;
146
- // まず取引番号発行
147
- const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({
148
- startDate: new Date()
149
- });
150
- const actionAttributes = (0, factory_2.createActionAttributes)({
151
- acceptedOffer: acceptedOffer,
152
- transaction: transaction,
153
- transactionNumber: transactionNumber
154
- });
155
- const action = await repos.authorizeProductOfferAction.start(actionAttributes);
156
- try {
157
- // 会員の場合のみ排他ロック
158
- // if (params.agent.typeOf === factory.personType.Person) {
159
- // }
160
- // サービス登録開始
161
- const startParams = (0, factory_2.createRegisterServiceStartParams)({
162
- project: { typeOf: factory_1.factory.organizationType.Project, id: params.project.id },
163
- object: acceptedOffer,
164
- transaction: transaction,
165
- transactionNumber
166
- });
167
- requestBody = startParams;
168
- responseBody = await RegisterServiceTransaction.start(startParams)(repos);
169
- const acceptedOffers4result = (0, factory_2.responseBody2resultAcceptedOffer)({
170
- project: actionAttributes.project, responseBody, acceptedOffer
171
- });
172
- result = (0, factory_2.createResult)({ project: actionAttributes.project, requestBody, responseBody, acceptedOffer });
173
- await (0, any_1.acceptOffer)({
174
- orderNumber,
175
- project: transaction.project,
176
- acceptedOffers: acceptedOffers4result
177
- })(repos);
178
- }
179
- catch (error) {
180
- try {
181
- await repos.authorizeProductOfferAction.giveUp({ typeOf: action.typeOf, id: action.id, error });
182
- }
183
- catch (__) {
184
- // no op
185
- }
186
- throw error;
187
- }
188
- await repos.authorizeProductOfferAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
189
- return { id: action.id, result };
190
- };
191
- }
192
- function fixProductAndOffers(params) {
193
- return async (repos) => {
194
- const productId = String(params.object[0]?.itemOffered?.id);
195
- const searchProductsResult = await repos.product.projectFields({
196
- limit: 1,
197
- page: 1,
198
- project: { id: { $eq: params.project.id } },
199
- id: { $eq: productId }
200
- }, ['id', 'name', 'productID', 'project', 'serviceOutput', 'serviceType', 'typeOf']
201
- // []
202
- );
203
- const product = searchProductsResult.shift();
204
- if (product === undefined) {
205
- throw new factory_1.factory.errors.NotFound('Product');
206
- }
207
- if (product.typeOf !== factory_1.factory.product.ProductType.MembershipService
208
- && product.typeOf !== factory_1.factory.product.ProductType.PaymentCard) {
209
- throw new factory_1.factory.errors.Argument('object.itemOffered.id', `invalid product type: ${product.typeOf}`);
210
- }
211
- const { offers } = await search({
212
- ids: params.object.map((o) => String(o.id)),
213
- project: { id: params.project.id },
214
- itemOffered: { id: String(product.id) },
215
- onlyValid: true,
216
- includedInDataCatalog: { id: '' }, // 承認時はカタログ指定の必要なし
217
- addSortIndex: false,
218
- useIncludeInDataCatalog: false,
219
- // 利用アプリケーションを指定
220
- ...(typeof params.location?.id === 'string') ? { availableAt: { id: params.location.id } } : undefined
221
- })(repos);
222
- return { product, availableOffers: offers };
223
- };
224
- }
225
- function voidTransaction(params) {
226
- return async (repos) => {
227
- const transaction = await repos.placeOrder.findPlaceOrderById({
228
- typeOf: params.purpose.typeOf,
229
- id: params.purpose.id
230
- }, ['agent', 'status', 'typeOf']);
231
- if (transaction.status !== factory_1.factory.transactionStatusType.Canceled
232
- && transaction.status !== factory_1.factory.transactionStatusType.Expired
233
- && transaction.status !== factory_1.factory.transactionStatusType.InProgress) {
234
- throw new factory_1.factory.errors.Argument('purpose', `invalid transaction status: ${transaction.status}`);
235
- }
236
- if (typeof params.agent?.id === 'string') {
237
- if (transaction.agent.id !== params.agent.id) {
238
- throw new factory_1.factory.errors.Forbidden('Transaction not yours');
239
- }
240
- }
241
- let authorizeActions;
242
- if (typeof params.id === 'string') {
243
- const action = await repos.authorizeProductOfferAction.findById({ typeOf: factory_1.factory.actionType.AuthorizeAction, id: params.id });
244
- if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
245
- throw new factory_1.factory.errors.Argument('Transaction', 'Action not found in the transaction');
246
- }
247
- authorizeActions = [action];
248
- }
249
- else {
250
- authorizeActions = await repos.authorizeProductOfferAction.findAuthorizeProductOfferActionsByPurpose({
251
- // typeOf: factory.actionType.AuthorizeAction,
252
- purpose: {
253
- typeOf: params.purpose.typeOf,
254
- id: params.purpose.id
255
- }
256
- })
257
- .then((actions) => actions
258
- .filter((a) =>
259
- // Array.isArray(a.object)
260
- // && a.object.length > 0
261
- // && a.object[0].typeOf === factory.offerType.Offer
262
- // && availableProductTypes.indexOf(a.object[0].itemOffered.typeOf) >= 0
263
- a.object.typeOf === factory_1.factory.action.authorize.offer.product.ObjectType.AggregateOffer
264
- && availableProductTypes_1.availableProductTypes.indexOf(a.object.itemOffered.typeOf) >= 0));
265
- }
266
- await Promise.all(authorizeActions.map(async (action) => {
267
- // const productId = action.object[0]?.itemOffered?.id;
268
- const productId = action.object?.itemOffered?.id;
269
- if (typeof productId === 'string') {
270
- // 廃止(2023-12-07~)
271
- // await processUnlockRegisterMembershipService({
272
- // agent: { id: transaction.agent.id },
273
- // product: { id: productId },
274
- // purpose: params.purpose
275
- // })(repos);
276
- }
277
- await repos.authorizeProductOfferAction.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
278
- await processVoidRegisterServiceTransaction({
279
- action,
280
- project: params.project
281
- })(repos);
282
- }));
283
- };
284
- }
285
- /**
286
- * Chevre進行中取引を中止する
287
- */
288
- function processVoidRegisterServiceTransaction(params) {
289
- return async (repos) => {
290
- const transactionNumber = params.action.instrument?.transactionNumber;
291
- if (typeof transactionNumber === 'string') {
292
- // 取引が存在すれば中止
293
- const searchAssetTransactionsResult = await repos.assetTransaction.search({
294
- limit: 1,
295
- page: 1,
296
- project: { id: { $eq: params.project.id } },
297
- typeOf: factory_1.factory.assetTransactionType.RegisterService,
298
- transactionNumber: { $eq: transactionNumber }
299
- });
300
- if (searchAssetTransactionsResult.length > 0) {
301
- await RegisterServiceTransaction.cancel({ transactionNumber })(repos);
302
- // await repos.registerServiceTransaction.cancel({ transactionNumber: transactionNumber });
303
- }
304
- }
305
- };
306
- }
307
- /**
308
- * 受け入れらたオファーの内容を検証
309
- */
310
- function validateAcceptedOffers(params) {
311
- return async (__) => {
312
- let acceptedOfferWithoutDetail = params.object;
313
- if (!Array.isArray(acceptedOfferWithoutDetail)) {
314
- acceptedOfferWithoutDetail = [acceptedOfferWithoutDetail];
315
- }
316
- if (acceptedOfferWithoutDetail.length === 0) {
317
- throw new factory_1.factory.errors.ArgumentNull('object');
318
- }
319
- const project = { typeOf: factory_1.factory.organizationType.Project, id: params.product.project.id };
320
- const issuedBy = {
321
- id: params.seller.id,
322
- name: params.seller.name,
323
- typeOf: params.seller.typeOf
324
- };
325
- // 販売者を検証
326
- // productsドキュメント参照のoffers検証は廃止(2025-09-22~)
327
- // const productOffers = await repos.productOffer.search({
328
- // project: { id: { $eq: params.product.project.id } },
329
- // itemOffered: { id: { $eq: String(params.product.id) } },
330
- // seller: { id: { $eq: params.seller.id } }
331
- // });
332
- // const hasValidOffer = productOffers.some((o) => {
333
- // return o.seller?.id === params.seller.id;
334
- // });
335
- // if (!hasValidOffer) {
336
- // throw new factory.errors.Argument('Product', 'Product has no valid offer');
337
- // }
338
- // 利用可能なチケットオファーであれば受け入れる
339
- return Promise.all(acceptedOfferWithoutDetail.map((offerWithoutDetail) => {
340
- const offer = params.availableOffers.find((o) => o.id === offerWithoutDetail.id);
341
- if (offer === undefined) {
342
- throw new factory_1.factory.errors.NotFound('Offer', `Offer ${offerWithoutDetail.id} not found`);
343
- }
344
- // ポイント特典入金先の指定があれば入金識別子を発行
345
- let pointAward;
346
- const pointAwardToLocationIdentifier = offerWithoutDetail.itemOffered?.pointAward?.toLocation?.identifier;
347
- const pointAwardToLocationIssuedThroughId = offerWithoutDetail.itemOffered?.pointAward?.toLocation?.issuedThrough.id;
348
- if (typeof pointAwardToLocationIdentifier === 'string' && pointAwardToLocationIdentifier.length > 0
349
- && typeof pointAwardToLocationIssuedThroughId === 'string' && pointAwardToLocationIssuedThroughId.length > 0) {
350
- const pointAwardPurposeIdentifier = (0, accountTransactionIdentifier_1.createPointAwardIdentifier)({
351
- project: project,
352
- purpose: { orderNumber: params.orderNumber },
353
- toLocation: { identifier: pointAwardToLocationIdentifier }
354
- });
355
- pointAward = {
356
- recipient: offerWithoutDetail.itemOffered.pointAward?.recipient,
357
- toLocation: {
358
- identifier: pointAwardToLocationIdentifier,
359
- // toLocation.issuedThroughを保証する
360
- issuedThrough: { id: pointAwardToLocationIssuedThroughId },
361
- typeOf: factory_1.factory.permit.PermitType.Permit
362
- },
363
- typeOf: factory_1.factory.actionType.MoneyTransfer,
364
- purpose: { identifier: pointAwardPurposeIdentifier },
365
- ...(typeof offerWithoutDetail.itemOffered.pointAward?.description === 'string')
366
- ? { description: offerWithoutDetail.itemOffered.pointAward.description }
367
- : undefined
368
- };
369
- }
370
- const itemOffered = {
371
- // project: project,
372
- typeOf: params.product.typeOf,
373
- id: params.product.id,
374
- name: params.product.name,
375
- serviceOutput: {
376
- ...params.product?.serviceOutput,
377
- ...offerWithoutDetail.itemOffered?.serviceOutput,
378
- project: project,
379
- // 発行者は販売者でいったん固定
380
- issuedBy: issuedBy,
381
- typeOf: factory_1.factory.permit.PermitType.Permit
382
- },
383
- ...(pointAward !== undefined) ? { pointAward } : undefined
384
- };
385
- return {
386
- ...offerWithoutDetail,
387
- ...offer,
388
- itemOffered,
389
- seller: { project: project, typeOf: params.seller.typeOf, id: params.seller.id, name: params.seller.name }
390
- };
391
- }));
392
- };
393
- }
394
- function checkIfRegistered(params) {
395
- return async (repos) => {
396
- // メンバーシップについては、登録済かどうか確認する
397
- if (params.product.typeOf === factory_1.factory.product.ProductType.MembershipService) {
398
- // プロダクトによって発行されたPermitを所有していれば、登録済
399
- const searchOwnershipInfosResult = await repos.ownershipInfo.projectFields({
400
- limit: 1,
401
- page: 1,
402
- ownedBy: { id: params.agent.id },
403
- // プロダクトIDで検索
404
- typeOfGood: {
405
- issuedThrough: {
406
- id: { $eq: params.product.id },
407
- typeOf: { $eq: factory_1.factory.product.ProductType.MembershipService }
408
- }
409
- },
410
- ownedFrom: params.now,
411
- ownedThrough: params.now
412
- }, []);
413
- const ownershipInfos = searchOwnershipInfosResult;
414
- if (ownershipInfos.length > 0) {
415
- // Already registered
416
- throw new factory_1.factory.errors.Argument('object', exports.ERROR_MESSAGE_ALREADY_REGISTERED);
417
- }
418
- }
419
- };
420
- }
421
- function createServiceOutputIdentifier(params) {
422
- return async (repos) => {
423
- const publishParams = params.acceptedOffer.map(() => {
424
- return { project: { id: params.product.project.id } };
425
- });
426
- const publishIdentifierResult = await Promise.all(publishParams.map(async () => {
427
- const identifier = await repos.serviceOutputIdentifier.issueServiceOutputIdentifier({ startDate: new Date() });
428
- return { identifier };
429
- }));
430
- // 識別子を発行
431
- return Promise.all(params.acceptedOffer.map(async (o, key) => {
432
- return {
433
- ...o,
434
- itemOffered: {
435
- ...o.itemOffered,
436
- serviceOutput: {
437
- ...o.itemOffered?.serviceOutput,
438
- project: params.product.project,
439
- typeOf: factory_1.factory.permit.PermitType.Permit,
440
- identifier: publishIdentifierResult[key].identifier
441
- }
442
- }
443
- };
444
- }));
445
- };
446
- }
@@ -7,7 +7,7 @@ declare function isDeliverable(params: {
7
7
  id: string;
8
8
  };
9
9
  orderNumber: string;
10
- assetTransactionType: factory.assetTransactionType.Reserve | factory.assetTransactionType.MoneyTransfer | factory.assetTransactionType.RegisterService;
10
+ assetTransactionType: factory.assetTransactionType.Reserve;
11
11
  }): (repos: {
12
12
  acceptedOffer: AcceptedOfferRepo;
13
13
  assetTransaction: AssetTransactionRepo;
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ // import createDebug from 'debug';
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
6
4
  exports.isDeliverable = isDeliverable;
7
- const debug_1 = __importDefault(require("debug"));
8
5
  const factory_1 = require("../../../factory");
9
- const debug = (0, debug_1.default)('chevre-domain:service:order');
6
+ // const debug = createDebug('chevre-domain:service:order');
10
7
  function isDeliverable(params) {
11
8
  return async (repos) => {
12
9
  let allReserveTransactionConfirmed = false;
@@ -30,44 +27,52 @@ function isDeliverable(params) {
30
27
  else {
31
28
  allReserveTransactionConfirmed = true;
32
29
  }
33
- }
34
- else if (params.assetTransactionType === factory_1.factory.assetTransactionType.MoneyTransfer) {
35
- allReserveTransactionConfirmed = true;
36
- allRegisterServiceTransactionConfirmed = true;
37
- // 注文のMoneyTransferTransaction.transactionNumberを取得
38
- const moneyTransferTransactionNumbers = await repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.orderNumber] } }, 'acceptedOffers.serialNumber');
39
- if (moneyTransferTransactionNumbers.length > 0) {
40
- debug('is deliverable?...', params.orderNumber, 'moneyTransferTransactionNumbers:', moneyTransferTransactionNumbers);
41
- const referencedMoneyTransferTransactions = await repos.assetTransaction.search({
42
- project: { id: { $eq: params.project.id } },
43
- typeOf: factory_1.factory.assetTransactionType.MoneyTransfer,
44
- transactionNumber: { $in: moneyTransferTransactionNumbers }
45
- }, ['status']);
46
- allMoneyTransferTransactionConfirmed =
47
- referencedMoneyTransferTransactions.length === moneyTransferTransactionNumbers.length
48
- && referencedMoneyTransferTransactions.every(({ status }) => status === factory_1.factory.transactionStatusType.Confirmed);
49
- }
50
- else {
51
- allMoneyTransferTransactionConfirmed = true;
52
- }
53
- }
54
- else if (params.assetTransactionType === factory_1.factory.assetTransactionType.RegisterService) {
55
- allReserveTransactionConfirmed = true;
56
- allMoneyTransferTransactionConfirmed = true;
57
- const registerServiceTransactionNumbers = await repos.acceptedOffer.distinctValues({ orderNumber: { $in: [params.orderNumber] } }, 'acceptedOffers.serialNumber');
58
- if (registerServiceTransactionNumbers.length > 0) {
59
- const referencedRegisterServiceTransactions = await repos.assetTransaction.search({
60
- project: { id: { $eq: params.project.id } },
61
- typeOf: factory_1.factory.assetTransactionType.RegisterService,
62
- transactionNumber: { $in: registerServiceTransactionNumbers }
63
- }, ['status']);
64
- allRegisterServiceTransactionConfirmed =
65
- referencedRegisterServiceTransactions.length === registerServiceTransactionNumbers.length
66
- && referencedRegisterServiceTransactions.every(({ status }) => status === factory_1.factory.transactionStatusType.Confirmed);
67
- }
68
- else {
69
- allRegisterServiceTransactionConfirmed = true;
70
- }
30
+ // } else if (params.assetTransactionType === factory.assetTransactionType.MoneyTransfer) {
31
+ // allReserveTransactionConfirmed = true;
32
+ // allRegisterServiceTransactionConfirmed = true;
33
+ // // 注文のMoneyTransferTransaction.transactionNumberを取得
34
+ // const moneyTransferTransactionNumbers = await repos.acceptedOffer.distinctValues(
35
+ // { orderNumber: { $in: [params.orderNumber] } },
36
+ // 'acceptedOffers.serialNumber'
37
+ // );
38
+ // if (moneyTransferTransactionNumbers.length > 0) {
39
+ // debug('is deliverable?...', params.orderNumber, 'moneyTransferTransactionNumbers:', moneyTransferTransactionNumbers);
40
+ // const referencedMoneyTransferTransactions = await repos.assetTransaction.search(
41
+ // {
42
+ // project: { id: { $eq: params.project.id } },
43
+ // typeOf: factory.assetTransactionType.MoneyTransfer,
44
+ // transactionNumber: { $in: moneyTransferTransactionNumbers }
45
+ // },
46
+ // ['status']
47
+ // ) as Pick<factory.assetTransaction.moneyTransfer.ITransaction, 'status'>[];
48
+ // allMoneyTransferTransactionConfirmed =
49
+ // referencedMoneyTransferTransactions.length === moneyTransferTransactionNumbers.length
50
+ // && referencedMoneyTransferTransactions.every(({ status }) => status === factory.transactionStatusType.Confirmed);
51
+ // } else {
52
+ // allMoneyTransferTransactionConfirmed = true;
53
+ // }
54
+ // } else if (params.assetTransactionType === factory.assetTransactionType.RegisterService) {
55
+ // allReserveTransactionConfirmed = true;
56
+ // allMoneyTransferTransactionConfirmed = true;
57
+ // const registerServiceTransactionNumbers = await repos.acceptedOffer.distinctValues(
58
+ // { orderNumber: { $in: [params.orderNumber] } },
59
+ // 'acceptedOffers.serialNumber'
60
+ // );
61
+ // if (registerServiceTransactionNumbers.length > 0) {
62
+ // const referencedRegisterServiceTransactions = await repos.assetTransaction.search(
63
+ // {
64
+ // project: { id: { $eq: params.project.id } },
65
+ // typeOf: factory.assetTransactionType.RegisterService,
66
+ // transactionNumber: { $in: registerServiceTransactionNumbers }
67
+ // },
68
+ // ['status']
69
+ // ) as Pick<factory.assetTransaction.registerService.ITransaction, 'status'>[];
70
+ // allRegisterServiceTransactionConfirmed =
71
+ // referencedRegisterServiceTransactions.length === registerServiceTransactionNumbers.length
72
+ // && referencedRegisterServiceTransactions.every(({ status }) => status === factory.transactionStatusType.Confirmed);
73
+ // } else {
74
+ // allRegisterServiceTransactionConfirmed = true;
75
+ // }
71
76
  }
72
77
  return allReserveTransactionConfirmed && allMoneyTransferTransactionConfirmed && allRegisterServiceTransactionConfirmed;
73
78
  };
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processing2inTransit = exports.paymentDue2Processing = void 0;
4
4
  exports.onAssetTransactionStatusChanged = onAssetTransactionStatusChanged;
5
- const isDeliverable_1 = require("./onAssetTransactionStatusChanged/isDeliverable");
6
5
  const onPayTransactionCanceled_1 = require("./onAssetTransactionStatusChanged/onPayTransactionCanceled");
7
6
  const onPayTransactionConfirmed_1 = require("./onAssetTransactionStatusChanged/onPayTransactionConfirmed");
8
7
  const onReserveTransactionConfirmed_1 = require("./onAssetTransactionStatusChanged/onReserveTransactionConfirmed");
@@ -18,8 +17,8 @@ function onAssetTransactionStatusChanged(params) {
18
17
  }
19
18
  switch (params.object.status) {
20
19
  case factory_1.factory.transactionStatusType.Confirmed: {
21
- const orderNumber = params.purpose?.orderNumber;
22
- const confirmationNumber = params.purpose?.confirmationNumber;
20
+ // const orderNumber = params.purpose?.orderNumber;
21
+ // const confirmationNumber = params.purpose?.confirmationNumber;
23
22
  switch (params.object.typeOf) {
24
23
  case factory_1.factory.assetTransactionType.Pay:
25
24
  await (0, onPayTransactionConfirmed_1.onPayTransactionConfirmed)({
@@ -48,40 +47,42 @@ function onAssetTransactionStatusChanged(params) {
48
47
  }
49
48
  })(repos, settings);
50
49
  break;
51
- case factory_1.factory.assetTransactionType.MoneyTransfer:
52
- if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
53
- const deliverable = await (0, isDeliverable_1.isDeliverable)({
54
- project: { id: params.project.id },
55
- orderNumber,
56
- assetTransactionType: params.object.typeOf
57
- })(repos);
58
- if (deliverable) {
59
- await (0, processing2inTransit_1.processing2inTransit)({
60
- project: { id: params.project.id },
61
- // confirmationNumber,
62
- orderNumber,
63
- useOnOrderStatusChanged: params.useOnOrderStatusChanged
64
- })(repos, settings);
65
- }
66
- }
67
- break;
68
- case factory_1.factory.assetTransactionType.RegisterService:
69
- if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
70
- const deliverable = await (0, isDeliverable_1.isDeliverable)({
71
- project: { id: params.project.id },
72
- orderNumber,
73
- assetTransactionType: params.object.typeOf
74
- })(repos);
75
- if (deliverable) {
76
- await (0, processing2inTransit_1.processing2inTransit)({
77
- project: { id: params.project.id },
78
- // confirmationNumber,
79
- orderNumber,
80
- useOnOrderStatusChanged: params.useOnOrderStatusChanged
81
- })(repos, settings);
82
- }
83
- }
84
- break;
50
+ // discontinue(2026-04-18~)
51
+ // case factory.assetTransactionType.MoneyTransfer:
52
+ // if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
53
+ // const deliverable = await isDeliverable({
54
+ // project: { id: params.project.id },
55
+ // orderNumber,
56
+ // assetTransactionType: params.object.typeOf
57
+ // })(repos);
58
+ // if (deliverable) {
59
+ // await processing2inTransit({
60
+ // project: { id: params.project.id },
61
+ // // confirmationNumber,
62
+ // orderNumber,
63
+ // useOnOrderStatusChanged: params.useOnOrderStatusChanged
64
+ // })(repos, settings);
65
+ // }
66
+ // }
67
+ // break;
68
+ // discontinue(2026-04-19~)
69
+ // case factory.assetTransactionType.RegisterService:
70
+ // if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
71
+ // const deliverable = await isDeliverable({
72
+ // project: { id: params.project.id },
73
+ // orderNumber,
74
+ // assetTransactionType: params.object.typeOf
75
+ // })(repos);
76
+ // if (deliverable) {
77
+ // await processing2inTransit({
78
+ // project: { id: params.project.id },
79
+ // // confirmationNumber,
80
+ // orderNumber,
81
+ // useOnOrderStatusChanged: params.useOnOrderStatusChanged
82
+ // })(repos, settings);
83
+ // }
84
+ // }
85
+ // break;
85
86
  default:
86
87
  // no op
87
88
  }