@chevre/domain 22.13.0-alpha.12 → 22.13.0-alpha.13

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,28 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ mongoose.Model.on('index', (...args) => {
7
+ console.error('******** index event emitted. ********\n', args);
8
+ });
9
+
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
+
13
+ const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
14
+
15
+ const orders = await orderRepo.projectFields(
16
+ {
17
+ limit: 1,
18
+ page: 1
19
+ },
20
+ { inclusion: ['customer.id', 'customer.typeOf'] }
21
+ );
22
+ // tslint:disable-next-line:no-null-keyword
23
+ console.dir(orders, { depth: null });
24
+ }
25
+
26
+ main()
27
+ .then()
28
+ .catch(console.error);
@@ -1,7 +1,7 @@
1
1
  import type { Connection, FilterQuery } from 'mongoose';
2
2
  import * as factory from '../factory';
3
3
  type IOrderWithoutAcceptedOffers = factory.order.IOrder;
4
- type IKeyOfProjection = Extract<keyof IOrderWithoutAcceptedOffers, 'broker' | 'confirmationNumber' | 'customer' | 'dateReturned' | 'identifier' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'previousOrderStatus' | 'price' | 'priceCurrency' | 'project' | 'returner' | 'seller' | 'typeOf' | 'url'> | 'paymentMethods.accountId' | 'paymentMethods.name' | 'paymentMethods.paymentMethod' | 'paymentMethods.paymentMethodId' | 'paymentMethods.totalPaymentDue' | 'paymentMethods.additionalProperty' | 'paymentMethods.issuedThrough';
4
+ type IKeyOfProjection = Extract<keyof IOrderWithoutAcceptedOffers, 'broker' | 'confirmationNumber' | 'customer' | 'dateReturned' | 'identifier' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'previousOrderStatus' | 'price' | 'priceCurrency' | 'project' | 'returner' | 'seller' | 'typeOf' | 'url'> | 'paymentMethods.accountId' | 'paymentMethods.name' | 'paymentMethods.paymentMethod' | 'paymentMethods.paymentMethodId' | 'paymentMethods.totalPaymentDue' | 'paymentMethods.additionalProperty' | 'paymentMethods.issuedThrough' | 'customer.id' | 'customer.typeOf';
5
5
  export type IReturnedOrder = Pick<IOrderWithoutAcceptedOffers, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
6
6
  id: string;
7
7
  };
@@ -21,7 +21,8 @@ const AVAILABLE_PROJECT_FIELDS = [
21
21
  'broker', 'confirmationNumber', 'customer', 'dateReturned', 'identifier', 'name', 'orderDate', 'orderNumber', 'orderStatus', 'orderedItem',
22
22
  'paymentMethods', 'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf', 'url',
23
23
  'paymentMethods.accountId', 'paymentMethods.additionalProperty', 'paymentMethods.issuedThrough', 'paymentMethods.name', 'paymentMethods.paymentMethod',
24
- 'paymentMethods.paymentMethodId', 'paymentMethods.totalPaymentDue'
24
+ 'paymentMethods.paymentMethodId', 'paymentMethods.totalPaymentDue',
25
+ 'customer.id', 'customer.typeOf'
25
26
  ];
26
27
  /**
27
28
  * 注文リポジトリ
package/package.json CHANGED
@@ -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": "22.13.0-alpha.12"
118
+ "version": "22.13.0-alpha.13"
119
119
  }
@@ -1,48 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- mongoose.Model.on('index', (...args) => {
9
- console.error('******** index event emitted. ********\n', args);
10
- });
11
-
12
- async function main() {
13
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
14
-
15
- const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
16
-
17
- const acceptedOffers = await acceptedOfferRepo.searchAcceptedOffersByOrderNumber(
18
- {
19
- // tslint:disable-next-line:no-magic-numbers
20
- limit: 10,
21
- page: 1,
22
- project: { id: { $eq: project.id } },
23
- orderNumber: { $eq: 'CIN7-9247770-0699829' },
24
- acceptedOffers: {
25
- itemOffered: {
26
- typeOf: { $in: [chevre.factory.reservationType.EventReservation] },
27
- reservationFor: { id: { $in: ['blpw1ew8f'] } },
28
- reservedTicket: { ticketedSeat: { seatNumber: { $in: ['A-26', 'xxx'] } } }
29
- }
30
- }
31
- },
32
- ['itemOffered', 'priceSpecification']
33
- );
34
- // tslint:disable-next-line:no-null-keyword
35
- console.dir(acceptedOffers, { depth: 1 });
36
- const reservationIds = acceptedOffers.map((acceptedOffer) => {
37
- if (acceptedOffer.itemOffered.typeOf === chevre.factory.reservationType.EventReservation) {
38
- return acceptedOffer.itemOffered.id;
39
- } else {
40
- return '';
41
- }
42
- });
43
- console.log('reservationIds:', reservationIds);
44
- }
45
-
46
- main()
47
- .then()
48
- .catch(console.error);