@chevre/domain 23.1.0-alpha.0 → 23.1.0-alpha.1

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.
@@ -16,50 +16,13 @@ const factory = require("../../../../../factory");
16
16
  */
17
17
  function requestedProgramMembershipUsed2permit(params) {
18
18
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
19
- return (repos
20
- // credentials: {
21
- // jwt: JWTCredentials;
22
- // }
23
- ) => __awaiter(this, void 0, void 0, function* () {
24
- var _a, _b;
19
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
20
+ var _a, _b, _c, _d;
25
21
  let programMembershipUsedAsPermit;
26
22
  const { programMembershipUsed, placeOrder } = params;
27
23
  // discontinue token as fromLocation(ticketTokenへ移行するべき)(2024-12-18~)
28
24
  if (typeof programMembershipUsed === 'string') {
29
25
  throw new factory.errors.NotImplemented('programMembershipUsed as string not implemented');
30
- // トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
31
- // const { authorizedObject } = await CodeService.verifyToken({
32
- // project: { id: params.project.id },
33
- // agent: { id: params.project.id, typeOf: factory.organizationType.Project },
34
- // token: String(programMembershipUsed)
35
- // })(repos);
36
- // const permitOwnershipInfo = authorizedObject;
37
- // if (Array.isArray(permitOwnershipInfo)) {
38
- // throw new factory.errors.NotImplemented('programMembershipUsed as an array not implemented');
39
- // }
40
- // if (permitOwnershipInfo.typeOf !== 'OwnershipInfo') {
41
- // throw new factory.errors.Argument('programMembershipUsed', 'must be OwnershipInfo');
42
- // }
43
- // const typeOfGood = permitOwnershipInfo.typeOfGood;
44
- // if (typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
45
- // throw new factory.errors.Argument('programMembershipUsed', 'must be Permit');
46
- // }
47
- // const issuedThroughTypeOf = typeOfGood.issuedThrough?.typeOf;
48
- // if (issuedThroughTypeOf !== factory.product.ProductType.MembershipService) {
49
- // throw new factory.errors.Argument('programMembershipUsed', 'must be issued through MembershipService');
50
- // }
51
- // if (typeof typeOfGood.issuedThrough?.id !== 'string') {
52
- // throw new factory.errors.NotFound('itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
53
- // }
54
- // if (issuedThroughTypeOf === factory.product.ProductType.MembershipService) {
55
- // programMembershipUsedAsPermit = {
56
- // identifier: typeOfGood.identifier,
57
- // issuedThrough: { id: typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
58
- // typeOf: factory.permit.PermitType.Permit
59
- // };
60
- // } else {
61
- // throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
62
- // }
63
26
  }
64
27
  else if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) === 'Ticket') {
65
28
  const { ticketToken } = programMembershipUsed;
@@ -81,47 +44,54 @@ function requestedProgramMembershipUsed2permit(params) {
81
44
  if (object.typeOf !== 'OwnershipInfo') {
82
45
  throw new factory.errors.Argument('programMembershipUsed', 'invalid authorization');
83
46
  }
84
- // const ownershipInfoId = object.id;
85
- // const permitOwnershipInfo = (await repos.ownershipInfo.search({
86
- // limit: 1,
87
- // page: 1,
88
- // project: { id: { $eq: params.project.id } },
89
- // ids: [ownershipInfoId],
90
- // ownedFrom: now,
91
- // ownedThrough: now
92
- // })).shift();
93
- // if (permitOwnershipInfo === undefined) {
94
- // throw new factory.errors.NotFound('OwnershipInfo');
95
- // }
96
47
  // audience検証
97
48
  if ((audience === null || audience === void 0 ? void 0 : audience.typeOf) !== factory.transactionType.PlaceOrder || audience.id !== placeOrder.id) {
98
49
  throw new factory.errors.Argument('programMembershipUsed', 'audience not matched with placeOrder');
99
50
  }
100
51
  const permitOwnershipInfo = object;
101
- if (permitOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
102
- throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.typeOf must be Permit');
103
- }
104
- const issuedThroughTypeOf = (_a = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf;
105
- if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
106
- programMembershipUsedAsPermit = {
107
- identifier: permitOwnershipInfo.typeOfGood.identifier,
108
- issuedThrough: { typeOf: issuedThroughTypeOf },
109
- typeOf: factory.permit.PermitType.Permit
110
- };
52
+ const ownedGoodType = (_a = permitOwnershipInfo.typeOfGood) === null || _a === void 0 ? void 0 : _a.typeOf;
53
+ if (ownedGoodType === factory.permit.PermitType.Permit) {
54
+ const issuedThroughTypeOf = (_b = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.typeOf;
55
+ if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
56
+ programMembershipUsedAsPermit = {
57
+ identifier: permitOwnershipInfo.typeOfGood.identifier,
58
+ issuedThrough: { typeOf: issuedThroughTypeOf },
59
+ typeOf: factory.permit.PermitType.Permit
60
+ };
61
+ }
62
+ else if (issuedThroughTypeOf === factory.product.ProductType.MembershipService
63
+ || issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
64
+ if (typeof ((_c = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _c === void 0 ? void 0 : _c.id) !== 'string') {
65
+ throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.issuedThrough.id undefined');
66
+ }
67
+ programMembershipUsedAsPermit = {
68
+ identifier: permitOwnershipInfo.typeOfGood.identifier,
69
+ issuedThrough: { id: permitOwnershipInfo.typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
70
+ typeOf: factory.permit.PermitType.Permit
71
+ };
72
+ }
73
+ else {
74
+ throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
75
+ }
111
76
  }
112
- else if (issuedThroughTypeOf === factory.product.ProductType.MembershipService
113
- || issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
114
- if (typeof ((_b = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) !== 'string') {
115
- throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.issuedThrough.id undefined');
77
+ else if (ownedGoodType === factory.service.paymentService.PaymentServiceType.CreditCard) {
78
+ // CreditCard決済の場合、決済方法所有権を受け入れる(2025-11-11~)
79
+ const paymentServiceId = (_d = permitOwnershipInfo.typeOfGood) === null || _d === void 0 ? void 0 : _d.id;
80
+ const paymentMethodId = permitOwnershipInfo.typeOfGood.serviceOutput.paymentMethodId;
81
+ if (typeof paymentMethodId !== 'string' || paymentMethodId === '') {
82
+ throw new factory.errors.Argument('programMembershipUsed', 'paymentServiceId required');
83
+ }
84
+ if (typeof paymentMethodId !== 'string' || paymentMethodId === '') {
85
+ throw new factory.errors.Argument('programMembershipUsed', 'paymentMethodId required');
116
86
  }
117
87
  programMembershipUsedAsPermit = {
118
- identifier: permitOwnershipInfo.typeOfGood.identifier,
119
- issuedThrough: { id: permitOwnershipInfo.typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
88
+ identifier: paymentMethodId,
89
+ issuedThrough: { id: paymentServiceId, typeOf: ownedGoodType },
120
90
  typeOf: factory.permit.PermitType.Permit
121
91
  };
122
92
  }
123
93
  else {
124
- throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
94
+ throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.typeOf must be Permit');
125
95
  }
126
96
  }
127
97
  }
@@ -5,7 +5,6 @@ import type { TicketRepo } from '../../../../repo/ticket';
5
5
  import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
6
6
  import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
7
7
  import * as PayTransactionService from '../../../assetTransaction/pay';
8
- import { IPermitOrInvoice } from '../verifyTicketTokenAsNeeded';
9
8
  interface IFixTransactionNumberRepos {
10
9
  action: ActionRepo;
11
10
  authorization: AuthorizationRepo;
@@ -28,7 +27,7 @@ declare function fixTransactionNumber(params: {
28
27
  transactionNumber: string;
29
28
  pendingPaymentAgencyTransaction?: PayTransactionService.IPaymentAgencyTransaction;
30
29
  creditCard?: factory.action.authorize.paymentMethod.any.ICreditCard;
31
- permitOrInvoice?: IPermitOrInvoice;
30
+ permitOrInvoice?: never;
32
31
  id?: never;
33
32
  } | {
34
33
  /**
@@ -81,6 +81,8 @@ function fixTransactionNumber(params) {
81
81
  const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
82
82
  transactionNumber = publishTransactionNumberResult.transactionNumber;
83
83
  }
84
- return Object.assign(Object.assign(Object.assign({ transactionNumber }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined), (creditCard !== undefined) ? { creditCard } : undefined), (permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined);
84
+ return Object.assign(Object.assign({ transactionNumber }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined), (creditCard !== undefined) ? { creditCard } : undefined
85
+ // ...(permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined
86
+ );
85
87
  });
86
88
  }
@@ -34,7 +34,6 @@ export declare function createMovieTicket(params: factory.action.trade.pay.IMovi
34
34
  export declare function createAuthorizeResult(params: {
35
35
  object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
36
36
  payTransaction: Pick<factory.assetTransaction.pay.ITransaction, 'object'>;
37
- permit?: Pick<factory.ownershipInfo.IPermitAsGood, 'identifier'>;
38
37
  }): factory.action.authorize.paymentMethod.any.IResult;
39
38
  /**
40
39
  * 通知対象としてのアクションを最適化
@@ -45,24 +45,40 @@ function verifyTicketTokenAsNeeded(params) {
45
45
  }
46
46
  if (authorizedObject.typeOf === 'OwnershipInfo') {
47
47
  const { typeOfGood } = authorizedObject;
48
- if (((_b = typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.typeOf) !== paymentServiceType) {
49
- throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
48
+ if (typeOfGood.typeOf === factory.permit.PermitType.Permit || typeOfGood.typeOf === 'Invoice') {
49
+ if (((_b = typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.typeOf) !== paymentServiceType) {
50
+ throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
51
+ }
52
+ // FaceToFace以外の場合、発行サービスIDを検証
53
+ if (typeOfGood.issuedThrough.typeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
54
+ if (typeOfGood.issuedThrough.id !== issuedThrough.id) {
55
+ throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
56
+ }
57
+ }
58
+ if (typeOfGood.typeOf === factory.permit.PermitType.Permit) {
59
+ permitOrInvoice = { identifier: typeOfGood.identifier, typeOf: factory.permit.PermitType.Permit };
60
+ }
61
+ else if (typeOfGood.typeOf === 'Invoice') {
62
+ // support paymentServiceType.MovieTicket(2024-11-23~)
63
+ permitOrInvoice = { paymentMethodId: typeOfGood.paymentMethodId, typeOf: 'Invoice' };
64
+ }
65
+ else {
66
+ throw new factory.errors.Argument('ticketToken', 'must be Permit or Invoice');
67
+ }
50
68
  }
51
- // FaceToFace以外の場合、発行サービスIDを検証
52
- if (typeOfGood.issuedThrough.typeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
53
- if (typeOfGood.issuedThrough.id !== issuedThrough.id) {
69
+ else if (typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
70
+ || typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket) {
71
+ // 決済方法所有権を受け入れる(2025-11-11~)
72
+ if (typeOfGood.typeOf !== paymentServiceType) {
73
+ throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
74
+ }
75
+ if (typeOfGood.id !== issuedThrough.id) {
54
76
  throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
55
77
  }
56
- }
57
- if (typeOfGood.typeOf === factory.permit.PermitType.Permit) {
58
- permitOrInvoice = { identifier: typeOfGood.identifier, typeOf: factory.permit.PermitType.Permit };
59
- }
60
- else if (typeOfGood.typeOf === 'Invoice') {
61
- // support paymentServiceType.MovieTicket(2024-11-23~)
62
- permitOrInvoice = { paymentMethodId: typeOfGood.paymentMethodId, typeOf: 'Invoice' };
78
+ permitOrInvoice = { paymentMethodId: typeOfGood.serviceOutput.paymentMethodId, typeOf: 'Invoice' };
63
79
  }
64
80
  else {
65
- throw new factory.errors.Argument('ticketToken', 'must be Permit or Invoice');
81
+ throw new factory.errors.Argument('ticketToken', `invalid typeOfGood.typeOf ${typeOfGood.typeOf}`);
66
82
  }
67
83
  }
68
84
  else {
@@ -439,7 +439,7 @@ function authorize(params) {
439
439
  if (typeof fixTransactionNumberResult.id === 'string') {
440
440
  return { id: fixTransactionNumberResult.id };
441
441
  }
442
- const { transactionNumber, pendingPaymentAgencyTransaction, creditCard, permitOrInvoice } = fixTransactionNumberResult;
442
+ const { transactionNumber, pendingPaymentAgencyTransaction, creditCard } = fixTransactionNumberResult;
443
443
  // let transactionNumber: string | undefined;
444
444
  // let pendingPaymentAgencyTransaction: PayTransactionService.IPaymentAgencyTransaction | undefined;
445
445
  // let creditCard: factory.action.authorize.paymentMethod.any.ICreditCard | undefined = params.object.creditCard;
@@ -568,7 +568,11 @@ function authorize(params) {
568
568
  throw error;
569
569
  }
570
570
  }
571
- const result = (0, factory_1.createAuthorizeResult)(Object.assign({ payTransaction, object: authorizeObjectIncludingPaymentMethodDetails }, ((permitOrInvoice === null || permitOrInvoice === void 0 ? void 0 : permitOrInvoice.typeOf) === factory.permit.PermitType.Permit) ? { permit: permitOrInvoice } : undefined));
571
+ const result = (0, factory_1.createAuthorizeResult)({
572
+ payTransaction,
573
+ object: authorizeObjectIncludingPaymentMethodDetails
574
+ // ...(permitOrInvoice?.typeOf === factory.permit.PermitType.Permit) ? { permit: permitOrInvoice } : undefined
575
+ });
572
576
  yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
573
577
  return { id: action.id };
574
578
  });
package/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "5.2.0-alpha.5",
15
- "@cinerino/sdk": "12.7.0-alpha.1",
14
+ "@chevre/factory": "5.2.0-alpha.6",
15
+ "@cinerino/sdk": "12.7.0-alpha.3",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
18
18
  "@sendgrid/client": "8.1.4",
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "23.1.0-alpha.0"
118
+ "version": "23.1.0-alpha.1"
119
119
  }