@aranova/tracking-next 0.20.1 → 0.21.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 (42) hide show
  1. package/README.md +80 -1
  2. package/dist/blog-server.js +6 -3
  3. package/dist/blog-server.js.map +1 -1
  4. package/dist/blog-server.mjs +6 -3
  5. package/dist/blog-server.mjs.map +1 -1
  6. package/dist/blog.js +4 -2
  7. package/dist/blog.js.map +1 -1
  8. package/dist/blog.mjs +4 -2
  9. package/dist/blog.mjs.map +1 -1
  10. package/dist/calendar-server.d.mts +53 -0
  11. package/dist/calendar-server.d.ts +53 -0
  12. package/dist/calendar-server.js +206 -0
  13. package/dist/calendar-server.js.map +1 -0
  14. package/dist/calendar-server.mjs +180 -0
  15. package/dist/calendar-server.mjs.map +1 -0
  16. package/dist/calendar.d.mts +112 -0
  17. package/dist/calendar.d.ts +112 -0
  18. package/dist/calendar.js +517 -0
  19. package/dist/calendar.js.map +1 -0
  20. package/dist/calendar.mjs +457 -0
  21. package/dist/calendar.mjs.map +1 -0
  22. package/dist/date-BHetnL7s.d.mts +26 -0
  23. package/dist/date-BHetnL7s.d.ts +26 -0
  24. package/dist/index.d.mts +60 -3
  25. package/dist/index.d.ts +60 -3
  26. package/dist/index.js +511 -18
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +474 -18
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/request-Doq36Rt0.d.mts +19 -0
  31. package/dist/request-Doq36Rt0.d.ts +19 -0
  32. package/dist/{sales-DrH6dY5F.d.mts → sales-B3BnYncU.d.mts} +5 -44
  33. package/dist/{sales-DrH6dY5F.d.ts → sales-CDjXRdmd.d.ts} +5 -44
  34. package/dist/sales.d.mts +3 -1
  35. package/dist/sales.d.ts +3 -1
  36. package/dist/sales.js +22 -17
  37. package/dist/sales.js.map +1 -1
  38. package/dist/sales.mjs +22 -17
  39. package/dist/sales.mjs.map +1 -1
  40. package/dist/transport-Bku8zftU.d.mts +721 -0
  41. package/dist/transport-DsOY6kcW.d.ts +721 -0
  42. package/package.json +22 -1
@@ -0,0 +1,112 @@
1
+ import { A as AranovaApiError } from './date-BHetnL7s.mjs';
2
+ export { f as formatDateInTz } from './date-BHetnL7s.mjs';
3
+ import { r as CalendarSummary, m as BusyResponse, C as CalendarTransportConfig, q as CalendarErrorCode, d as BusyInterval } from './transport-Bku8zftU.mjs';
4
+ export { e as BOOKING_SOURCES, f as BOOKING_STATUSES, a as Booking, g as BookingAttendee, c as BookingCancelInput, B as BookingCreateInput, h as BookingCustomer, i as BookingLocation, j as BookingMetadata, k as BookingReminders, b as BookingRescheduleInput, l as BookingStatus, n as CALENDAR_ERROR_CODES, o as CALENDAR_METADATA_SCHEMA_VERSION, p as CALENDAR_SYNC_STATUSES, s as CalendarSyncStatus, G as GOOGLE_SYNC_STATES, t as GoogleSyncState, J as JsonScalar, M as MAX_ATTENDEES, u as MAX_BOOKING_MINUTES, v as MAX_REMINDER_MINUTES, w as MAX_REMINDER_OVERRIDES, x as bookingAttendeeSchema, y as bookingCancelSchema, z as bookingCreateSchema, A as bookingCustomerSchema, D as bookingLocationNullableSchema, E as bookingLocationSchema, F as bookingMetadataSchema, H as bookingReminderSchema, I as bookingRemindersSchema, K as bookingRescheduleSchema } from './transport-Bku8zftU.mjs';
5
+ import 'zod';
6
+ import './request-Doq36Rt0.mjs';
7
+
8
+ /**
9
+ * The browser-side calendar client — reads only.
10
+ *
11
+ * There is deliberately no write verb on this type. A public key ships in a JS
12
+ * bundle and its Origin allowlist is a browser-enforced header a script forges
13
+ * trivially; a booking is not a database row but an event on a real person's
14
+ * calendar that mails their contacts. Writes live in
15
+ * `@aranova/tracking-next/calendar-server`, which is `server-only`.
16
+ */
17
+ interface CalendarReadClientConfig extends CalendarTransportConfig {
18
+ /** Falls back to the visitor's own zone. */
19
+ defaultTimeZone?: string;
20
+ /** Required when the key is not already scoped to one business. */
21
+ businessId?: string;
22
+ }
23
+ interface BusyQuery {
24
+ /**
25
+ * ISO 8601 instants WITH an offset — the API rejects a naive or date-only
26
+ * value with a 400. `startOfDayInTz`/`endOfDayInTz` turn a picked date into
27
+ * the right pair for a given zone.
28
+ */
29
+ since: string;
30
+ until: string;
31
+ timeZone?: string;
32
+ }
33
+ interface CalendarReadClient<TCalendarKey extends string = string> {
34
+ /** Labels, timezones and status — everything a widget needs before booking. */
35
+ listCalendars(): Promise<CalendarSummary[]>;
36
+ /** Busy intervals only. Never the contents of the grantee's events. */
37
+ busy(calendarKey: TCalendarKey, query: BusyQuery): Promise<BusyResponse>;
38
+ }
39
+ declare function createCalendarReadClient<TCalendarKey extends string = string>(config: CalendarReadClientConfig): CalendarReadClient<TCalendarKey>;
40
+ /** Narrow an unknown error to a specific calendar failure code. */
41
+ declare function isCalendarError(error: unknown, code?: CalendarErrorCode): error is AranovaApiError;
42
+
43
+ /** The visitor's own zone, so a booking page defaults to their local times. */
44
+ declare function resolveBrowserTimeZone(): string;
45
+ /** Offset in minutes between UTC and `timeZone` at a given instant. */
46
+ declare function offsetMinutesAt(date: Date, timeZone: string): number;
47
+ /**
48
+ * The instant matching a wall-clock time in `timeZone`.
49
+ *
50
+ * Two passes because the offset itself depends on the instant: guess with the
51
+ * offset at the naive time, then re-solve with the offset that guess landed in.
52
+ * That second pass is what makes DST-transition days come out right.
53
+ */
54
+ declare function instantFromWallClock(timeZone: string, year: number, month: number, day: number, hour?: number, minute?: number): Date;
55
+ /** `YYYY-MM-DD` for an instant as seen in `timeZone`. */
56
+ declare function localDateKey(iso: string, timeZone: string): string;
57
+ declare function startOfDayInTz(dateKey: string, timeZone: string): Date;
58
+ declare function endOfDayInTz(dateKey: string, timeZone: string): Date;
59
+ declare function durationMinutes(startIso: string, endIso: string): number;
60
+ /** `10:00 – 10:30` in the given zone. */
61
+ declare function formatSlotRange(startIso: string, endIso: string, timeZone: string, locale?: string): string;
62
+
63
+ /**
64
+ * Slot computation lives in the client site, not in our database.
65
+ *
66
+ * Opening hours, slot length, notice and buffers differ per client and per use
67
+ * case; modelling them as dashboard config would mean every new client needs
68
+ * data entry before their site works. The API answers only "when is this person
69
+ * busy" — this pure helper turns that plus the site's own hours into offerable
70
+ * slots.
71
+ */
72
+ interface OpeningInterval {
73
+ /** Local wall-clock `HH:MM` in the calendar's zone. */
74
+ start: string;
75
+ end: string;
76
+ }
77
+ interface OpeningHours {
78
+ /** 0 = Sunday … 6 = Saturday. A missing weekday is closed. */
79
+ weekly: Partial<Record<number, OpeningInterval[]>>;
80
+ /** `YYYY-MM-DD` → intervals, replacing that day's weekly rule entirely. */
81
+ overrides?: Record<string, OpeningInterval[]>;
82
+ /** `YYYY-MM-DD` dates that are closed regardless of the weekly rule. */
83
+ closedDates?: string[];
84
+ }
85
+ interface ComputeSlotsOptions {
86
+ busy: BusyInterval[];
87
+ openingHours: OpeningHours;
88
+ timeZone: string;
89
+ durationMinutes: number;
90
+ granularityMinutes?: number;
91
+ minNoticeMinutes?: number;
92
+ bufferBeforeMinutes?: number;
93
+ bufferAfterMinutes?: number;
94
+ windowDays?: number;
95
+ now?: Date;
96
+ }
97
+ interface Slot {
98
+ start_at: string;
99
+ end_at: string;
100
+ }
101
+ interface ComputeSlotsResult {
102
+ slots: Slot[];
103
+ nextAvailableAt: string | null;
104
+ }
105
+ declare function computeSlots(options: ComputeSlotsOptions): ComputeSlotsResult;
106
+ /** Group slots by local date, the shape every date-picker UI wants. */
107
+ declare function groupSlotsByDay(slots: Slot[], timeZone: string): {
108
+ date: string;
109
+ slots: Slot[];
110
+ }[];
111
+
112
+ export { AranovaApiError, BusyInterval, type BusyQuery, BusyResponse, CalendarErrorCode, type CalendarReadClient, type CalendarReadClientConfig, CalendarSummary, CalendarTransportConfig, type ComputeSlotsOptions, type ComputeSlotsResult, type OpeningHours, type OpeningInterval, type Slot, computeSlots, createCalendarReadClient, durationMinutes, endOfDayInTz, formatSlotRange, groupSlotsByDay, instantFromWallClock, isCalendarError, localDateKey, offsetMinutesAt, resolveBrowserTimeZone, startOfDayInTz };
@@ -0,0 +1,112 @@
1
+ import { A as AranovaApiError } from './date-BHetnL7s.js';
2
+ export { f as formatDateInTz } from './date-BHetnL7s.js';
3
+ import { r as CalendarSummary, m as BusyResponse, C as CalendarTransportConfig, q as CalendarErrorCode, d as BusyInterval } from './transport-DsOY6kcW.js';
4
+ export { e as BOOKING_SOURCES, f as BOOKING_STATUSES, a as Booking, g as BookingAttendee, c as BookingCancelInput, B as BookingCreateInput, h as BookingCustomer, i as BookingLocation, j as BookingMetadata, k as BookingReminders, b as BookingRescheduleInput, l as BookingStatus, n as CALENDAR_ERROR_CODES, o as CALENDAR_METADATA_SCHEMA_VERSION, p as CALENDAR_SYNC_STATUSES, s as CalendarSyncStatus, G as GOOGLE_SYNC_STATES, t as GoogleSyncState, J as JsonScalar, M as MAX_ATTENDEES, u as MAX_BOOKING_MINUTES, v as MAX_REMINDER_MINUTES, w as MAX_REMINDER_OVERRIDES, x as bookingAttendeeSchema, y as bookingCancelSchema, z as bookingCreateSchema, A as bookingCustomerSchema, D as bookingLocationNullableSchema, E as bookingLocationSchema, F as bookingMetadataSchema, H as bookingReminderSchema, I as bookingRemindersSchema, K as bookingRescheduleSchema } from './transport-DsOY6kcW.js';
5
+ import 'zod';
6
+ import './request-Doq36Rt0.js';
7
+
8
+ /**
9
+ * The browser-side calendar client — reads only.
10
+ *
11
+ * There is deliberately no write verb on this type. A public key ships in a JS
12
+ * bundle and its Origin allowlist is a browser-enforced header a script forges
13
+ * trivially; a booking is not a database row but an event on a real person's
14
+ * calendar that mails their contacts. Writes live in
15
+ * `@aranova/tracking-next/calendar-server`, which is `server-only`.
16
+ */
17
+ interface CalendarReadClientConfig extends CalendarTransportConfig {
18
+ /** Falls back to the visitor's own zone. */
19
+ defaultTimeZone?: string;
20
+ /** Required when the key is not already scoped to one business. */
21
+ businessId?: string;
22
+ }
23
+ interface BusyQuery {
24
+ /**
25
+ * ISO 8601 instants WITH an offset — the API rejects a naive or date-only
26
+ * value with a 400. `startOfDayInTz`/`endOfDayInTz` turn a picked date into
27
+ * the right pair for a given zone.
28
+ */
29
+ since: string;
30
+ until: string;
31
+ timeZone?: string;
32
+ }
33
+ interface CalendarReadClient<TCalendarKey extends string = string> {
34
+ /** Labels, timezones and status — everything a widget needs before booking. */
35
+ listCalendars(): Promise<CalendarSummary[]>;
36
+ /** Busy intervals only. Never the contents of the grantee's events. */
37
+ busy(calendarKey: TCalendarKey, query: BusyQuery): Promise<BusyResponse>;
38
+ }
39
+ declare function createCalendarReadClient<TCalendarKey extends string = string>(config: CalendarReadClientConfig): CalendarReadClient<TCalendarKey>;
40
+ /** Narrow an unknown error to a specific calendar failure code. */
41
+ declare function isCalendarError(error: unknown, code?: CalendarErrorCode): error is AranovaApiError;
42
+
43
+ /** The visitor's own zone, so a booking page defaults to their local times. */
44
+ declare function resolveBrowserTimeZone(): string;
45
+ /** Offset in minutes between UTC and `timeZone` at a given instant. */
46
+ declare function offsetMinutesAt(date: Date, timeZone: string): number;
47
+ /**
48
+ * The instant matching a wall-clock time in `timeZone`.
49
+ *
50
+ * Two passes because the offset itself depends on the instant: guess with the
51
+ * offset at the naive time, then re-solve with the offset that guess landed in.
52
+ * That second pass is what makes DST-transition days come out right.
53
+ */
54
+ declare function instantFromWallClock(timeZone: string, year: number, month: number, day: number, hour?: number, minute?: number): Date;
55
+ /** `YYYY-MM-DD` for an instant as seen in `timeZone`. */
56
+ declare function localDateKey(iso: string, timeZone: string): string;
57
+ declare function startOfDayInTz(dateKey: string, timeZone: string): Date;
58
+ declare function endOfDayInTz(dateKey: string, timeZone: string): Date;
59
+ declare function durationMinutes(startIso: string, endIso: string): number;
60
+ /** `10:00 – 10:30` in the given zone. */
61
+ declare function formatSlotRange(startIso: string, endIso: string, timeZone: string, locale?: string): string;
62
+
63
+ /**
64
+ * Slot computation lives in the client site, not in our database.
65
+ *
66
+ * Opening hours, slot length, notice and buffers differ per client and per use
67
+ * case; modelling them as dashboard config would mean every new client needs
68
+ * data entry before their site works. The API answers only "when is this person
69
+ * busy" — this pure helper turns that plus the site's own hours into offerable
70
+ * slots.
71
+ */
72
+ interface OpeningInterval {
73
+ /** Local wall-clock `HH:MM` in the calendar's zone. */
74
+ start: string;
75
+ end: string;
76
+ }
77
+ interface OpeningHours {
78
+ /** 0 = Sunday … 6 = Saturday. A missing weekday is closed. */
79
+ weekly: Partial<Record<number, OpeningInterval[]>>;
80
+ /** `YYYY-MM-DD` → intervals, replacing that day's weekly rule entirely. */
81
+ overrides?: Record<string, OpeningInterval[]>;
82
+ /** `YYYY-MM-DD` dates that are closed regardless of the weekly rule. */
83
+ closedDates?: string[];
84
+ }
85
+ interface ComputeSlotsOptions {
86
+ busy: BusyInterval[];
87
+ openingHours: OpeningHours;
88
+ timeZone: string;
89
+ durationMinutes: number;
90
+ granularityMinutes?: number;
91
+ minNoticeMinutes?: number;
92
+ bufferBeforeMinutes?: number;
93
+ bufferAfterMinutes?: number;
94
+ windowDays?: number;
95
+ now?: Date;
96
+ }
97
+ interface Slot {
98
+ start_at: string;
99
+ end_at: string;
100
+ }
101
+ interface ComputeSlotsResult {
102
+ slots: Slot[];
103
+ nextAvailableAt: string | null;
104
+ }
105
+ declare function computeSlots(options: ComputeSlotsOptions): ComputeSlotsResult;
106
+ /** Group slots by local date, the shape every date-picker UI wants. */
107
+ declare function groupSlotsByDay(slots: Slot[], timeZone: string): {
108
+ date: string;
109
+ slots: Slot[];
110
+ }[];
111
+
112
+ export { AranovaApiError, BusyInterval, type BusyQuery, BusyResponse, CalendarErrorCode, type CalendarReadClient, type CalendarReadClientConfig, CalendarSummary, CalendarTransportConfig, type ComputeSlotsOptions, type ComputeSlotsResult, type OpeningHours, type OpeningInterval, type Slot, computeSlots, createCalendarReadClient, durationMinutes, endOfDayInTz, formatSlotRange, groupSlotsByDay, instantFromWallClock, isCalendarError, localDateKey, offsetMinutesAt, resolveBrowserTimeZone, startOfDayInTz };