@gomusdev/web-components 1.22.3 → 1.23.0

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 (20) hide show
  1. package/dist-js/components/cart/mocks/gomusTicketMocks.d.ts +0 -2
  2. package/dist-js/components/ticketSelection/TicketSelectionDetails.svelte.d.ts +1 -1
  3. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/TicketSegmentDetails.svelte.d.ts +4 -919
  4. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/annualTickets.svelte.d.ts +2 -0
  5. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/dayTickets.svelte.d.ts +2 -0
  6. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventScaledPriceTickets.spec.d.ts +1 -0
  7. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventScaledPriceTickets.svelte.d.ts +2 -0
  8. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventTickets.spec.d.ts +1 -0
  9. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventTickets.svelte.d.ts +2 -0
  10. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/timeslotTickets.svelte.d.ts +2 -0
  11. package/dist-js/gomus-webcomponents.iife.js +228 -119
  12. package/dist-js/gomus-webcomponents.js +228 -119
  13. package/dist-js/lib/models/capacities/capacities.d.ts +44 -0
  14. package/dist-js/lib/models/capacities/capacities.spec.d.ts +1 -0
  15. package/dist-js/lib/models/scalePrice/UIScaledPrice.svelte.d.ts +0 -6
  16. package/dist-js/lib/models/ticket/UITicket.svelte.d.ts +1 -4
  17. package/dist-js/lib/stores/shop.svelte.d.ts +45 -54
  18. package/dist-js/mocks/MSWMocks.d.ts +5 -0
  19. package/dist-js/mocks/mocks.d.ts +0 -24
  20. package/package.json +1 -1
@@ -5585,6 +5585,11 @@ const isNumber = (value) => {
5585
5585
  return false;
5586
5586
  }
5587
5587
  };
5588
+ const boil = (array2, compareFunc) => {
5589
+ if (!array2 || (array2.length ?? 0) === 0)
5590
+ return null;
5591
+ return array2.reduce(compareFunc);
5592
+ };
5588
5593
  function sum(array2, fn) {
5589
5594
  return (array2 || []).reduce((acc, item) => acc + (fn ? fn(item) : item), 0);
5590
5595
  }
@@ -5602,6 +5607,10 @@ const alphabetical = (array2, getter, dir = "asc") => {
5602
5607
  const dsc = (a2, b) => `${getter(b)}`.localeCompare(getter(a2));
5603
5608
  return array2.slice().sort(dir === "desc" ? dsc : asc);
5604
5609
  };
5610
+ function max$1(array2, getter) {
5611
+ const get2 = getter ?? ((v) => v);
5612
+ return boil(array2, (a2, b) => get2(a2) > get2(b) ? a2 : b);
5613
+ }
5605
5614
  const iterate = (count, func, initValue) => {
5606
5615
  let value = initValue;
5607
5616
  for (let i = 1; i <= count; i++) {
@@ -11985,7 +11994,7 @@ class Shop {
11985
11994
  const isCacheExpired = this.#fetchStatus[fetchId]?.fetchedAt < Date.now() - options.cache * 1e3;
11986
11995
  if (isNotFetchedYet || isCacheExpired) {
11987
11996
  this.apiGet(endpoint, query, options.path).then((ret) => {
11988
- get$2(this.#data)[dataKey] = responseKey === "" ? ret : ret[responseKey];
11997
+ if (ret) get$2(this.#data)[dataKey] = responseKey === "" ? ret : ret[responseKey];
11989
11998
  });
11990
11999
  }
11991
12000
  return get$2(this.#data)[dataKey];
@@ -12004,6 +12013,12 @@ class Shop {
12004
12013
  getEvent(id) {
12005
12014
  return this.fetchAndCache(`/api/v4/events/${id}`, `single_event_${id}`, "event");
12006
12015
  }
12016
+ getTicketCapacities(date2, ticketIds) {
12017
+ return this.apiPost(`/api/v4/tickets/capacities`, {
12018
+ body: { date: date2, ticket_ids: ticketIds },
12019
+ requiredFields: ["date", "ticket_ids"]
12020
+ });
12021
+ }
12007
12022
  getEventDetailsOnDate(eventId, dateId) {
12008
12023
  return this.fetchAndCache(`/api/v4/events/${eventId}/dates/${dateId}`, `/api/v4/events/${eventId}/dates/${dateId}`, "date");
12009
12024
  }
@@ -15345,16 +15360,7 @@ function createUIEventTicket(apiTicket, dateId, options) {
15345
15360
  ...product,
15346
15361
  ...apiTicket,
15347
15362
  ...finalOptions,
15348
- type: "scale",
15349
- get max_capacity() {
15350
- return 18;
15351
- },
15352
- get min_quantity() {
15353
- return 0;
15354
- },
15355
- get max_quantity() {
15356
- return 18;
15357
- }
15363
+ type: "scale"
15358
15364
  };
15359
15365
  return uiTicket;
15360
15366
  }
@@ -15434,7 +15440,7 @@ function isUITicket(x) {
15434
15440
  return x.product_type === "Ticket";
15435
15441
  }
15436
15442
  function createUITicket(apiTicket, options) {
15437
- const finalOptions = { minAvailableCapacity: 0, selectedTime: "", ...options ?? {} };
15443
+ const finalOptions = { selectedTime: "", ...{} };
15438
15444
  const product = { product_type: "Ticket", ...apiTicket };
15439
15445
  const _ = { ...apiTicket, ...finalOptions };
15440
15446
  const uiTicket = {
@@ -15460,7 +15466,7 @@ function generateCartItem(cartItem) {
15460
15466
  switch (type) {
15461
15467
  case "Ticket":
15462
15468
  if (cartItem.product.ticket_type === "timeslot" && !inTheFuture(cartItem.attributes.time)) return;
15463
- const ticket = createUITicket(cartItem.product, { minAvailableCapacity: 0 });
15469
+ const ticket = createUITicket(cartItem.product);
15464
15470
  return createCartItem(ticket, { time: cartItem.time, quantity: cartItem.quantity });
15465
15471
  case "Event":
15466
15472
  const event = createUIEventTicket(cartItem.product, cartItem.id);
@@ -30440,7 +30446,13 @@ function evaluateExpression(expression, data) {
30440
30446
  console.log(`Error while evaluating when (${expression}) in go-if: ${error.message}`);
30441
30447
  }
30442
30448
  }
30443
- const validTicketSelectionFilters = ["timeslot", "day", "annual", "scaled-price"];
30449
+ const validTicketSelectionFilters = [
30450
+ "timeslot",
30451
+ "day",
30452
+ "annual",
30453
+ "event:scaled-price",
30454
+ "event:ticket"
30455
+ ];
30444
30456
  let lastUId = 0;
30445
30457
  class TicketSelectionDetails {
30446
30458
  uid = lastUId++;
@@ -30535,8 +30547,10 @@ class TicketSelectionDetails {
30535
30547
  return Boolean(this.selectedDate);
30536
30548
  case "annual":
30537
30549
  return true;
30538
- case "scaled-price":
30539
- return true;
30550
+ case "event:scaled-price":
30551
+ return Boolean(this.selectedDate);
30552
+ case "event:ticket":
30553
+ return Boolean(this.selectedDate);
30540
30554
  case "timeslot":
30541
30555
  switch (this.mode) {
30542
30556
  case "event":
@@ -31356,6 +31370,187 @@ function TicketsSum($$anchor, $$props) {
31356
31370
  pop();
31357
31371
  }
31358
31372
  customElements.define("go-tickets-sum", create_custom_element(TicketsSum, {}, [], [], false));
31373
+ function loadAnnualTickets(segment) {
31374
+ const tsd = segment.ticketSelectionDetails;
31375
+ if (!tsd) return [];
31376
+ if (!tsd.filters?.includes("annual")) return [];
31377
+ const tickets = snapshot(shop.tickets({
31378
+ by_bookable: true,
31379
+ // @ts-ignore
31380
+ "by_ticket_types[]": ["annual"],
31381
+ "by_ticket_ids[]": tsd.ticketIds,
31382
+ "by_ticket_group_ids[]": tsd.ticketGroupIds
31383
+ }));
31384
+ if (!tickets) return [];
31385
+ segment.tickets = initUITimeslotTickets(tickets);
31386
+ }
31387
+ function loadDayTickets(segment) {
31388
+ const tsd = segment.ticketSelectionDetails;
31389
+ if (!tsd) return [];
31390
+ if (!tsd.filters?.includes("day")) return [];
31391
+ const tickets = snapshot(shop.tickets({
31392
+ by_bookable: true,
31393
+ // @ts-ignore
31394
+ "by_ticket_types[]": ["normal"],
31395
+ "by_ticket_ids[]": tsd.ticketIds,
31396
+ "by_ticket_group_ids[]": tsd.ticketGroupIds
31397
+ }));
31398
+ if (!tickets) return [];
31399
+ segment.tickets = initUITimeslotTickets(tickets);
31400
+ }
31401
+ function loadEventScaledPricesTickets(segment) {
31402
+ const tsd = segment.ticketSelectionDetails;
31403
+ if (!tsd) {
31404
+ console.warn("(loadEventScaledPricesTickets) tsd is undefined");
31405
+ segment.tickets = [];
31406
+ return;
31407
+ }
31408
+ if (!tsd.eventIds?.length) {
31409
+ console.warn("(loadEventScaledPricesTickets) eventIds is undefined");
31410
+ segment.tickets = [];
31411
+ return;
31412
+ }
31413
+ if (!segment.filters?.includes("event:scaled-price")) {
31414
+ console.warn("(loadEventScaledPricesTickets) filters should include event:scaled-price");
31415
+ segment.tickets = [];
31416
+ return;
31417
+ }
31418
+ if (!segment.dateId) {
31419
+ console.warn("(loadEventScaledPricesTickets) date-id is not given to the go-ticket-segment");
31420
+ segment.tickets = [];
31421
+ return;
31422
+ }
31423
+ if (tsd.eventIds.length > 1) throw new Error("(loadEventScaledPricesTickets) currently we support only one eventId in go-ticket-selection");
31424
+ const eid = tsd.eventIds[0];
31425
+ const event = snapshot(shop.getEventDetailsOnDate(eid, segment.dateId));
31426
+ segment.tickets = event?.prices.map((t) => createUIEventTicket(t, segment.dateId)) || [];
31427
+ const seats = {
31428
+ max_per_registration: 2,
31429
+ available: 100,
31430
+ overbook: true,
31431
+ ...event?.seats
31432
+ };
31433
+ const max_per_registration = seats.max_per_registration || seats.available;
31434
+ segment.contingent = seats.overbook ? max_per_registration : Math.min(seats.available, max_per_registration);
31435
+ }
31436
+ function createCapacities(apiCapacities) {
31437
+ let reservations = {};
31438
+ const ret = {
31439
+ apiData: apiCapacities,
31440
+ reservations,
31441
+ setReservation(ticketId, timeSlot, quantity) {
31442
+ this.reservations[ticketId + ":" + timeSlot] = quantity;
31443
+ },
31444
+ getReservation(ticketId, timeSlot) {
31445
+ return this.reservations[ticketId + ":" + timeSlot] ?? 0;
31446
+ },
31447
+ /**
31448
+ * a flat list of all timeslots and their capacities, considering reservations.
31449
+ */
31450
+ timeslots() {
31451
+ return Object.entries(this.apiData).flatMap(([quota, cap]) => {
31452
+ return Object.keys(cap.capacities).map((timeSlot) => {
31453
+ const sumReserved = sum(cap.tickets.map((ticket) => this.getReservation(ticket, timeSlot)));
31454
+ return {
31455
+ timeSlot,
31456
+ quota,
31457
+ capacity: cap.capacities[timeSlot] - sumReserved,
31458
+ tickets: cap.tickets
31459
+ };
31460
+ });
31461
+ });
31462
+ },
31463
+ tickets(ticketId) {
31464
+ return this.timeslots().flatMap(
31465
+ (x) => x.tickets.map((ticket) => ({
31466
+ timeslot: x.timeSlot,
31467
+ ticket,
31468
+ quota: x.quota,
31469
+ capacity: x.capacity
31470
+ }))
31471
+ );
31472
+ },
31473
+ ticketsByTimeSlot(timeslot) {
31474
+ return this.timeslots().filter((x) => x.timeSlot === timeslot).flatMap(
31475
+ (x) => x.tickets.map((ticket) => ({
31476
+ timeslot,
31477
+ ticket,
31478
+ quota: x.quota,
31479
+ capacity: x.capacity
31480
+ }))
31481
+ );
31482
+ },
31483
+ ticketCapacityByTicketAndTimeslot(ticketId, timeslot) {
31484
+ const maxCap = max$1(
31485
+ this.ticketsByTimeSlot(timeslot).filter((x) => x.ticket === ticketId),
31486
+ (x) => x.capacity
31487
+ )?.capacity ?? 0;
31488
+ return maxCap;
31489
+ },
31490
+ /**
31491
+ * returns the max capacity of a ticket in all timeslots
31492
+ */
31493
+ ticketCapacityByTicketId(ticketId) {
31494
+ const maxCap = max$1(
31495
+ this.tickets(ticketId).filter((x) => x.ticket === ticketId),
31496
+ (x) => x.capacity
31497
+ )?.capacity ?? 0;
31498
+ return maxCap;
31499
+ }
31500
+ };
31501
+ return ret;
31502
+ }
31503
+ async function loadEventTickets(segment) {
31504
+ const tsd = segment.ticketSelectionDetails;
31505
+ if (!tsd) {
31506
+ console.warn("(loadEventTickets) tsd is undefined");
31507
+ segment.tickets = [];
31508
+ return;
31509
+ }
31510
+ if (!tsd.eventIds?.length) {
31511
+ console.warn("(loadEventTickets) eventIds is undefined");
31512
+ segment.tickets = [];
31513
+ return;
31514
+ }
31515
+ if (!segment.filters?.includes("event:ticket")) {
31516
+ console.warn("(loadEventTickets) filters should include event:tickets");
31517
+ segment.tickets = [];
31518
+ return;
31519
+ }
31520
+ if (!tsd.selectedDate) {
31521
+ console.warn("(loadEventTickets) selected-date is not given to the go-ticket-selection");
31522
+ segment.tickets = [];
31523
+ return;
31524
+ }
31525
+ if (tsd.eventIds.length > 1) throw new Error("(loadEventTickets) currently we support only one eventId in go-ticket-selection");
31526
+ const eid = tsd.eventIds[0];
31527
+ const event = shop.getEvent(eid);
31528
+ if (!event?.tickets) return;
31529
+ const ticketIds = event.tickets;
31530
+ const tickets = shop.tickets({ by_ticket_ids: ticketIds });
31531
+ const capacitiesRes = await shop.getTicketCapacities(tsd.selectedDate.toString(), ticketIds);
31532
+ if (!tickets || !capacitiesRes) return;
31533
+ const capacities = createCapacities(capacitiesRes.data.data);
31534
+ segment.tickets = tickets.filter((t) => capacities.ticketCapacityByTicketId(t.id) > 0).map((t) => createUITicket(t));
31535
+ segment.preCart = createCart(segment.tickets);
31536
+ }
31537
+ function loadTimeslotTickets(segment) {
31538
+ const tsd = segment.ticketSelectionDetails;
31539
+ if (!tsd) return [];
31540
+ if (!tsd.selectedDate && !tsd.selectedTimeslot && tsd.filters?.includes("timeslot")) return [];
31541
+ const result = snapshot(shop.ticketsAndQuotas({
31542
+ by_bookable: true,
31543
+ valid_at: tsd.selectedDate?.toString(),
31544
+ // @ts-ignore
31545
+ "by_ticket_types[]": ["time_slot"],
31546
+ "by_museum_ids[]": tsd.museumIds,
31547
+ "by_exhibition_ids[]": tsd.exhibitionIds,
31548
+ "by_ticket_ids[]": tsd.ticketIds,
31549
+ "by_ticket_group_ids[]": tsd.ticketGroupIds
31550
+ }));
31551
+ if (!result) return [];
31552
+ segment.tickets = initUITimeslotTickets(result.tickets);
31553
+ }
31359
31554
  class TicketSegmentDetails {
31360
31555
  #ticketSelectionDetails;
31361
31556
  get ticketSelectionDetails() {
@@ -31410,7 +31605,10 @@ class TicketSegmentDetails {
31410
31605
  });
31411
31606
  });
31412
31607
  user_effect(() => {
31413
- this.preCart = createCart(this.preCartTickets(), this.contingent);
31608
+ this.loadTickets();
31609
+ untrack(() => {
31610
+ this.preCart = createCart(this.tickets, this.contingent);
31611
+ });
31414
31612
  });
31415
31613
  });
31416
31614
  }
@@ -31421,105 +31619,17 @@ class TicketSegmentDetails {
31421
31619
  preCart: this.preCart
31422
31620
  });
31423
31621
  }
31424
- preCartTickets() {
31425
- switch (this.filters) {
31426
- case "timeslot":
31427
- return this.timeslotTickets;
31428
- case "annual":
31429
- return this.annualTickets;
31430
- case "day":
31431
- return this.dayTickets;
31432
- case "custom":
31433
- return this.tickets;
31434
- case "scaled-price":
31435
- return this.scaledPricesTickets;
31436
- default:
31437
- const exhaustiveCheck = this.filters;
31438
- if (exhaustiveCheck) throw new Error(`(TicketGroup) Unhandled case: ${exhaustiveCheck}`);
31439
- }
31440
- return [];
31441
- }
31442
- get timeslotTickets() {
31443
- const tsd = this.ticketSelectionDetails;
31444
- if (!tsd) return [];
31445
- if (!tsd.selectedDate && !tsd.selectedTimeslot && tsd.filters?.includes("timeslot")) return [];
31446
- const result = snapshot(shop.ticketsAndQuotas({
31447
- by_bookable: true,
31448
- valid_at: tsd.selectedDate?.toString(),
31449
- // @ts-ignore
31450
- "by_ticket_types[]": ["time_slot"],
31451
- "by_museum_ids[]": tsd.museumIds,
31452
- "by_exhibition_ids[]": tsd.exhibitionIds,
31453
- "by_ticket_ids[]": tsd.ticketIds,
31454
- "by_ticket_group_ids[]": tsd.ticketGroupIds
31455
- }));
31456
- if (!result) return [];
31457
- return initUITimeslotTickets(result.tickets);
31458
- }
31459
- get annualTickets() {
31460
- const tsd = this.ticketSelectionDetails;
31461
- if (!tsd) return [];
31462
- if (!tsd.filters?.includes("annual")) return [];
31463
- const tickets = snapshot(shop.tickets({
31464
- by_bookable: true,
31465
- // @ts-ignore
31466
- "by_ticket_types[]": ["annual"],
31467
- "by_ticket_ids[]": tsd.ticketIds,
31468
- "by_ticket_group_ids[]": tsd.ticketGroupIds
31469
- }));
31470
- if (!tickets) return [];
31471
- return initUITimeslotTickets(tickets);
31472
- }
31473
- get dayTickets() {
31474
- const tsd = this.ticketSelectionDetails;
31475
- if (!tsd) return [];
31476
- if (!tsd.filters?.includes("day")) return [];
31477
- const tickets = snapshot(shop.tickets({
31478
- by_bookable: true,
31479
- // @ts-ignore
31480
- "by_ticket_types[]": ["normal"],
31481
- "by_ticket_ids[]": tsd.ticketIds,
31482
- "by_ticket_group_ids[]": tsd.ticketGroupIds
31483
- }));
31484
- if (!tickets) return [];
31485
- return initUITimeslotTickets(tickets);
31486
- }
31487
- get scaledPricesTickets() {
31488
- const tsd = this.ticketSelectionDetails;
31489
- if (!this.ensureScaledPrices()) return [];
31490
- const eid = tsd.eventIds[0];
31491
- const event = snapshot(shop.getEventDetailsOnDate(eid, this.dateId));
31492
- const ret = event?.prices.map((t) => createUIEventTicket(t, this.dateId)) || [];
31493
- const seats = {
31494
- max_per_registration: 2,
31495
- available: 100,
31496
- overbook: true,
31497
- ...event?.seats
31498
- };
31499
- const max_per_registration = seats.max_per_registration || seats.available;
31500
- this.contingent = seats.overbook ? max_per_registration : Math.min(seats.available, max_per_registration);
31501
- return ret;
31502
- }
31503
- ensureScaledPrices() {
31504
- const tsd = this.ticketSelectionDetails;
31505
- if (!tsd) {
31506
- console.warn("(scaledPricesTickets) tsd is undefined");
31507
- return false;
31508
- }
31509
- if (!tsd.eventIds?.length) {
31510
- console.warn("(scaledPricesTickets) eventIds is undefined");
31511
- return false;
31512
- }
31513
- if (!this.filters?.includes("scaled-price")) {
31514
- console.warn("(scaledPricesTickets) filters should include scaled-price");
31515
- return false;
31516
- }
31517
- if (!this.dateId) {
31518
- console.warn("(scaledPricesTickets) date-id is not given to the go-ticket-segment");
31519
- return false;
31520
- }
31521
- if (tsd.eventIds.length > 1) throw new Error("(scaledPricesTickets) currently we support only one eventId in go-ticket-selection");
31522
- return true;
31622
+ loadTickets() {
31623
+ const method = {
31624
+ timeslot: loadTimeslotTickets,
31625
+ annual: loadAnnualTickets,
31626
+ day: loadDayTickets,
31627
+ custom: () => {
31628
+ },
31629
+ "event:scaled-price": loadEventScaledPricesTickets,
31630
+ "event:ticket": loadEventTickets
31631
+ }[this.filters];
31632
+ method(this);
31523
31633
  }
31524
31634
  }
31525
31635
  const KEY = "go-ticket-segment";
@@ -31529,7 +31639,6 @@ function TicketSegment($$anchor, $$props) {
31529
31639
  push($$props, true);
31530
31640
  const filters = prop($$props, "filters", 7), dateId = prop($$props, "dateId", 7);
31531
31641
  if (!filters()) throw new Error("filters is required");
31532
- console.log("TicketSegment: ", filters(), "dateId: ", dateId());
31533
31642
  const tsdWrapper = getTicketSelectionDetails($$props.$$host);
31534
31643
  const details = new TicketSegmentDetails(filters(), tsdWrapper);
31535
31644
  setTicketSegmentDetails($$props.$$host, details);
@@ -31538,7 +31647,6 @@ function TicketSegment($$anchor, $$props) {
31538
31647
  user_effect(() => {
31539
31648
  details.filters = filters();
31540
31649
  details.dateId = dateId();
31541
- console.log("SET DATEID,", dateId());
31542
31650
  });
31543
31651
  var $$exports = {
31544
31652
  details,
@@ -31957,7 +32065,8 @@ class Calendar {
31957
32065
  day: "normal",
31958
32066
  timeslot: "time_slot",
31959
32067
  annual: "annual",
31960
- "scaled-price": "scaled_price"
32068
+ "event:scaled-price": "scaled_price",
32069
+ "event:ticket": "not implemented"
31961
32070
  })[f]);
31962
32071
  }
31963
32072
  params() {
@@ -0,0 +1,44 @@
1
+ import { Capacities } from '@gomus/types';
2
+ export type UICapacities = ReturnType<typeof createCapacities>;
3
+ export declare function createCapacities(apiCapacities: Capacities): {
4
+ apiData: {
5
+ [key: string]: {
6
+ tickets: number[];
7
+ capacities: {
8
+ [key: string]: number;
9
+ };
10
+ total_capacities: {
11
+ [key: string]: number;
12
+ };
13
+ };
14
+ };
15
+ reservations: Record<string, number>;
16
+ setReservation(ticketId: number, timeSlot: string, quantity: number): void;
17
+ getReservation(ticketId: number, timeSlot: string): number;
18
+ /**
19
+ * a flat list of all timeslots and their capacities, considering reservations.
20
+ */
21
+ timeslots(): {
22
+ timeSlot: string;
23
+ quota: string;
24
+ capacity: number;
25
+ tickets: number[];
26
+ }[];
27
+ tickets(ticketId: number): {
28
+ timeslot: string;
29
+ ticket: number;
30
+ quota: string;
31
+ capacity: number;
32
+ }[];
33
+ ticketsByTimeSlot(timeslot: string): {
34
+ timeslot: string;
35
+ ticket: number;
36
+ quota: string;
37
+ capacity: number;
38
+ }[];
39
+ ticketCapacityByTicketAndTimeslot(ticketId: number, timeslot: string): number;
40
+ /**
41
+ * returns the max capacity of a ticket in all timeslots
42
+ */
43
+ ticketCapacityByTicketId(ticketId: number): number;
44
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -10,9 +10,6 @@ export declare function isUIEventTicket(x: Product): x is UIEventTicket;
10
10
  export type UIEventTicket = ReturnType<typeof createUIEventTicket>;
11
11
  export declare function createUIEventTicket(apiTicket: EventScalePriceTicket, dateId: number, options?: Options): {
12
12
  type: UIEventTicketTypes;
13
- max_capacity: number;
14
- min_quantity: number;
15
- max_quantity: number;
16
13
  minAvailableCapacity: number;
17
14
  selectedTime: string;
18
15
  quantity: number;
@@ -31,9 +28,6 @@ export declare function createUIEventTicket(apiTicket: EventScalePriceTicket, da
31
28
  uid: number;
32
29
  } | {
33
30
  type: UIEventTicketTypes;
34
- max_capacity: number;
35
- min_quantity: number;
36
- max_quantity: number;
37
31
  product_type: ProductType;
38
32
  accounting_article_id: number;
39
33
  accounting_article_type: string;
@@ -1,17 +1,15 @@
1
1
  import { Product, ProductType } from '../cart/types.ts';
2
2
  import { AnnualTicket, Ticket, Tickets } from '@gomus/types';
3
3
  interface Options {
4
- minAvailableCapacity?: number;
5
4
  selectedTime?: string;
6
5
  }
7
- export type UITicketType = 'timeslot' | 'annual' | 'day';
6
+ export type UITicketType = 'timeslot' | 'annual' | 'day' | 'event:ticket';
8
7
  export type UITicket = ReturnType<typeof createUITicket>;
9
8
  export declare function isUITicket(x: Product): x is UITicket;
10
9
  export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options?: Options): {
11
10
  product_type: ProductType;
12
11
  type: UITicketType;
13
12
  shop_order: number;
14
- minAvailableCapacity: number;
15
13
  selectedTime: string;
16
14
  id: number;
17
15
  title: string;
@@ -123,7 +121,6 @@ export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options
123
121
  product_type: ProductType;
124
122
  type: UITicketType;
125
123
  shop_order: number;
126
- minAvailableCapacity: number;
127
124
  selectedTime: string;
128
125
  id: number;
129
126
  title: string;
@@ -3,7 +3,7 @@ import { ShopUrls } from '../helpers/urls';
3
3
  import { User } from './user.svelte.ts';
4
4
  import { OpenApiClient } from '@gomus/api';
5
5
  import { TicketsAndQuotasParams, TicketsCalendarParams, TicketsParams } from '@gomus/api/lib/types.ts';
6
- import { CheckoutParams, CheckoutResponse, Country, Event, Exhibition, FinalizePersonalizationParams, FinalizePersonalizationResponse, LocaleOptions, Merchandise, Museum, PasswordResetResponse, Salutation, ShopType, SignInParams, SignInResponse, SignUpParams, SignUpResponse, Tour } from '@gomus/types';
6
+ import { CapacitiesResponse, CheckoutParams, CheckoutResponse, Country, Event, Exhibition, FinalizePersonalizationParams, FinalizePersonalizationResponse, LocaleOptions, Merchandise, Museum, PasswordResetResponse, Salutation, ShopType, SignInParams, SignInResponse, SignUpParams, SignUpResponse, Tour } from '@gomus/types';
7
7
  export type ShopKind = 'angular' | 'jmb';
8
8
  export declare class Shop {
9
9
  #private;
@@ -132,60 +132,50 @@ export declare class Shop {
132
132
  meta: import('@gomus/types').components["schemas"]["meta"];
133
133
  };
134
134
  tickets(params: TicketsParams): {
135
- [key: string]: {
136
- id: number;
137
- title: string;
138
- ticket_type: "time_slot" | "annual" | "normal";
139
- bookable: boolean;
140
- museum_ids: number[];
141
- exhibition_ids: number[];
142
- price_cents: number;
143
- discount: number;
144
- vat_pct: number;
145
- tax_included: boolean;
146
- entry_duration: number | null;
147
- min_persons: number;
148
- max_persons: number;
149
- quota_ids: number[];
150
- first_entry: number;
151
- last_entry: number;
152
- personalizeable: boolean;
153
- attendees: boolean | string;
154
- identification: boolean | string;
155
- free_timing: boolean;
156
- is_collective: boolean;
157
- is_upgrade: boolean;
158
- is_mantle: boolean;
159
- description: string | null;
160
- sub_ticket_ids: number[];
161
- sub_tickets: {
162
- [key: string]: {
163
- title?: string;
164
- min_persons?: number;
165
- max_persons?: number;
166
- description?: string | null;
167
- };
168
- } | null;
169
- is_sub_ticket: boolean;
170
- created_at: string;
171
- updated_at: string;
172
- shop_order: number;
173
- shipped_with_merchandise_id: number | null;
174
- restricted_shop_account: boolean;
175
- cash_point_order: number;
176
- capacities: {
177
- [key: string]: number;
178
- };
179
- total_capacities: {
180
- [key: string]: number;
135
+ id: number;
136
+ title: string;
137
+ ticket_type: "time_slot" | "annual" | "normal";
138
+ bookable: boolean;
139
+ museum_ids: number[];
140
+ exhibition_ids: number[];
141
+ price_cents: number;
142
+ discount: number;
143
+ vat_pct: number;
144
+ tax_included: boolean;
145
+ entry_duration: number | null;
146
+ quota_ids: number[];
147
+ first_entry: number;
148
+ last_entry: number;
149
+ personalizeable: boolean;
150
+ attendees: boolean | string;
151
+ identification: boolean | string;
152
+ free_timing: boolean;
153
+ is_collective: boolean;
154
+ is_upgrade: boolean;
155
+ is_mantle: boolean;
156
+ description: string | null;
157
+ sub_ticket_ids: number[];
158
+ sub_tickets: {
159
+ [key: string]: {
160
+ title?: string;
161
+ min_persons?: number;
162
+ max_persons?: number;
163
+ description?: string | null;
181
164
  };
182
- max_capacity: number;
183
- max_total_capacity: number;
184
- dynamic_prices: {
185
- [key: string]: number;
186
- } | null;
187
- };
188
- };
165
+ } | null;
166
+ is_sub_ticket: boolean;
167
+ created_at: string;
168
+ updated_at: string;
169
+ cash_point_order: number;
170
+ shop_order: number;
171
+ shipped_with_merchandise_id: number | null;
172
+ restricted_shop_account: boolean;
173
+ min_persons: number;
174
+ max_persons: number;
175
+ dynamic_prices?: {
176
+ [key: string]: number;
177
+ } | null;
178
+ }[];
189
179
  signIn(params: SignInParams): Promise<SignInResponse>;
190
180
  signUp(params: SignUpParams, asGuest?: boolean): Promise<SignUpResponse>;
191
181
  passwordReset(params: {
@@ -337,6 +327,7 @@ export declare class Shop {
337
327
  documents: import('@gomus/types').components["schemas"]["document"][];
338
328
  content: Record<string, never>;
339
329
  };
330
+ getTicketCapacities(date: string, ticketIds: number[]): Promise<CapacitiesResponse>;
340
331
  getEventDetailsOnDate(eventId: number, dateId: number): {
341
332
  id?: number;
342
333
  event_id?: number;
@@ -11,7 +11,12 @@ export declare const MSWMocks: {
11
11
  mockAnnualOrder: () => void;
12
12
  mockCountries: () => void;
13
13
  mockPersonalizationFormSubmit: () => void;
14
+ tickets: {
15
+ mockTwoTickets: (options?: Record<string, any>) => void;
16
+ mockOneTicketCapacity: (options?: Record<string, any>) => void;
17
+ };
14
18
  events: {
15
19
  mockTwoScaledPrices: (options?: Record<string, any>) => void;
20
+ mockTwoTickets: (options?: Record<string, any>) => void;
16
21
  };
17
22
  };