@chevre/domain 21.8.0-alpha.6 → 21.8.0-alpha.60

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 (129) hide show
  1. package/example/src/chevre/countOffers.ts +32 -0
  2. package/example/src/chevre/findItemListElementByCatalogId.ts +23 -0
  3. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  4. package/example/src/chevre/migrateAggregateOffers.ts +89 -0
  5. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  7. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  8. package/example/src/chevre/processPay.ts +3 -4
  9. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  10. package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
  11. package/example/src/chevre/searchAggregateOffers.ts +48 -0
  12. package/example/src/chevre/searchEventTicketOffers.ts +3 -1
  13. package/example/src/chevre/searchEvents.ts +9 -7
  14. package/example/src/chevre/searchOffersByCatalog.ts +9 -5
  15. package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
  16. package/example/src/chevre/searchOrders.ts +9 -7
  17. package/example/src/chevre/sync2aggregateOffer.ts +27 -0
  18. package/example/src/chevre/syncAggregateOffer.ts +25 -0
  19. package/lib/chevre/emailMessageBuilder.js +6 -5
  20. package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
  21. package/lib/chevre/repo/aggregateOffer.js +534 -0
  22. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  23. package/lib/chevre/repo/assetTransaction.js +54 -2
  24. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
  25. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +177 -0
  26. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
  27. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
  28. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  29. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +24 -33
  30. package/lib/chevre/repo/mongoose/schemas/offer.js +4 -3
  31. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  32. package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
  33. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
  34. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  35. package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
  36. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  37. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  38. package/lib/chevre/repo/offer.d.ts +82 -47
  39. package/lib/chevre/repo/offer.js +1279 -289
  40. package/lib/chevre/repo/offerCatalog.d.ts +6 -0
  41. package/lib/chevre/repo/offerCatalog.js +13 -0
  42. package/lib/chevre/repo/order.d.ts +15 -0
  43. package/lib/chevre/repo/order.js +58 -26
  44. package/lib/chevre/repo/task.d.ts +7 -1
  45. package/lib/chevre/repo/task.js +100 -0
  46. package/lib/chevre/repository.d.ts +3 -0
  47. package/lib/chevre/repository.js +5 -1
  48. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
  49. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -1
  50. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  51. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  52. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  53. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  54. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  55. package/lib/chevre/service/assetTransaction/registerService.js +2 -1
  56. package/lib/chevre/service/assetTransaction/reserve.js +111 -35
  57. package/lib/chevre/service/delivery.js +17 -0
  58. package/lib/chevre/service/offer/event/authorize.js +39 -35
  59. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  60. package/lib/chevre/service/offer/event/factory.js +8 -8
  61. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  62. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -0
  63. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -3
  64. package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
  65. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  66. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
  67. package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
  68. package/lib/chevre/service/offer/factory.d.ts +12 -4
  69. package/lib/chevre/service/offer/factory.js +9 -11
  70. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +8 -1
  71. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -3
  72. package/lib/chevre/service/offer/product.d.ts +1 -0
  73. package/lib/chevre/service/offer/product.js +3 -2
  74. package/lib/chevre/service/offer.d.ts +1 -0
  75. package/lib/chevre/service/offer.js +7 -1
  76. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  77. package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
  78. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  80. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  81. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  82. package/lib/chevre/service/order/onOrderStatusChanged.js +81 -54
  83. package/lib/chevre/service/order/payOrder.d.ts +2 -10
  84. package/lib/chevre/service/order/payOrder.js +4 -45
  85. package/lib/chevre/service/order/placeOrder.js +11 -13
  86. package/lib/chevre/service/order.d.ts +3 -1
  87. package/lib/chevre/service/order.js +6 -2
  88. package/lib/chevre/service/payment/any/factory.js +33 -8
  89. package/lib/chevre/service/payment/any.js +30 -21
  90. package/lib/chevre/service/payment/creditCard.js +12 -12
  91. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  92. package/lib/chevre/service/payment/movieTicket.js +10 -11
  93. package/lib/chevre/service/payment/paymentCard.js +9 -12
  94. package/lib/chevre/service/project.js +1 -1
  95. package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
  96. package/lib/chevre/service/reserve/checkInReservation.js +3 -2
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
  99. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
  100. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
  101. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  102. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  103. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
  104. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  105. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  106. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  107. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  108. package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
  109. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
  110. package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
  111. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  112. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
  113. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
  114. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +60 -0
  115. package/lib/chevre/service/task/onResourceUpdated.js +12 -0
  116. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  117. package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
  118. package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
  119. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  120. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  121. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  122. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  123. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  124. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  125. package/lib/chevre/settings.d.ts +5 -3
  126. package/lib/chevre/settings.js +6 -6
  127. package/package.json +3 -3
  128. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  129. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
@@ -0,0 +1,168 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+
12
+ const offers = await offerRepo.search(
13
+ {
14
+ limit: 10,
15
+ page: 1,
16
+ sort: {
17
+ 'priceSpecification.price': 1,
18
+ identifier: 1
19
+ },
20
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
21
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
22
+ itemOffered: {
23
+ typeOf: {
24
+ // $eq: chevre.factory.product.ProductType.EventService
25
+ }
26
+ },
27
+ addOn: {
28
+ itemOffered: {
29
+ /**
30
+ * アドオンプロダクトID
31
+ */
32
+ id: {
33
+ // $eq: ''
34
+ }
35
+ }
36
+ },
37
+ availableAtOrFrom: {
38
+ id: {
39
+ // $eq: ''
40
+ // $in: string[]
41
+ }
42
+ },
43
+ eligibleMembershipType: {
44
+ /**
45
+ * 適用メンバーシップ区分
46
+ */
47
+ codeValue: {
48
+ // $eq: 'Permit'
49
+ }
50
+ },
51
+ eligibleMonetaryAmount: {
52
+ /**
53
+ * 適用通貨区分
54
+ */
55
+ currency: {
56
+ // $eq: 'Point'
57
+ }
58
+ },
59
+ eligibleSeatingType: {
60
+ /**
61
+ * 適用座席区分
62
+ */
63
+ codeValue: {
64
+ // $eq: ''
65
+ }
66
+ },
67
+ hasMerchantReturnPolicy: {
68
+ id: {
69
+ // $eq: ''
70
+ }
71
+ },
72
+ // parentOffer: { id: { $in: ['901'] } },
73
+ id: {
74
+ // $eq: '901'
75
+ // $in: string[];
76
+ },
77
+ identifier: {
78
+ // $eq: '1001'
79
+ // $in: string[];
80
+ // $regex: '003'
81
+ },
82
+ name: {
83
+ // $regex: ''
84
+ },
85
+ priceSpecification: {
86
+ appliesToMovieTicket: {
87
+ /**
88
+ * 適用決済カード区分
89
+ */
90
+ serviceType: {
91
+ /**
92
+ * 適用決済カード区分が存在するかどうか
93
+ */
94
+ // $exists: boolean;
95
+ // $eq: '01'
96
+ },
97
+ serviceOutput: {
98
+ /**
99
+ * 適用決済方法タイプ
100
+ */
101
+ typeOf: {
102
+ // $eq: ''
103
+ // $nin: string[];
104
+ }
105
+ }
106
+ },
107
+ price: {
108
+ // $gte: 2000,
109
+ // $lte: 2000
110
+ },
111
+ referenceQuantity: {
112
+ value: {
113
+ // $eq: 2
114
+ }
115
+ },
116
+ accounting: {
117
+ accountsReceivable: {
118
+ // $gte: 1800,
119
+ // $lte: 100
120
+ },
121
+ operatingRevenue: {
122
+ codeValue: {
123
+ // $eq: ''
124
+ // $in: string[];
125
+ }
126
+ }
127
+ }
128
+ },
129
+ category: {
130
+ codeValue: {
131
+ // $in: ['1']
132
+ }
133
+ }
134
+ /**
135
+ * 有効期間設定がない、あるいは、有効期間内
136
+ */
137
+ // onlyValid: true
138
+ // additionalProperty: {
139
+ // $all: [
140
+ // {
141
+ // $elemMatch: {
142
+ // name: { $eq: 'nameForPrinting' },
143
+ // value: { $in: ['General'] }
144
+ // }
145
+ // }
146
+ // ]
147
+ // }
148
+ },
149
+ {
150
+ id: 1,
151
+ identifier: 1,
152
+ name: 1,
153
+ alternateName: 1,
154
+ priceSpecification: 1,
155
+ project: 1
156
+ }
157
+ );
158
+ console.log(offers);
159
+ console.log(offers.map((offer) => {
160
+ return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id}`;
161
+ }));
162
+ console.log(offers.length);
163
+ console.log('USE_AGGREGATE_OFFERS_AS_PRIMARY:', process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY);
164
+ }
165
+
166
+ main()
167
+ .then(console.log)
168
+ .catch(console.error);
@@ -6,11 +6,12 @@ import { chevre } from '../../../lib/index';
6
6
  const project = { id: String(process.env.PROJECT_ID) };
7
7
 
8
8
  async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
10
10
 
11
11
  const orderRepo = new chevre.repository.Order(mongoose.connection);
12
12
 
13
13
  const orders = await orderRepo.search({
14
+ limit: 10,
14
15
  project: { id: { $eq: project.id } },
15
16
  // acceptedOffers: {
16
17
  // itemOffered: {
@@ -18,12 +19,13 @@ async function main() {
18
19
  // }
19
20
  // },
20
21
  paymentMethods: {
21
- additionalProperty: {
22
- $in: [
23
- { name: 'orderId', value: '0102022031518442020' },
24
- { name: 'orderId', value: '0102022031518423030' }
25
- ]
26
- }
22
+ paymentMethod: { identifier: { $in: ['Cash'] } }
23
+ // additionalProperty: {
24
+ // $in: [
25
+ // { name: 'orderId', value: '0102022031518442020' },
26
+ // { name: 'orderId', value: '0102022031518423030' }
27
+ // ]
28
+ // }
27
29
  }
28
30
  });
29
31
  console.log('orders found', orders);
@@ -0,0 +1,27 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+
12
+ const result = await offerRepo.sync2aggregateOffer({
13
+ id: {
14
+ $in: ['1001']
15
+ },
16
+ project: {
17
+ id: String(process.env.PROJECT_ID)
18
+ },
19
+ isDeleted: false,
20
+ typeOf: chevre.factory.offerType.AggregateOffer
21
+ });
22
+ console.log(result);
23
+ }
24
+
25
+ main()
26
+ .then(console.log)
27
+ .catch(console.error);
@@ -0,0 +1,25 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
13
+
14
+ const result = await offerRepo.sync2aggregateOffer({
15
+ project: { id: project.id },
16
+ identifier: { $in: ['COA-120-15'] },
17
+ isDeleted: false,
18
+ typeOf: chevre.factory.offerType.Offer
19
+ });
20
+ console.log(result);
21
+ }
22
+
23
+ main()
24
+ .then(console.log)
25
+ .catch(console.error);
@@ -107,7 +107,7 @@ function createEmailMessageAbout(params) {
107
107
  });
108
108
  }
109
109
  function createEmailMessageSender(params) {
110
- var _a, _b, _c, _d;
110
+ var _a, _b;
111
111
  return {
112
112
  typeOf: params.order.seller.typeOf,
113
113
  name: (typeof ((_b = (_a = params.email) === null || _a === void 0 ? void 0 : _a.sender) === null || _b === void 0 ? void 0 : _b.name) === 'string')
@@ -115,10 +115,11 @@ function createEmailMessageSender(params) {
115
115
  : (typeof params.order.seller.name === 'string')
116
116
  ? params.order.seller.name
117
117
  : String(params.order.seller.id),
118
- // sender.email指定を非推奨化(2023-08-23~)
119
- email: (settings_1.USE_CUSTOM_SENDER_EMAIL && typeof ((_d = (_c = params.email) === null || _c === void 0 ? void 0 : _c.sender) === null || _d === void 0 ? void 0 : _d.email) === 'string')
120
- ? params.email.sender.email
121
- : settings_1.DEFAULT_SENDER_EMAIL
118
+ // sender.email指定を廃止(2023-09-07~)
119
+ // email: (USE_CUSTOM_SENDER_EMAIL && typeof params.email?.sender?.email === 'string')
120
+ // ? params.email.sender.email
121
+ // : DEFAULT_SENDER_EMAIL
122
+ email: settings_1.DEFAULT_SENDER_EMAIL
122
123
  };
123
124
  }
124
125
  /**
@@ -0,0 +1,62 @@
1
+ import { AnyExpression, Connection, PipelineStage } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ type IMatchStage = PipelineStage.Match;
4
+ type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
5
+ type IProjection = {
6
+ [key in KeyOfUnitPriceOffer]?: 0 | 1;
7
+ };
8
+ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPriceOffer & {
9
+ offerIndex?: number;
10
+ parentOffer?: {
11
+ id: string;
12
+ };
13
+ };
14
+ /**
15
+ * 集計オファーリポジトリ
16
+ */
17
+ export declare class MongoRepository {
18
+ private readonly aggregateOfferModel;
19
+ constructor(connection: Connection);
20
+ static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
21
+ static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
22
+ [field: string]: AnyExpression;
23
+ };
24
+ count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
25
+ search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
26
+ pushIncludedInDataCatalog(params: {
27
+ project: {
28
+ id: string;
29
+ };
30
+ id: {
31
+ $in: string[];
32
+ };
33
+ $push: {
34
+ includedInDataCatalog: {
35
+ $each: {
36
+ id: string;
37
+ }[];
38
+ };
39
+ };
40
+ }): Promise<void>;
41
+ /**
42
+ * 含まれるカタログからカタログを除外する
43
+ */
44
+ pullIncludedInDataCatalog(params: {
45
+ project: {
46
+ id: string;
47
+ };
48
+ id?: {
49
+ $nin?: string[];
50
+ };
51
+ $pull: {
52
+ includedInDataCatalog: {
53
+ $elemMatch: {
54
+ id: {
55
+ $eq: string;
56
+ };
57
+ };
58
+ };
59
+ };
60
+ }): Promise<import("mongodb").UpdateResult>;
61
+ }
62
+ export {};