@chevre/domain 24.0.0-alpha.84 → 24.0.0-alpha.85

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.
@@ -110,17 +110,6 @@ class AggregateOfferRepo {
110
110
  }
111
111
  });
112
112
  }
113
- // const eligibleMonetaryAmountCurrencyEq = params.eligibleMonetaryAmount?.currency?.$eq;
114
- // if (typeof eligibleMonetaryAmountCurrencyEq === 'string') {
115
- // matchStages.push({
116
- // $match: {
117
- // 'offers.eligibleMonetaryAmount.currency': {
118
- // $exists: true,
119
- // $eq: eligibleMonetaryAmountCurrencyEq
120
- // }
121
- // }
122
- // });
123
- // }
124
113
  const eligibleSeatingTypeCodeValueEq = params.eligibleSeatingType?.codeValue?.$eq;
125
114
  if (typeof eligibleSeatingTypeCodeValueEq === 'string') {
126
115
  matchStages.push({
@@ -378,11 +367,6 @@ class AggregateOfferRepo {
378
367
  }
379
368
  });
380
369
  }
381
- // add advanceBookingRequirement.id.$eq(2025-04-08~)
382
- const advanceBookingRequirementIdEq = params.advanceBookingRequirement?.id?.$eq;
383
- if (typeof advanceBookingRequirementIdEq === 'string') {
384
- matchStages.push({ $match: { 'offers.advanceBookingRequirement.id': { $exists: true, $eq: advanceBookingRequirementIdEq } } });
385
- }
386
370
  return matchStages;
387
371
  }
388
372
  static CREATE_AGGREGATE_OFFERS_PROJECTION(params) {
@@ -199,15 +199,6 @@ const indexes = [
199
199
  }
200
200
  }
201
201
  ],
202
- [
203
- { 'offers.eligibleMonetaryAmount.currency': 1 },
204
- {
205
- name: 'searchByOffersEligibleMonetaryAmountCurrency-v2',
206
- partialFilterExpression: {
207
- 'offers.eligibleMonetaryAmount.currency': { $exists: true }
208
- }
209
- }
210
- ],
211
202
  [
212
203
  { 'offers.eligibleSeatingType.codeValue': 1 },
213
204
  {
@@ -271,15 +262,6 @@ const indexes = [
271
262
  }
272
263
  }
273
264
  ],
274
- [
275
- { 'offers.advanceBookingRequirement.id': 1 },
276
- {
277
- name: 'advanceBookingRequirementId',
278
- partialFilterExpression: {
279
- 'offers.advanceBookingRequirement.id': { $exists: true }
280
- }
281
- }
282
- ]
283
265
  ];
284
266
  exports.indexes = indexes;
285
267
  /**
@@ -38,7 +38,6 @@ class OfferRepo {
38
38
  color: '$offers.color',
39
39
  acceptedPaymentMethod: '$offers.acceptedPaymentMethod',
40
40
  additionalProperty: '$offers.additionalProperty',
41
- advanceBookingRequirement: '$offers.advanceBookingRequirement',
42
41
  alternateName: '$offers.alternateName',
43
42
  addOn: '$offers.addOn',
44
43
  availability: '$offers.availability',
@@ -50,7 +49,6 @@ class OfferRepo {
50
49
  eligibleCustomerType: '$offers.eligibleCustomerType',
51
50
  eligibleDuration: '$offers.eligibleDuration',
52
51
  eligibleMembershipType: '$offers.eligibleMembershipType',
53
- // eligibleMonetaryAmount: '$offers.eligibleMonetaryAmount', // discontinue(2026-04-19~)
54
52
  eligibleQuantity: '$offers.eligibleQuantity',
55
53
  eligibleRegion: '$offers.eligibleRegion',
56
54
  eligibleSeatingType: '$offers.eligibleSeatingType',
@@ -16,7 +16,6 @@ import type { CheckThingActionRepo } from './repo/action/checkThing';
16
16
  import type { PayActionRepo } from './repo/action/pay';
17
17
  import type { RefundActionRepo } from './repo/action/refund';
18
18
  import type { AdditionalPropertyRepo } from './repo/additionalProperty';
19
- import type { AdvanceBookingRequirementRepo } from './repo/advanceBookingRequirement';
20
19
  import type { AggregateActionRepo } from './repo/aggregateAction';
21
20
  import type { AggregateOfferRepo } from './repo/aggregateOffer';
22
21
  import type { AggregateOrderRepo } from './repo/aggregateOrder';
@@ -156,10 +155,6 @@ export type AdditionalProperty = AdditionalPropertyRepo;
156
155
  export declare namespace AdditionalProperty {
157
156
  function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
158
157
  }
159
- export type AdvanceBookingRequirement = AdvanceBookingRequirementRepo;
160
- export declare namespace AdvanceBookingRequirement {
161
- function createInstance(...params: ConstructorParameters<typeof AdvanceBookingRequirementRepo>): Promise<AdvanceBookingRequirementRepo>;
162
- }
163
158
  export type AggregateAction = AggregateActionRepo;
164
159
  export declare namespace AggregateAction {
165
160
  function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAction = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
- exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
3
+ exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
+ exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = void 0;
5
5
  var AcceptedOffer;
6
6
  (function (AcceptedOffer) {
7
7
  let repo;
@@ -170,17 +170,6 @@ var AdditionalProperty;
170
170
  }
171
171
  AdditionalProperty.createInstance = createInstance;
172
172
  })(AdditionalProperty || (exports.AdditionalProperty = AdditionalProperty = {}));
173
- var AdvanceBookingRequirement;
174
- (function (AdvanceBookingRequirement) {
175
- let repo;
176
- async function createInstance(...params) {
177
- if (repo === undefined) {
178
- repo = (await import('./repo/advanceBookingRequirement.js')).AdvanceBookingRequirementRepo;
179
- }
180
- return new repo(...params);
181
- }
182
- AdvanceBookingRequirement.createInstance = createInstance;
183
- })(AdvanceBookingRequirement || (exports.AdvanceBookingRequirement = AdvanceBookingRequirement = {}));
184
173
  var AggregateAction;
185
174
  (function (AggregateAction) {
186
175
  let repo;
@@ -1,5 +1,4 @@
1
1
  import { factory } from '../../../../factory';
2
- import type { AdvanceBookingRequirementRepo } from '../../../../repo/advanceBookingRequirement';
3
2
  import type { IMinimizedIndividualEvent } from '../../../../repo/event';
4
3
  import type { OfferRepo } from '../../../../repo/offer/unitPriceInCatalog';
5
4
  import type { OfferCatalogRepo } from '../../../../repo/offerCatalog';
@@ -19,7 +18,6 @@ declare function createSubReservations(params: {
19
18
  };
20
19
  validateAppliesToMovieTicket: boolean;
21
20
  }): (repos: {
22
- advanceBookingRequirement: AdvanceBookingRequirementRepo;
23
21
  offer: OfferRepo;
24
22
  offerCatalog: OfferCatalogRepo;
25
23
  paymentService: PaymentServiceRepo;
@@ -32,18 +32,11 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  exports.createSubReservations = createSubReservations;
40
- const debug_1 = __importDefault(require("debug"));
41
- const moment_1 = __importDefault(require("moment"));
42
37
  const factory_1 = require("../../../../factory");
43
- // import * as OfferService from '../../../offer';
44
38
  const ProductOfferService = __importStar(require("../../../offer/product"));
45
39
  const createReservation_1 = require("./factory/createReservation");
46
- const debug = (0, debug_1.default)('chevre-domain:service:assetTransaction:reserve');
47
40
  function createSubReservations(params) {
48
41
  return async (repos) => {
49
42
  // 予約番号
@@ -56,14 +49,7 @@ function createSubReservations(params) {
56
49
  const eventOffers = params.event.offers;
57
50
  const reservedSeatsOnly = eventOffers?.itemOffered.serviceOutput?.reservedTicket?.ticketedSeat !== undefined;
58
51
  // オファーIDごとにオファー適用条件を確認(興行オファー承認アクションから処理を移行)(2024-07-03~)
59
- validateQuantityRequirement({ acceptedOffers: params.acceptedOffers, ticketOffers: params.ticketOffers, reservationNumber });
60
- // 事前予約要件参照
61
- let advanceBookingRequirements = [];
62
- const advanceBookingRequirementIds = [...new Set(params.availableOffers.reduce((a, b) => (typeof b.advanceBookingRequirement?.id === 'string') ? [...a, b.advanceBookingRequirement.id] : a, []))];
63
- if (advanceBookingRequirementIds.length > 0) {
64
- advanceBookingRequirements = await repos.advanceBookingRequirement.projectFields({ id: { $in: advanceBookingRequirementIds } }, ['identifier', 'maxValue', 'minValue', 'unitCode', 'valueReference']);
65
- debug('createSubReservations:', advanceBookingRequirements.length, 'advanceBookingRequirements found', JSON.stringify(advanceBookingRequirements));
66
- }
52
+ validateQuantityRequirement({ acceptedOffers: params.acceptedOffers, ticketOffers: params.ticketOffers });
67
53
  const reservations = [];
68
54
  let reservationIndex = -1;
69
55
  for (const acceptedOffer of params.acceptedOffers) {
@@ -77,13 +63,6 @@ function createSubReservations(params) {
77
63
  if (ticketType === undefined) {
78
64
  throw new factory_1.factory.errors.NotFound(ticketOffer.typeOf);
79
65
  }
80
- // 事前予約要件検証(2023-08-10~)
81
- validateAdvanceBookingRequirement({
82
- advanceBookingRequirements,
83
- unitPriceOffer: ticketType,
84
- now: params.now,
85
- reservationFor: params.event
86
- });
87
66
  const programMembershipUsed = await validateProgramMembershipUsed({
88
67
  acceptedOffer,
89
68
  availableOffer: ticketType,
@@ -271,11 +250,10 @@ function searchAvailableAddOns(params) {
271
250
  };
272
251
  }
273
252
  function validateQuantityRequirement(params) {
274
- const { acceptedOffers, ticketOffers, reservationNumber } = params;
253
+ const { acceptedOffers, ticketOffers } = params;
275
254
  const offerIds = (Array.isArray(acceptedOffers))
276
255
  ? [...new Set(params.acceptedOffers.map(({ id }) => id))]
277
256
  : [];
278
- debug('validating quantity requirement... reservationNumber:', reservationNumber, offerIds);
279
257
  // オファーIDごとにオファー適用条件を確認
280
258
  offerIds.forEach((offerId) => {
281
259
  const numAcceptedOffersByOfferId = params.acceptedOffers.filter(({ id }) => id === offerId).length;
@@ -295,83 +273,24 @@ function validateQuantityRequirement(params) {
295
273
  referenceQuantityValue = unitPriceSpecReferenceQuantityValue;
296
274
  }
297
275
  // アイテム数が適用単位要件を満たしていなければエラー
298
- debug('validating referenceQuantity... reservationNumber:', reservationNumber, offerId, 'numAcceptedOffersByOfferId:', numAcceptedOffersByOfferId, 'referenceQuantityValue:', referenceQuantityValue);
299
276
  if (numAcceptedOffersByOfferId % referenceQuantityValue !== 0) {
300
277
  throw new factory_1.factory.errors.Argument('acceptedOffers', `Offer ${offerId} requires reference quantity value ${referenceQuantityValue}`);
301
278
  }
302
279
  // 適用数量要件を満たしていなければエラー
303
280
  const maxValue = unitPriceSpec.eligibleQuantity?.maxValue;
304
281
  if (typeof maxValue === 'number') {
305
- debug('validating eligibleQuantity.maxValue... reservationNumber:', reservationNumber, offerId, 'numAcceptedOffersByOfferId:', numAcceptedOffersByOfferId, 'maxValue:', maxValue);
306
282
  if (numAcceptedOffersByOfferId > maxValue) {
307
283
  throw new factory_1.factory.errors.Argument('acceptedOffers', `Number of offer:${offerId} must be less than or equal to ${maxValue}`);
308
284
  }
309
285
  }
310
286
  const minValue = unitPriceSpec.eligibleQuantity?.minValue;
311
287
  if (typeof minValue === 'number') {
312
- debug('validating eligibleQuantity.minValue... reservationNumber:', reservationNumber, offerId, 'numAcceptedOffersByOfferId:', numAcceptedOffersByOfferId, 'minValue:', minValue);
313
288
  if (numAcceptedOffersByOfferId < minValue) {
314
289
  throw new factory_1.factory.errors.Argument('acceptedOffers', `Number of offer:${offerId} must be more than or equal to ${minValue}`);
315
290
  }
316
291
  }
317
292
  });
318
293
  }
319
- /**
320
- * 事前予約要件を検証する
321
- */
322
- function validateAdvanceBookingRequirement(params) {
323
- let requirementSatisfied = true;
324
- // reimplement using advanceBookingRequirementRepo(2025-04-08~)
325
- const advanceBookingRequirementId = params.unitPriceOffer.advanceBookingRequirement?.id;
326
- if (typeof advanceBookingRequirementId === 'string') {
327
- const advanceBookingRequirement = params.advanceBookingRequirements.find(({ id }) => id === advanceBookingRequirementId);
328
- if (advanceBookingRequirement === undefined) {
329
- throw new factory_1.factory.errors.NotFound('advanceBookingRequirement');
330
- }
331
- const advanceBookingRequirementMaxValue = advanceBookingRequirement.maxValue;
332
- const advanceBookingRequirementMinValue = advanceBookingRequirement.minValue;
333
- const advanceBookingRequirementUnitCode = advanceBookingRequirement.unitCode;
334
- const valueReferenceOpens = advanceBookingRequirement.valueReference?.opens;
335
- let usageDate = (0, moment_1.default)(params.reservationFor.startDate, true);
336
- if (typeof valueReferenceOpens === 'string') {
337
- // support valueReference(2025-04-10~)
338
- const opensOffset = valueReferenceOpens.slice(8); // format: HH:mm:ssZ
339
- debug('opensOffset:', opensOffset);
340
- usageDate = usageDate.utcOffset(opensOffset);
341
- usageDate = (0, moment_1.default)(`${usageDate.format('YYYY-MM-DD')}T${valueReferenceOpens}`, true);
342
- }
343
- debug('usageDate:', usageDate);
344
- if (typeof advanceBookingRequirementMaxValue === 'number' && typeof advanceBookingRequirementUnitCode === 'string') {
345
- if (advanceBookingRequirementMaxValue < 0) {
346
- throw new factory_1.factory.errors.NotImplemented('negative value as advanceBookingRequirement.maxValue not implemented');
347
- }
348
- if (advanceBookingRequirementUnitCode !== factory_1.factory.unitCode.Day) {
349
- throw new factory_1.factory.errors.NotImplemented(`only ${factory_1.factory.unitCode.Day} implemented`);
350
- }
351
- const usageDateMustBeBefore = (0, moment_1.default)(params.now)
352
- .add(advanceBookingRequirementMaxValue, 'days');
353
- if (!usageDate.isSameOrBefore(usageDateMustBeBefore)) {
354
- requirementSatisfied = false;
355
- }
356
- }
357
- if (typeof advanceBookingRequirementMinValue === 'number' && typeof advanceBookingRequirementUnitCode === 'string') {
358
- if (advanceBookingRequirementMinValue < 0) {
359
- throw new factory_1.factory.errors.NotImplemented('negative value as advanceBookingRequirement.minValue not implemented');
360
- }
361
- if (advanceBookingRequirementUnitCode !== factory_1.factory.unitCode.Day) {
362
- throw new factory_1.factory.errors.NotImplemented(`only ${factory_1.factory.unitCode.Day} implemented`);
363
- }
364
- const usageDateMustBeAfter = (0, moment_1.default)(params.now)
365
- .add(advanceBookingRequirementMinValue, 'days');
366
- if (!usageDate.isSameOrAfter(usageDateMustBeAfter)) {
367
- requirementSatisfied = false;
368
- }
369
- }
370
- }
371
- if (!requirementSatisfied) {
372
- throw new factory_1.factory.errors.Argument('acceptedOffer.id', 'advanceBookingRequirement not satisfied');
373
- }
374
- }
375
294
  function validateProgramMembershipUsed(params) {
376
295
  return async (repos) => {
377
296
  // const now = new Date();
@@ -1,6 +1,5 @@
1
1
  import { factory } from '../../../factory';
2
2
  import { Settings } from '../../../settings';
3
- import type { AdvanceBookingRequirementRepo } from '../../../repo/advanceBookingRequirement';
4
3
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
5
4
  import type { AuthorizationRepo } from '../../../repo/authorization';
6
5
  import type { EventRepo } from '../../../repo/event';
@@ -23,7 +22,6 @@ import type { StockHolderRepo } from '../../../repo/stockHolder';
23
22
  import type { TaskRepo } from '../../../repo/task';
24
23
  import type { TicketRepo } from '../../../repo/ticket';
25
24
  interface IStartOperationRepos {
26
- advanceBookingRequirement: AdvanceBookingRequirementRepo;
27
25
  authorization: AuthorizationRepo;
28
26
  stockHolder: StockHolderRepo;
29
27
  event: EventRepo;
@@ -1,6 +1,5 @@
1
1
  import { factory } from '../../../../factory';
2
2
  import { Settings } from '../../../../settings';
3
- import type { AdvanceBookingRequirementRepo } from '../../../../repo/advanceBookingRequirement';
4
3
  import type { AssetTransactionRepo } from '../../../../repo/assetTransaction';
5
4
  import type { AuthorizationRepo } from '../../../../repo/authorization';
6
5
  import type { EventRepo, IMinimizedIndividualEvent } from '../../../../repo/event';
@@ -49,7 +48,6 @@ declare function processStartReserve4chevre(params: {
49
48
  */
50
49
  maxReservationGracePeriodInDays: number;
51
50
  }): (repos: {
52
- advanceBookingRequirement: AdvanceBookingRequirementRepo;
53
51
  authorization: AuthorizationRepo;
54
52
  stockHolder: StockHolderRepo;
55
53
  event: EventRepo;
@@ -1,7 +1,6 @@
1
1
  import { factory } from '../../../factory';
2
2
  import { Settings } from '../../../settings';
3
3
  import type { AuthorizeOfferActionRepo } from '../../../repo/action/authorizeOffer';
4
- import type { AdvanceBookingRequirementRepo } from '../../../repo/advanceBookingRequirement';
5
4
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
6
5
  import type { AuthorizationRepo } from '../../../repo/authorization';
7
6
  import type { EventRepo } from '../../../repo/event';
@@ -30,7 +29,6 @@ import type { TransactionNumberRepo } from '../../../repo/transactionNumber';
30
29
  interface IAuthorizeRepos {
31
30
  action?: never;
32
31
  authorizeOfferAction: AuthorizeOfferActionRepo;
33
- advanceBookingRequirement: AdvanceBookingRequirementRepo;
34
32
  assetTransaction: AssetTransactionRepo;
35
33
  authorization: AuthorizationRepo;
36
34
  event: EventRepo;
@@ -122,14 +122,11 @@ function createCompoundPriceSpec4event(params) {
122
122
  priceComponent
123
123
  };
124
124
  // 必要な属性のみに限定(2023-02-24~)
125
- const { acceptedPaymentMethod, name, description, alternateName, color, typeOf, id, availability, category, eligibleMembershipType, eligibleSeatingType,
126
- // eligibleMonetaryAmount, // discontinue(2026-04-19~)
127
- eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
125
+ const { acceptedPaymentMethod, name, description, alternateName, color, typeOf, id, availability, category, eligibleMembershipType, eligibleSeatingType, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
128
126
  return {
129
127
  name, description, alternateName, color, typeOf, id,
130
128
  category,
131
129
  eligibleMembershipType, eligibleSeatingType,
132
- // eligibleMonetaryAmount, // discontinue(2026-04-19~)
133
130
  eligibleSubReservation,
134
131
  priceCurrency,
135
132
  validFrom, validThrough, validRateLimit, additionalProperty,
package/package.json CHANGED
@@ -11,7 +11,7 @@
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": "8.0.0-alpha.6",
14
+ "@chevre/factory": "8.0.0-alpha.7",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "24.0.0-alpha.84"
94
+ "version": "24.0.0-alpha.85"
95
95
  }
@@ -1,35 +0,0 @@
1
- import { Connection, FilterQuery } from 'mongoose';
2
- import { factory } from '../factory';
3
- import { IDocType } from './mongoose/schemas/advanceBookingRequirement';
4
- export type ISavingRequirement = Pick<factory.advanceBookingRequirement.IAdvanceBookingRequirement, 'identifier' | 'project' | 'typeOf' | 'description' | 'maxValue' | 'minValue' | 'unitCode' | 'valueReference'> & {
5
- id?: never;
6
- };
7
- interface IUnset {
8
- $unset?: Record<string, 1>;
9
- }
10
- type IRequirementWithId = factory.advanceBookingRequirement.IAdvanceBookingRequirement & {
11
- id: string;
12
- };
13
- type IKeyOfProjection = keyof factory.advanceBookingRequirement.IAdvanceBookingRequirement;
14
- /**
15
- * 事前予約要件リポジトリ
16
- */
17
- export declare class AdvanceBookingRequirementRepo {
18
- private readonly advanceBookingRequirementModel;
19
- constructor(connection: Connection);
20
- static CREATE_FILTER_QUERY(params: factory.advanceBookingRequirement.ISearchConditions): FilterQuery<IDocType>[];
21
- save(params: {
22
- id?: string;
23
- attributes: ISavingRequirement & IUnset;
24
- }): Promise<{
25
- id: string;
26
- }>;
27
- projectFields(conditions: factory.advanceBookingRequirement.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IRequirementWithId[]>;
28
- deleteById(params: {
29
- id: string;
30
- project: {
31
- id: string;
32
- };
33
- }): Promise<void>;
34
- }
35
- export {};
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdvanceBookingRequirementRepo = void 0;
4
- const factory_1 = require("../factory");
5
- const settings_1 = require("../settings");
6
- const advanceBookingRequirement_1 = require("./mongoose/schemas/advanceBookingRequirement");
7
- /**
8
- * 事前予約要件リポジトリ
9
- */
10
- class AdvanceBookingRequirementRepo {
11
- advanceBookingRequirementModel;
12
- constructor(connection) {
13
- this.advanceBookingRequirementModel = connection.model(advanceBookingRequirement_1.modelName, (0, advanceBookingRequirement_1.createSchema)());
14
- }
15
- static CREATE_FILTER_QUERY(params) {
16
- const andConditions = [];
17
- const projectIdEq = params.project?.id?.$eq;
18
- if (typeof projectIdEq === 'string') {
19
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
20
- }
21
- const idEq = params.id?.$eq;
22
- if (typeof idEq === 'string') {
23
- andConditions.push({ _id: { $eq: idEq } });
24
- }
25
- const idIn = params.id?.$in;
26
- if (Array.isArray(idIn)) {
27
- andConditions.push({ _id: { $in: idIn } });
28
- }
29
- const identifierEq = params.identifier?.$eq;
30
- if (typeof identifierEq === 'string') {
31
- andConditions.push({ identifier: { $eq: identifierEq } });
32
- }
33
- const identifierRegex = params.identifier?.$regex;
34
- if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
35
- andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
36
- }
37
- return andConditions;
38
- }
39
- async save(params) {
40
- let doc;
41
- let savedId;
42
- const savingId = params.id;
43
- if (typeof savingId === 'string') {
44
- if (savingId === '') {
45
- throw new factory_1.factory.errors.ArgumentNull('id');
46
- }
47
- const { id, identifier, project, typeOf, $unset, ...updateFields } = params.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
48
- const filter = {
49
- _id: { $eq: savingId },
50
- 'project.id': { $eq: project.id }
51
- };
52
- const update = {
53
- $set: updateFields,
54
- ...($unset !== undefined && $unset !== null) ? { $unset } : undefined
55
- };
56
- const options = {
57
- upsert: false,
58
- new: true,
59
- projection: { _id: 1, id: { $toString: '$_id' } }
60
- };
61
- doc = await this.advanceBookingRequirementModel.findOneAndUpdate(filter, update, options)
62
- .lean()
63
- .exec();
64
- if (doc === null) {
65
- throw new factory_1.factory.errors.NotFound(this.advanceBookingRequirementModel.modelName);
66
- }
67
- savedId = savingId;
68
- }
69
- else {
70
- const { $unset, id, ...createParams } = params.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
71
- const result = await this.advanceBookingRequirementModel.insertMany(createParams, { rawResult: true });
72
- const insertedId = result.insertedIds?.[0]?.toHexString();
73
- if (typeof insertedId !== 'string') {
74
- throw new factory_1.factory.errors.Internal(`not saved unexpectedly. result:${JSON.stringify(result)}`);
75
- }
76
- savedId = insertedId;
77
- }
78
- return { id: savedId };
79
- }
80
- async projectFields(conditions, inclusion) {
81
- const andConditions = AdvanceBookingRequirementRepo.CREATE_FILTER_QUERY(conditions);
82
- const projection = {
83
- _id: 0,
84
- id: { $toString: '$_id' },
85
- ...Object.fromEntries(inclusion.map((key) => ([key, 1])))
86
- };
87
- const query = this.advanceBookingRequirementModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
88
- if (typeof conditions.limit === 'number' && conditions.limit > 0) {
89
- const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
90
- query.limit(conditions.limit)
91
- .skip(conditions.limit * (page - 1));
92
- }
93
- if (typeof conditions.sort?.identifier === 'number') {
94
- query.sort({ identifier: conditions.sort.identifier });
95
- }
96
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
97
- .lean()
98
- .exec();
99
- }
100
- async deleteById(params) {
101
- await this.advanceBookingRequirementModel.findOneAndDelete({
102
- _id: { $eq: params.id },
103
- 'project.id': { $eq: params.project.id }
104
- }, { projection: { _id: 1 } })
105
- .exec();
106
- }
107
- }
108
- exports.AdvanceBookingRequirementRepo = AdvanceBookingRequirementRepo;
@@ -1,11 +0,0 @@
1
- import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
- import { IVirtuals } from '../virtuals';
3
- import { factory } from '../../../factory';
4
- type IDocType = Omit<factory.advanceBookingRequirement.IAdvanceBookingRequirement, 'id'>;
5
- type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
6
- type ISchemaDefinition = SchemaDefinition<IDocType>;
7
- type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
8
- declare const modelName = "AdvanceBookingRequirement";
9
- declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
- declare function createSchema(): ISchema;
11
- export { createSchema, IDocType, IModel, indexes, modelName };
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modelName = exports.indexes = void 0;
4
- exports.createSchema = createSchema;
5
- const mongoose_1 = require("mongoose");
6
- const writeConcern_1 = require("../writeConcern");
7
- const settings_1 = require("../../../settings");
8
- const modelName = 'AdvanceBookingRequirement';
9
- exports.modelName = modelName;
10
- const schemaDefinition = {
11
- project: {
12
- type: mongoose_1.SchemaTypes.Mixed,
13
- required: true
14
- },
15
- typeOf: {
16
- type: String,
17
- required: true
18
- },
19
- identifier: {
20
- type: String,
21
- required: true
22
- },
23
- unitCode: {
24
- type: String,
25
- required: true
26
- },
27
- maxValue: Number,
28
- minValue: Number,
29
- description: mongoose_1.SchemaTypes.Mixed,
30
- valueReference: mongoose_1.SchemaTypes.Mixed
31
- };
32
- const schemaOptions = {
33
- autoIndex: settings_1.MONGO_AUTO_INDEX,
34
- autoCreate: false,
35
- collection: 'advanceBookingRequirements',
36
- id: true,
37
- read: settings_1.MONGO_READ_PREFERENCE,
38
- writeConcern: writeConcern_1.writeConcern,
39
- strict: true,
40
- strictQuery: false,
41
- timestamps: false,
42
- versionKey: false,
43
- toJSON: {
44
- getters: false,
45
- virtuals: false,
46
- minimize: false,
47
- versionKey: false
48
- },
49
- toObject: {
50
- getters: false,
51
- virtuals: true,
52
- minimize: false,
53
- versionKey: false
54
- }
55
- };
56
- const indexes = [
57
- [
58
- { identifier: 1 },
59
- { name: 'identifier' }
60
- ],
61
- [
62
- { 'project.id': 1, identifier: 1 },
63
- {
64
- name: 'uniqueIdentifier',
65
- unique: true
66
- }
67
- ]
68
- ];
69
- exports.indexes = indexes;
70
- /**
71
- * 事前予約要件スキーマ
72
- */
73
- let schema;
74
- function createSchema() {
75
- if (schema === undefined) {
76
- schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
77
- if (settings_1.MONGO_AUTO_INDEX) {
78
- indexes.forEach((indexParams) => {
79
- schema?.index(...indexParams);
80
- });
81
- }
82
- }
83
- return schema;
84
- }