@chevre/domain 20.11.0 → 20.11.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.
@@ -0,0 +1,77 @@
1
+ // tslint:disable:no-console no-magic-numbers
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ type IPermitOwnershipInfo = chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IPermitAsGood>;
7
+
8
+ const project = { id: <string>process.env.PROJECT_ID };
9
+
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
+
13
+ const now = new Date();
14
+
15
+ const ownershipInfoRepo = new chevre.repository.OwnershipInfo(mongoose.connection);
16
+ const newPersonRepo = new chevre.repository.Person({
17
+ userPoolId: <string>process.env.USERPOOL_ID_NEW
18
+ });
19
+ const oldPersonRepo = new chevre.repository.Person({
20
+ userPoolId: <string>process.env.USERPOOL_ID_OLD
21
+ });
22
+
23
+ const id = 'a7909268-a584-425e-8212-d7d10f344093';
24
+
25
+ const profile = await newPersonRepo.findById({
26
+ userId: id
27
+ });
28
+ console.log('profile found');
29
+
30
+ let oldUser;
31
+ const userIdentitiesStr = profile.additionalProperty?.find((p) => p.name === 'identities')?.value;
32
+ if (typeof userIdentitiesStr === 'string' && userIdentitiesStr.length > 0) {
33
+ try {
34
+ const identities = JSON.parse(userIdentitiesStr);
35
+ if (Array.isArray(identities) && identities.length > 0) {
36
+ const userIdByIdentities = identities[0].userId;
37
+ if (typeof userIdByIdentities === 'string' && userIdByIdentities.length > 0) {
38
+ // oldUserは必ず存在するはず
39
+ oldUser = await oldPersonRepo.findById({ userId: userIdByIdentities });
40
+ }
41
+ }
42
+ } catch (error) {
43
+ // tslint:disable-next-line:no-console
44
+ console.error('person2username throwed', error);
45
+ throw error;
46
+ }
47
+ }
48
+
49
+ const paymentCardOwnershipInfos = <IPermitOwnershipInfo[]>
50
+ await ownershipInfoRepo.search({
51
+ sort: { ownedFrom: chevre.factory.sortType.Ascending },
52
+ limit: 1,
53
+ page: 1,
54
+ project: { id: { $eq: project.id } },
55
+ ownedFrom: now,
56
+ ownedThrough: now,
57
+ ownedBy: { id },
58
+ typeOfGood: {
59
+ issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.PaymentCard } }
60
+ }
61
+ });
62
+ const paymentCardOwnershipInfo = paymentCardOwnershipInfos.shift();
63
+ console.log('paymentCard found');
64
+
65
+ console.log({
66
+ id,
67
+ // ...profile,
68
+ accountNumber: paymentCardOwnershipInfo?.typeOfGood.identifier,
69
+ ...oldUser
70
+ });
71
+ }
72
+
73
+ main()
74
+ .then(() => {
75
+ console.log('success!');
76
+ })
77
+ .catch(console.error);
@@ -120,7 +120,9 @@ function createTransactionObject(params) {
120
120
  transactionObject.push({
121
121
  typeOf: factory.offerType.Offer,
122
122
  id: String(offer.id),
123
- itemOffered: Object.assign({ project: params.product.project, typeOf: params.product.typeOf, id: String(params.product.id), serviceOutput: serviceOutput }, (pointAward !== undefined) ? { pointAward } : undefined)
123
+ itemOffered: Object.assign({
124
+ // project: params.product.project,
125
+ typeOf: params.product.typeOf, id: String(params.product.id), serviceOutput: serviceOutput }, (pointAward !== undefined) ? { pointAward } : undefined)
124
126
  });
125
127
  }
126
128
  return transactionObject;
@@ -143,7 +143,7 @@ function createPriceComponent(params) {
143
143
  priceCurrency: factory.priceCurrency.JPY,
144
144
  typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
145
145
  appliesToCategoryCode: [{
146
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
146
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
147
147
  typeOf: 'CategoryCode',
148
148
  codeValue: String(kbnJoueihousiki === null || kbnJoueihousiki === void 0 ? void 0 : kbnJoueihousiki.kubunCode),
149
149
  inCodeSet: {
@@ -170,7 +170,7 @@ function createPriceComponent(params) {
170
170
  priceCurrency: factory.priceCurrency.JPY,
171
171
  typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
172
172
  appliesToCategoryCode: [{
173
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
173
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
174
174
  typeOf: 'CategoryCode',
175
175
  codeValue: ticketInfo.spseatKbn,
176
176
  inCodeSet: {
@@ -353,7 +353,9 @@ function validateAcceptedOffers(params) {
353
353
  ? { description: offerWithoutDetail.itemOffered.pointAward.description }
354
354
  : undefined);
355
355
  }
356
- const itemOffered = Object.assign({ project: project, typeOf: params.product.typeOf, id: params.product.id, name: params.product.name, serviceOutput: Object.assign(Object.assign(Object.assign({}, (_j = params.product) === null || _j === void 0 ? void 0 : _j.serviceOutput), (_k = offerWithoutDetail.itemOffered) === null || _k === void 0 ? void 0 : _k.serviceOutput), { project: project,
356
+ const itemOffered = Object.assign({
357
+ // project: project,
358
+ typeOf: params.product.typeOf, id: params.product.id, name: params.product.name, serviceOutput: Object.assign(Object.assign(Object.assign({}, (_j = params.product) === null || _j === void 0 ? void 0 : _j.serviceOutput), (_k = offerWithoutDetail.itemOffered) === null || _k === void 0 ? void 0 : _k.serviceOutput), { project: project,
357
359
  // 発行者は販売者でいったん固定
358
360
  issuedBy: issuedBy, typeOf: factory.permit.PermitType.Permit }) }, (pointAward !== undefined) ? { pointAward } : undefined);
359
361
  return Object.assign(Object.assign(Object.assign({}, offerWithoutDetail), offer), { itemOffered, seller: { project: project, typeOf: params.seller.typeOf, id: params.seller.id, name: params.seller.name } });
@@ -206,7 +206,7 @@ function processAuthorizeProductOffer(params) {
206
206
  const transaction = params.transaction;
207
207
  const project = { typeOf: factory.organizationType.Project, id: params.project.id };
208
208
  const seller = {
209
- project: project,
209
+ // project: project,
210
210
  typeOf: transaction.seller.typeOf,
211
211
  id: transaction.seller.id,
212
212
  name: transaction.seller.name
@@ -263,11 +263,13 @@ function processAuthorizeProductOffer(params) {
263
263
  ? acceptedOffer.itemOffered.name
264
264
  : undefined;
265
265
  const object = [{
266
- project: project,
266
+ // project: project,
267
267
  typeOf: acceptedProductOffer.typeOf,
268
268
  id: acceptedProductOffer.id,
269
269
  priceCurrency: acceptedProductOffer.priceCurrency,
270
- itemOffered: Object.assign({ project: project, typeOf: factory.product.ProductType.MembershipService, id: params.product.id, serviceOutput: Object.assign({ project: project, typeOf: acceptedOffer.itemOffered.typeOf }, (typeof serviceOutputName === 'string') ? { name: serviceOutputName } : undefined) }, (pointAward !== undefined) ? { pointAward } : undefined),
270
+ itemOffered: Object.assign({
271
+ // project: project,
272
+ typeOf: factory.product.ProductType.MembershipService, id: params.product.id, serviceOutput: Object.assign({ project: project, typeOf: acceptedOffer.itemOffered.typeOf }, (typeof serviceOutputName === 'string') ? { name: serviceOutputName } : undefined) }, (pointAward !== undefined) ? { pointAward } : undefined),
271
273
  seller: seller
272
274
  }];
273
275
  // メンバーシップオファー承認
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.306.0",
13
- "@cinerino/sdk": "3.151.0-alpha.2",
12
+ "@chevre/factory": "4.307.0",
13
+ "@cinerino/sdk": "3.151.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.11.0"
123
+ "version": "20.11.1"
124
124
  }