@chevre/domain 21.22.0-alpha.1 → 21.22.0

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.
@@ -8,6 +8,8 @@ enum ROLE_NAME {
8
8
  Customer = 'customer',
9
9
  POS = 'pos'
10
10
  }
11
+ const CLIENT_ID = '5glmsqlnlmbri3bgruddoe78lb';
12
+ const CUSTOMER_TYPE = 'POS';
11
13
 
12
14
  // tslint:disable-next-line:max-func-body-length
13
15
  async function main() {
@@ -18,8 +20,8 @@ async function main() {
18
20
 
19
21
  const cursor = memberRepo.getCursor(
20
22
  {
21
- 'member.hasRole.roleName': { $in: [ROLE_NAME.Customer, ROLE_NAME.POS] }
22
- // 'member.id': { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' }
23
+ 'member.hasRole.roleName': { $in: [ROLE_NAME.Customer, ROLE_NAME.POS] },
24
+ 'member.id': { $eq: CLIENT_ID }
23
25
  },
24
26
  {
25
27
  // _id: 1,
@@ -37,7 +39,10 @@ async function main() {
37
39
  offeredBy: { id: { $eq: iamMember.project.id } },
38
40
  availableAtOrFrom: { id: { $eq: iamMember.member.id } }
39
41
  });
40
- const alreadyMigrated = existingOffers.length === 1;
42
+ const alreadyMigrated = existingOffers.length === 1
43
+ && Array.isArray(existingOffers[0].eligibleCustomerType)
44
+ && existingOffers[0].eligibleCustomerType.length === 1
45
+ && existingOffers[0].eligibleCustomerType[0].codeValue === CUSTOMER_TYPE;
41
46
 
42
47
  if (alreadyMigrated) {
43
48
  console.log(
@@ -46,8 +51,11 @@ async function main() {
46
51
  console.log(
47
52
  'updating project...',
48
53
  iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.name, i);
49
- await makesOfferRepo.create({
54
+ await makesOfferRepo.updateOne({
50
55
  availableAtOrFrom: { id: iamMember.member.id },
56
+ eligibleCustomerType: [{
57
+ codeValue: CUSTOMER_TYPE
58
+ }],
51
59
  offeredBy: { id: iamMember.project.id }
52
60
  });
53
61
  updateCount += 1;
@@ -15,11 +15,10 @@ async function main() {
15
15
  limit: 10,
16
16
  page: 1,
17
17
  subOfferCatalog: {
18
- id: '0001',
19
- isOfferCatalogItem: false
18
+ id: '0001'
19
+ // isOfferCatalogItem: false
20
20
  },
21
21
  excludeAppliesToMovieTicket: false,
22
- useIncludeInDataCatalog: true,
23
22
  unacceptedPaymentMethod: []
24
23
  });
25
24
  console.log(result);
@@ -28,7 +27,6 @@ async function main() {
28
27
  result = await (await chevre.service.offer.createService()).event.searchOfferAppliesToMovieTicket({
29
28
  event: { id: 'cllkq475p' },
30
29
  onlyValid: true,
31
- useIncludeInDataCatalog: true,
32
30
  limit: 100,
33
31
  page: 1
34
32
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
@@ -146,14 +146,12 @@ export declare class MongoRepository {
146
146
  * サブカタログID
147
147
  */
148
148
  id: string;
149
- isOfferCatalogItem: boolean;
150
149
  };
151
150
  availableAtOrFrom?: {
152
151
  id?: string;
153
152
  };
154
153
  unacceptedPaymentMethod?: string[];
155
154
  excludeAppliesToMovieTicket: boolean;
156
- useIncludeInDataCatalog: boolean;
157
155
  onlyValid?: boolean;
158
156
  limit?: number;
159
157
  page?: number;
@@ -622,17 +622,19 @@ class MongoRepository {
622
622
  searchAvaialbleAppliesToMovieTicketByOfferCatalogId(params) {
623
623
  var _a;
624
624
  return __awaiter(this, void 0, void 0, function* () {
625
- let sortedOfferIds = [];
626
- if (!params.useIncludeInDataCatalog) {
627
- // useIncludeInDataCatalogでない場合のみ集計オファーIDリストを検索する
628
- sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
629
- id: params.subOfferCatalog.id,
630
- isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
631
- });
632
- }
633
- const searchOffersConditions = Object.assign(Object.assign(Object.assign({}, (params.useIncludeInDataCatalog)
634
- ? { includedInDataCatalog: { id: { $in: [params.subOfferCatalog.id] } } }
635
- : { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
625
+ // let sortedOfferIds: string[] = [];
626
+ // if (!params.useIncludeInDataCatalog) {
627
+ // // useIncludeInDataCatalogでない場合のみ集計オファーIDリストを検索する
628
+ // sortedOfferIds = await this.searchAggregateOfferIdsBySubOfferCatalog({
629
+ // id: params.subOfferCatalog.id,
630
+ // isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
631
+ // });
632
+ // }
633
+ const searchOffersConditions = Object.assign(Object.assign({
634
+ // ...(params.useIncludeInDataCatalog)
635
+ // ? { includedInDataCatalog: { id: { $in: [params.subOfferCatalog.id] } } }
636
+ // : { parentOffer: { id: { $in: sortedOfferIds } } },
637
+ includedInDataCatalog: { id: { $in: [params.subOfferCatalog.id] } } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
636
638
  ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
637
639
  : undefined), { priceSpecification: {
638
640
  appliesToMovieTicket: Object.assign({
@@ -76,7 +76,6 @@ declare function searchOfferAppliesToMovieTicket(params: {
76
76
  * 有効なオファーのみ対象とするか
77
77
  */
78
78
  onlyValid?: boolean;
79
- useIncludeInDataCatalog: boolean;
80
79
  }): (repos: {
81
80
  event: EventRepo;
82
81
  offer: OfferRepo;
@@ -397,19 +397,20 @@ function searchOfferAppliesToMovieTicket(params) {
397
397
  }
398
398
  // サブカタログIDを決定
399
399
  let subOfferCatalogId = catalogId;
400
- let isOfferCatalogItem = false;
400
+ // let isOfferCatalogItem: boolean = false;
401
401
  const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
402
402
  if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
403
403
  subOfferCatalogId = offerCatalogFirstElement.id;
404
- isOfferCatalogItem = true;
404
+ // isOfferCatalogItem = true;
405
405
  }
406
406
  return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
407
- subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
407
+ // subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
408
+ subOfferCatalog: { id: subOfferCatalogId },
408
409
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
409
410
  unacceptedPaymentMethod: unacceptedPaymentMethod,
410
411
  excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
411
412
  onlyValid: params.onlyValid === true,
412
- useIncludeInDataCatalog: params.useIncludeInDataCatalog,
413
+ // useIncludeInDataCatalog: params.useIncludeInDataCatalog,
413
414
  limit: params.limit,
414
415
  page: params.page
415
416
  });
@@ -78,7 +78,7 @@ function confirm(params) {
78
78
  expiresInSeconds: publishCodeExpiresInSeconds
79
79
  })(repos);
80
80
  }
81
- const { orderWithAcceptedOffers, result, eventId, reservationIds } = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions, code }));
81
+ const { result, eventId, reservationIds } = createResult(Object.assign(Object.assign({}, params), { orderNumber, transaction: transaction, authorizeActions: completedAuthorizeActions, code }));
82
82
  // デフォルトEメールメッセージを検索
83
83
  let emailMessageOnOrderSent;
84
84
  if (repos.emailMessage !== undefined) {
@@ -92,8 +92,8 @@ function confirm(params) {
92
92
  }
93
93
  // ポストアクションを作成
94
94
  const potentialActions = yield (0, potentialActions_1.createPotentialActions)({
95
- // order: result.order,
96
- order: orderWithAcceptedOffers,
95
+ order: result.order,
96
+ // order: orderWithAcceptedOffers, // 現時点でcreateEmailMessageでorder.acceptedOffersを使用している(2024-02-06~)
97
97
  potentialActions: params.potentialActions,
98
98
  transaction: transaction,
99
99
  emailMessage: emailMessageOnOrderSent,
@@ -158,9 +158,6 @@ function createResult(params) {
158
158
  orderNumber: params.orderNumber,
159
159
  transaction: transaction,
160
160
  orderDate: params.result.order.orderDate,
161
- // OrderPaymentDueオプションを追加(2023-08-25~)
162
- // 注文作成時のステータスとなる
163
- // orderStatus: (USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
164
161
  orderStatus: factory.orderStatus.OrderPaymentDue,
165
162
  isGift: false,
166
163
  authorizeActions: params.authorizeActions
@@ -191,13 +188,8 @@ function createResult(params) {
191
188
  order.identifier = identifier;
192
189
  order.url = url;
193
190
  const authorizeActions = params.authorizeActions.map(({ id }) => ({ id }));
194
- let orderAsResult;
195
- // if (USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT) {
196
- // orderAsResult = order;
197
- // } else {
198
- // }
199
191
  const { acceptedOffers } = order, orderWithoutAcceptedOffers = __rest(order, ["acceptedOffers"]);
200
- orderAsResult = orderWithoutAcceptedOffers;
192
+ const orderAsResult = orderWithoutAcceptedOffers;
201
193
  let eventId;
202
194
  let reservationIds;
203
195
  if (params.options.expectsReservationIds) {
@@ -11,17 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createPotentialActions = void 0;
13
13
  const givePointAward_1 = require("./potentialActions/givePointAward");
14
- // import { createMoneyTransferActions } from './potentialActions/moneyTransfer';
15
- // import { createRegisterServiceActions } from './potentialActions/registerService';
16
14
  const sendEmailMessage_1 = require("./potentialActions/sendEmailMessage");
17
15
  /**
18
16
  * 取引のポストアクションを作成する
19
17
  */
20
18
  function createPotentialActions(params) {
21
19
  return __awaiter(this, void 0, void 0, function* () {
22
- // const registerServiceActions = await createRegisterServiceActions(params);
23
- // 通貨転送アクション
24
- // const moneyTransferActions = await createMoneyTransferActions(params);
25
20
  // ポイントインセンティブに対する承認アクションの分だけ、ポイントインセンティブ付与アクションを作成する
26
21
  const givePointAwardActions = yield (0, givePointAward_1.createGivePointAwardActions)(params);
27
22
  // 注文配送メール送信設定
@@ -35,20 +30,6 @@ function createPotentialActions(params) {
35
30
  };
36
31
  // optimize(2024-01-22~)
37
32
  return {
38
- // order: {
39
- // project: params.transaction.project,
40
- // typeOf: factory.actionType.OrderAction,
41
- // object: simpleOrder,
42
- // agent: params.transaction.project,
43
- // potentialActions: {
44
- // givePointAward: givePointAwardActions,
45
- // sendOrder: sendOrderActionAttributes // optimize(2024-01-16~)
46
- // },
47
- // purpose: {
48
- // typeOf: params.transaction.typeOf,
49
- // id: params.transaction.id
50
- // }
51
- // }
52
33
  order: {
53
34
  potentialActions: {
54
35
  givePointAward: givePointAwardActions,
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.22.0-alpha.1"
113
+ "version": "21.22.0"
114
114
  }
@@ -1,7 +0,0 @@
1
- import * as factory from '../../../../factory';
2
- export type IAuthorizeMoneyTransferOffer = factory.action.authorize.offer.moneyTransfer.IAction;
3
- export declare function createMoneyTransferActions(params: {
4
- order: factory.order.IOrder;
5
- transaction: factory.transaction.placeOrder.ITransaction;
6
- authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
7
- }): Promise<factory.action.interact.confirm.moneyTransfer.IAttributes[]>;
@@ -1,57 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createMoneyTransferActions = void 0;
13
- const factory = require("../../../../factory");
14
- const order_1 = require("../../../../factory/order");
15
- function createMoneyTransferActions(params) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const moneyTransferActions = [];
18
- const authorizeMoneyTransferActions = params.authorizeActions
19
- .filter((a) => a.object.typeOf === factory.offerType.Offer)
20
- .filter((a) => { var _a; return ((_a = a.object.itemOffered) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.actionType.MoneyTransfer; });
21
- const moneyTransferPurpose = {
22
- typeOf: params.order.typeOf,
23
- seller: {
24
- id: params.order.seller.id,
25
- typeOf: params.order.seller.typeOf,
26
- name: params.order.seller.name
27
- },
28
- // mask
29
- customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
30
- orderNumber: params.order.orderNumber,
31
- price: params.order.price,
32
- priceCurrency: params.order.priceCurrency,
33
- orderDate: params.order.orderDate
34
- };
35
- // const paymentMethod = params.order.paymentMethods[0];
36
- authorizeMoneyTransferActions.forEach((a) => {
37
- var _a;
38
- const actionResult = a.result;
39
- if (actionResult !== undefined) {
40
- const pendingTransaction = (_a = a.object.itemOffered.object) === null || _a === void 0 ? void 0 : _a.pendingTransaction;
41
- moneyTransferActions.push({
42
- project: params.transaction.project,
43
- typeOf: factory.actionType.ConfirmAction,
44
- object: {
45
- // pendingTransaction: { id: actionResult.responseBody.id },
46
- transactionNumber: pendingTransaction.transactionNumber,
47
- typeOf: factory.assetTransactionType.MoneyTransfer
48
- },
49
- agent: params.transaction.project,
50
- purpose: moneyTransferPurpose
51
- });
52
- }
53
- });
54
- return moneyTransferActions;
55
- });
56
- }
57
- exports.createMoneyTransferActions = createMoneyTransferActions;
@@ -1,6 +0,0 @@
1
- import * as factory from '../../../../factory';
2
- export declare function createRegisterServiceActions(params: {
3
- order: factory.order.IOrder;
4
- transaction: factory.transaction.placeOrder.ITransaction;
5
- authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
6
- }): Promise<factory.action.interact.confirm.registerService.IAttributes[]>;
@@ -1,78 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createRegisterServiceActions = void 0;
13
- const factory = require("../../../../factory");
14
- const availableProductTypes_1 = require("../../../../factory/availableProductTypes");
15
- const order_1 = require("../../../../factory/order");
16
- function createRegisterServiceActions(params) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const registerServiceActions = [];
19
- const authorizeProductOfferActions = params.authorizeActions
20
- .filter((a) => Array.isArray(a.object)
21
- && a.object.length > 0
22
- && a.object[0].typeOf === factory.offerType.Offer
23
- && availableProductTypes_1.availableProductTypes.indexOf(a.object[0].itemOffered.typeOf) >= 0);
24
- const registerServicePurpose = {
25
- typeOf: params.order.typeOf,
26
- seller: {
27
- id: params.order.seller.id,
28
- typeOf: params.order.seller.typeOf,
29
- name: params.order.seller.name
30
- },
31
- // mask
32
- customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
33
- orderNumber: params.order.orderNumber,
34
- price: params.order.price,
35
- priceCurrency: params.order.priceCurrency,
36
- orderDate: params.order.orderDate
37
- };
38
- authorizeProductOfferActions.forEach((a) => {
39
- var _a;
40
- const actionResult = a.result;
41
- if (actionResult !== undefined) {
42
- const registerServiceObject = createRegisterServiceActionObject({
43
- order: params.order,
44
- // potentialActions: params.potentialActions,
45
- transaction: params.transaction,
46
- transactionNumber: (_a = a.instrument) === null || _a === void 0 ? void 0 : _a.transactionNumber
47
- });
48
- // 廃止(2023-08-18~)
49
- // const orderProgramMembershipTask = createOrderProgramMembershipTask({
50
- // order: params.order,
51
- // authorizeAction: a
52
- // });
53
- registerServiceActions.push({
54
- project: params.transaction.project,
55
- typeOf: factory.actionType.ConfirmAction,
56
- object: registerServiceObject,
57
- agent: params.transaction.project,
58
- purpose: registerServicePurpose,
59
- potentialActions: {
60
- // ...(orderProgramMembershipTask !== undefined)
61
- // ? { orderProgramMembership: [orderProgramMembershipTask] }
62
- // : undefined
63
- }
64
- });
65
- }
66
- });
67
- return registerServiceActions;
68
- });
69
- }
70
- exports.createRegisterServiceActions = createRegisterServiceActions;
71
- function createRegisterServiceActionObject(params) {
72
- return {
73
- transactionNumber: params.transactionNumber,
74
- endDate: params.order.orderDate,
75
- // object: {},
76
- typeOf: factory.assetTransactionType.RegisterService
77
- };
78
- }