@chevre/domain 21.12.0-alpha.0 → 21.12.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.
package/README.md CHANGED
@@ -11,14 +11,9 @@
11
11
  - [Chevre Domain Library for Node.js](#chevre-domain-library-for-nodejs)
12
12
  - [Table of contents](#table-of-contents)
13
13
  - [Usage](#usage)
14
- - [License](#license)
15
14
 
16
15
  ## Usage
17
16
 
18
17
  ```shell
19
18
  npm install @chevre/domain
20
19
  ```
21
-
22
- ## License
23
-
24
- ISC
@@ -342,14 +342,12 @@ function createReservations4transactionObject(params) {
342
342
  if (ticketType === undefined) {
343
343
  throw new factory.errors.NotFound(ticketOffer.typeOf);
344
344
  }
345
- if (settings_1.USE_ADVANCE_BOOKING_REQUIREMENT) {
346
- // 事前予約要件検証(2023-08-10~)
347
- validateAdvanceBookingRequirement({
348
- unitPriceOffer: ticketType,
349
- now: params.now,
350
- reservationFor: params.event
351
- });
352
- }
345
+ // 事前予約要件検証(2023-08-10~)
346
+ validateAdvanceBookingRequirement({
347
+ unitPriceOffer: ticketType,
348
+ now: params.now,
349
+ reservationFor: params.event
350
+ });
353
351
  const programMembershipUsed = yield validateProgramMembershipUsed({
354
352
  acceptedOffer,
355
353
  project: params.transaction.project
@@ -37,7 +37,6 @@ export type ISettings = factory.project.ISettings & {
37
37
  export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
38
38
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
39
39
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
40
- export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
41
40
  export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
42
41
  export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
43
42
  export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -63,7 +63,6 @@ exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTIO
63
63
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
64
64
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
65
65
  : moment('2023-08-31T15:00:00Z');
66
- exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
67
66
  exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
68
67
  exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
69
68
  exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@chevre/factory": "4.334.0",
13
- "@cinerino/sdk": "3.170.0",
13
+ "@cinerino/sdk": "3.172.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -24,7 +24,6 @@
24
24
  "jsonwebtoken": "9.0.0",
25
25
  "lodash.difference": "^4.5.0",
26
26
  "moment": "^2.29.1",
27
- "moment-range": "^4.0.2",
28
27
  "moment-timezone": "^0.5.33",
29
28
  "node-fpe": "1.0.0",
30
29
  "pug": "^2.0.4",
@@ -82,7 +81,6 @@
82
81
  "npm": ">=6.0.0"
83
82
  },
84
83
  "keywords": [],
85
- "license": "ISC",
86
84
  "main": "./lib/index.js",
87
85
  "types": "./lib/index.d.ts",
88
86
  "files": [
@@ -117,5 +115,5 @@
117
115
  "postversion": "git push origin --tags",
118
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
117
  },
120
- "version": "21.12.0-alpha.0"
118
+ "version": "21.12.0"
121
119
  }
@@ -1,31 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- import { findCreditCard } from '../../../../lib/chevre/service/transaction/orderProgramMembership/findCreditCard';
7
-
8
- const project = { id: String(process.env.PROJECT_ID) };
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const projectRepo = new chevre.repository.Project(mongoose.connection);
13
- const productRepo = new chevre.repository.Product(mongoose.connection);
14
- const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.settings.userPoolIdNew });
15
-
16
- const result = await findCreditCard({
17
- project: { id: project.id },
18
- customer: { id: 'a7909268-a584-425e-8212-d7d10f344093' },
19
- // iss: '',
20
- paymentMethodType: 'CreditCard'
21
- })({
22
- product: productRepo,
23
- person: personRepo,
24
- project: projectRepo
25
- });
26
- console.log(result);
27
- }
28
-
29
- main()
30
- .then(console.log)
31
- .catch(console.error);
@@ -1,23 +0,0 @@
1
- /**
2
- * findCreditCard
3
- */
4
- import * as GMO from '@motionpicture/gmo-service';
5
- import { CognitoRepository as PersonRepo } from '../../../repo/person';
6
- import { MongoRepository as ProductRepo } from '../../../repo/product';
7
- import { MongoRepository as ProjectRepo } from '../../../repo/project';
8
- /**
9
- * 所有クレジットカード検索
10
- */
11
- export declare function findCreditCard(params: {
12
- project: {
13
- id: string;
14
- };
15
- customer: {
16
- id: string;
17
- };
18
- paymentMethodType: string;
19
- }): (repos: {
20
- project: ProjectRepo;
21
- person: PersonRepo;
22
- product: ProductRepo;
23
- }) => Promise<GMO.factory.card.ISearchCardResult>;
@@ -1,136 +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.findCreditCard = void 0;
13
- /**
14
- * findCreditCard
15
- */
16
- const GMO = require("@motionpicture/gmo-service");
17
- const createDebug = require("debug");
18
- const creditCard_1 = require("../../../repo/paymentMethod/creditCard");
19
- const person_1 = require("../../../repo/person");
20
- const factory = require("../../../factory");
21
- const credentials_1 = require("../../../credentials");
22
- const settings_1 = require("../../../settings");
23
- const debug = createDebug('chevre-domain:orderProgramMembership');
24
- /**
25
- * 所有クレジットカード検索
26
- */
27
- function findCreditCard(params) {
28
- return (repos) => __awaiter(this, void 0, void 0, function* () {
29
- // 会員クレジットカード検索
30
- // const creditCards = await repos.creditCard.searchCreditCards({ id: params.customer.id, iss: params.iss });
31
- // // creditCards = creditCards.filter((c) => c.defaultFlag === '1');
32
- // const creditCard = creditCards.shift();
33
- // if (creditCard === undefined) {
34
- // throw new factory.errors.NotFound('CreditCard');
35
- // }
36
- var _a;
37
- const project = yield repos.project.findById({
38
- id: params.project.id,
39
- inclusion: ['settings'],
40
- exclusion: []
41
- });
42
- // const userPoolId: string = params.iss;
43
- // checkUseMyCreditCards(project);
44
- let memberId = params.customer.id;
45
- const useUsernameAsGMOMemberId = ((_a = project.settings) === null || _a === void 0 ? void 0 : _a.useUsernameAsGMOMemberId) === true;
46
- debug('useUsernameAsGMOMemberId:', useUsernameAsGMOMemberId);
47
- if (useUsernameAsGMOMemberId) {
48
- const person = yield repos.person.findById({ userId: params.customer.id });
49
- memberId = yield person2username(person);
50
- }
51
- const creditCardPaymentCredentials = yield getCreditCardPaymentServiceChannel({
52
- project: { id: params.project.id },
53
- paymentMethodType: params.paymentMethodType
54
- })(repos);
55
- const creditCardRepo = new creditCard_1.GMORepository({
56
- siteId: creditCardPaymentCredentials.siteId,
57
- sitePass: creditCardPaymentCredentials.sitePass,
58
- cardService: new GMO.service.Card({ endpoint: creditCardPaymentCredentials.endpoint }, { timeout: credentials_1.credentials.gmo.timeout })
59
- });
60
- const searchCardResults = yield creditCardRepo.search({ personId: memberId });
61
- const creditCard = searchCardResults.shift();
62
- if (creditCard === undefined) {
63
- throw new factory.errors.NotFound('CreditCard');
64
- }
65
- return creditCard;
66
- });
67
- }
68
- exports.findCreditCard = findCreditCard;
69
- const SSKTS_PROVIDER_NAME = 'SSKTS';
70
- function person2username(person) {
71
- var _a, _b, _c, _d;
72
- return __awaiter(this, void 0, void 0, function* () {
73
- let username = (_a = person.memberOf) === null || _a === void 0 ? void 0 : _a.membershipNumber;
74
- // ユーザープールが本家の場合とsskstの場合に対応
75
- // 本家にssktsをプロバイダーとしてログインしている場合、追加特性に以下のような値のidentitiesがあるはず
76
- // [{"userId":"xxxx","providerName":"SSKTS","providerType":"OIDC"}]
77
- const userIdentitiesStr = (_c = (_b = person.additionalProperty) === null || _b === void 0 ? void 0 : _b.find((p) => p.name === 'identities')) === null || _c === void 0 ? void 0 : _c.value;
78
- if (typeof userIdentitiesStr === 'string' && userIdentitiesStr.length > 0) {
79
- debug('userIdentitiesStr:', userIdentitiesStr);
80
- try {
81
- const identities = JSON.parse(userIdentitiesStr);
82
- if (Array.isArray(identities) && identities.length > 0) {
83
- const providerName = identities[0].providerName;
84
- const userIdByIdentities = identities[0].userId;
85
- if (providerName === SSKTS_PROVIDER_NAME) {
86
- if (typeof userIdByIdentities === 'string' && userIdByIdentities.length > 0) {
87
- const personRepo = new person_1.CognitoRepository({
88
- userPoolId: settings_1.settings.userPoolIdOld
89
- });
90
- // oldUserは必ず存在するはず
91
- const oldUser = yield personRepo.findById({ userId: userIdByIdentities });
92
- username = String((_d = oldUser.memberOf) === null || _d === void 0 ? void 0 : _d.membershipNumber);
93
- debug('oldUser found. username:', username);
94
- }
95
- }
96
- }
97
- }
98
- catch (error) {
99
- throw error;
100
- }
101
- }
102
- return username;
103
- });
104
- }
105
- function getCreditCardPaymentServiceChannel(params) {
106
- return (repos) => __awaiter(this, void 0, void 0, function* () {
107
- var _a, _b;
108
- const paymentServices = yield repos.product.search({
109
- limit: 1,
110
- project: { id: { $eq: params.project.id } },
111
- typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
112
- serviceType: { codeValue: { $eq: params.paymentMethodType } }
113
- }, [], []);
114
- const paymentServiceSetting = paymentServices.shift();
115
- if (paymentServiceSetting === undefined) {
116
- throw new factory.errors.NotFound('PaymentService');
117
- }
118
- // IDで検索いないとavailableChannelを取得できない
119
- const paymentService = yield repos.product.findById({ id: String(paymentServiceSetting.id) }, ['availableChannel'], []);
120
- const availableChannel = paymentService === null || paymentService === void 0 ? void 0 : paymentService.availableChannel;
121
- if (typeof (availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.serviceUrl) !== 'string') {
122
- throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
123
- }
124
- if (typeof ((_a = availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.siteId) !== 'string') {
125
- throw new factory.errors.NotFound('paymentService.availableChannel.credentials.siteId');
126
- }
127
- if (typeof ((_b = availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.sitePass) !== 'string') {
128
- throw new factory.errors.NotFound('paymentService.availableChannel.credentials.sitePass');
129
- }
130
- return {
131
- endpoint: availableChannel.serviceUrl,
132
- siteId: availableChannel.credentials.siteId,
133
- sitePass: availableChannel.credentials.sitePass
134
- };
135
- });
136
- }