@chevre/domain 23.0.0-alpha.15 → 23.0.0-alpha.18

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.
@@ -1,32 +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
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const eventSellerMakesOfferRepo = await chevre.repository.EventSellerMakesOffer.createInstance(mongoose.connection);
12
- const result = await eventSellerMakesOfferRepo.aggregateMakesOffer(
13
- {
14
- limit: 10,
15
- page: 1,
16
- // id: { $eq: 'bm0f0cadu' },
17
- // typeOf: chevre.factory.eventType.ScreeningEvent,
18
- project: { id: { $eq: project.id } },
19
- availableAtOrFrom: { id: { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' } },
20
- itemOffered: {
21
- serviceOutput: { reservationFor: { id: { $in: ['bm0f0cadu', 'blco2394l'] } } }
22
- }
23
- }
24
- );
25
- // tslint:disable-next-line:no-null-keyword
26
- console.dir(result, { depth: null });
27
- console.dir(result.length, 'results found');
28
- }
29
-
30
- main()
31
- .then(console.log)
32
- .catch(console.error);
@@ -1,31 +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
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
12
-
13
- const categoryCodes = await categoryCodeRepo.searchByAggregate(
14
- {
15
- limit: 100,
16
- page: 1,
17
- sort: { codeValue: chevre.factory.sortType.Ascending }
18
- // id: { $eq: 'xxx' }
19
- // project: { id: { $eq: project.id } }
20
- // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
21
- // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
22
- },
23
- ['id']
24
- );
25
- console.log('categoryCodes found', categoryCodes[0]);
26
- console.log(categoryCodes.length, 'categoryCodes found');
27
- }
28
-
29
- main()
30
- .then()
31
- .catch(console.error);
@@ -1,15 +0,0 @@
1
- import * as moment from 'moment';
2
- import * as factory from '../../../../factory';
3
- declare function validateOfferToken(params: {
4
- acceptedDate: moment.Moment;
5
- /**
6
- * トークン検証済の指定オファー
7
- */
8
- verifiedOffer: factory.assetTransaction.reserve.IOfferTokenPayload;
9
- /**
10
- * イベントのアプリケーションオファー設定
11
- */
12
- makesOfferOnApplication: factory.event.screeningEvent.ISellerMakesOffer;
13
- object: factory.assetTransaction.reserve.IObjectWithoutDetail;
14
- }): () => Promise<void>;
15
- export { validateOfferToken };
@@ -1,61 +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.validateOfferToken = validateOfferToken;
13
- const moment = require("moment");
14
- const factory = require("../../../../factory");
15
- const OFFER_TOKEN_DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ';
16
- function validateOfferToken(params) {
17
- return () => __awaiter(this, void 0, void 0, function* () {
18
- var _a, _b, _c, _d;
19
- const { acceptedDate, verifiedOffer, makesOfferOnApplication } = params;
20
- const applicationIdentifier = (_a = verifiedOffer.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.identifier;
21
- if (typeof applicationIdentifier !== 'string' || applicationIdentifier === '') {
22
- throw new factory.errors.Argument('reservationFor.offers.token', 'availableAtOrFrom.identifier must be string');
23
- }
24
- const applicationIdentifierMustBe = (Array.isArray(makesOfferOnApplication.availableAtOrFrom))
25
- ? makesOfferOnApplication.availableAtOrFrom[0].identifier
26
- : (_b = makesOfferOnApplication.availableAtOrFrom) === null || _b === void 0 ? void 0 : _b.identifier;
27
- if (typeof applicationIdentifierMustBe !== 'string') {
28
- throw new factory.errors.NotFound('makesOffer.availableAtOrFrom.identifier');
29
- }
30
- if (applicationIdentifier !== applicationIdentifierMustBe) {
31
- throw new factory.errors.Argument('reservationFor.offers.token', 'availableAtOrFrom.identifier not matched');
32
- }
33
- let validThroughMoment;
34
- let validFromMoment;
35
- validThroughMoment = moment(verifiedOffer.validThrough, OFFER_TOKEN_DATE_FORMAT, true);
36
- validFromMoment = moment(verifiedOffer.validFrom, OFFER_TOKEN_DATE_FORMAT, true);
37
- if (!validThroughMoment.isValid()) {
38
- throw new factory.errors.Argument('reservationFor.offers.token', 'invalid validThrough');
39
- }
40
- if (!validFromMoment.isValid()) {
41
- throw new factory.errors.Argument('reservationFor.offers.token', 'invalid validFrom');
42
- }
43
- if (acceptedDate.isBefore(validFromMoment)) {
44
- throw new factory.errors.Argument('reservationFor.offers.token', `the offer id valid from ${validFromMoment}`);
45
- }
46
- if (acceptedDate.isAfter(validThroughMoment)) {
47
- throw new factory.errors.Argument('reservationFor.offers.token', `the offer id valid through ${validThroughMoment}`);
48
- }
49
- // tslint:disable-next-line:no-suspicious-comment
50
- // TODO maxValueを検証
51
- const maxValue = (_c = verifiedOffer === null || verifiedOffer === void 0 ? void 0 : verifiedOffer.eligibleQuantity) === null || _c === void 0 ? void 0 : _c.maxValue;
52
- if (typeof maxValue === 'number') {
53
- const numAcceptedOffers = (_d = params.object.acceptedOffer) === null || _d === void 0 ? void 0 : _d.length;
54
- if (typeof numAcceptedOffers === 'number' && numAcceptedOffers > 0) {
55
- if (numAcceptedOffers > maxValue) {
56
- throw new factory.errors.Argument('reservationFor.id', `Maximum number of offers exceeded`);
57
- }
58
- }
59
- }
60
- });
61
- }