@withaevum/sdk 1.2.0 → 1.3.2

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.
package/dist/client.d.ts CHANGED
@@ -3,8 +3,10 @@ import { BookingsAPI } from './bookings';
3
3
  import { OfferingsAPI } from './offerings';
4
4
  import { CustomersAPI } from './customers';
5
5
  import { ProvidersAPI } from './providers';
6
+ import { OrgsAPI } from './orgs';
6
7
  import { CalendarAPI } from './calendar';
7
8
  import { AnalyticsAPI } from './analytics';
9
+ import { PaymentsAPI } from './payments';
8
10
  import type { AevumClientConfig } from './types';
9
11
  /**
10
12
  * Main client class for interacting with the Aevum API
@@ -19,8 +21,10 @@ export declare class AevumClient {
19
21
  readonly offerings: OfferingsAPI;
20
22
  readonly customers: CustomersAPI;
21
23
  readonly providers: ProvidersAPI;
24
+ readonly orgs: OrgsAPI;
22
25
  readonly calendar: CalendarAPI;
23
26
  readonly analytics: AnalyticsAPI;
27
+ readonly payments: PaymentsAPI;
24
28
  constructor(config: AevumClientConfig);
25
29
  /**
26
30
  * Resolve organization ID from API key (cached after first call)
package/dist/client.js CHANGED
@@ -4,8 +4,10 @@ import { BookingsAPI } from './bookings';
4
4
  import { OfferingsAPI } from './offerings';
5
5
  import { CustomersAPI } from './customers';
6
6
  import { ProvidersAPI } from './providers';
7
+ import { OrgsAPI } from './orgs';
7
8
  import { CalendarAPI } from './calendar';
8
9
  import { AnalyticsAPI } from './analytics';
10
+ import { PaymentsAPI } from './payments';
9
11
  import { AevumAPIError, AevumAuthenticationError, AevumNotFoundError, AevumValidationError, } from './errors';
10
12
  /**
11
13
  * Main client class for interacting with the Aevum API
@@ -18,7 +20,7 @@ export class AevumClient {
18
20
  throw new Error('API key is required');
19
21
  }
20
22
  this.apiKey = config.apiKey;
21
- this.baseUrl = config.baseUrl || 'https://api.withaevum.com';
23
+ this.baseUrl = config.baseUrl || 'https://withaevum.com';
22
24
  // Set orgId if provided in config (avoids extra API call)
23
25
  if (config.orgId) {
24
26
  this.orgId = config.orgId;
@@ -29,8 +31,10 @@ export class AevumClient {
29
31
  this.offerings = new OfferingsAPI(this);
30
32
  this.customers = new CustomersAPI(this);
31
33
  this.providers = new ProvidersAPI(this);
34
+ this.orgs = new OrgsAPI(this);
32
35
  this.calendar = new CalendarAPI(this);
33
36
  this.analytics = new AnalyticsAPI(this);
37
+ this.payments = new PaymentsAPI(this);
34
38
  }
35
39
  /**
36
40
  * Resolve organization ID from API key (cached after first call)
@@ -122,17 +126,21 @@ export class AevumClient {
122
126
  }
123
127
  // Handle errors
124
128
  if (!response.ok) {
125
- const errorData = data;
129
+ // Safely extract error data, handling null/undefined cases
130
+ const errorData = (data && typeof data === 'object') ? data : null;
131
+ const errorMessage = errorData?.error || `API request failed with status ${response.status}`;
132
+ const errorCode = errorData?.code;
133
+ const errorIssues = errorData?.issues;
126
134
  if (response.status === 401 || response.status === 403) {
127
- throw new AevumAuthenticationError(errorData.error || 'Authentication failed', response.status);
135
+ throw new AevumAuthenticationError(errorMessage, response.status);
128
136
  }
129
137
  if (response.status === 404) {
130
- throw new AevumNotFoundError(errorData.error || 'Resource not found');
138
+ throw new AevumNotFoundError(errorMessage);
131
139
  }
132
140
  if (response.status === 400) {
133
- throw new AevumValidationError(errorData.error || 'Validation error', errorData.issues);
141
+ throw new AevumValidationError(errorMessage, errorIssues);
134
142
  }
135
- throw new AevumAPIError(errorData.error || `API request failed with status ${response.status}`, response.status, errorData.code, errorData.issues);
143
+ throw new AevumAPIError(errorMessage, response.status, errorCode, errorIssues);
136
144
  }
137
145
  return data;
138
146
  }
@@ -1,5 +1,5 @@
1
1
  import { AevumClient } from './client';
2
- import type { Customer, CreateCustomerParams, ListCustomersParams, ListCustomersResponse, CustomerHistoryResponse } from './types';
2
+ import type { Customer, CreateCustomerParams, UpdateCustomerParams, ListCustomersParams, ListCustomersResponse, CustomerHistoryResponse } from './types';
3
3
  /**
4
4
  * Customers API methods
5
5
  */
@@ -18,6 +18,10 @@ export declare class CustomersAPI {
18
18
  * Create a new customer (or merge if email exists)
19
19
  */
20
20
  create(params: CreateCustomerParams): Promise<Customer>;
21
+ /**
22
+ * Update an existing customer
23
+ */
24
+ update(customerId: string, params: UpdateCustomerParams): Promise<Customer>;
21
25
  /**
22
26
  * Get customer booking history with analytics
23
27
  */
package/dist/customers.js CHANGED
@@ -51,6 +51,23 @@ export class CustomersAPI {
51
51
  const response = await this.client.request('POST', '/api/v1/orgs/{orgId}/customers', { body });
52
52
  return response.customer;
53
53
  }
54
+ /**
55
+ * Update an existing customer
56
+ */
57
+ async update(customerId, params) {
58
+ const body = {};
59
+ if (params.name !== undefined) {
60
+ body.name = params.name;
61
+ }
62
+ if (params.email !== undefined) {
63
+ body.email = params.email;
64
+ }
65
+ if (params.phone !== undefined) {
66
+ body.phone = params.phone;
67
+ }
68
+ const response = await this.client.request('PATCH', `/api/v1/orgs/{orgId}/customers/${customerId}`, { body });
69
+ return response.customer;
70
+ }
54
71
  /**
55
72
  * Get customer booking history with analytics
56
73
  */
package/dist/index.d.ts CHANGED
@@ -3,8 +3,10 @@ export { BookingsAPI } from './bookings';
3
3
  export { OfferingsAPI } from './offerings';
4
4
  export { CustomersAPI } from './customers';
5
5
  export { ProvidersAPI } from './providers';
6
+ export { OrgsAPI } from './orgs';
6
7
  export { CalendarAPI } from './calendar';
7
8
  export { AnalyticsAPI } from './analytics';
8
9
  export { AvailabilityAPI } from './availability';
10
+ export { PaymentsAPI } from './payments';
9
11
  export * from './types';
10
12
  export * from './errors';
package/dist/index.js CHANGED
@@ -4,8 +4,10 @@ export { BookingsAPI } from './bookings';
4
4
  export { OfferingsAPI } from './offerings';
5
5
  export { CustomersAPI } from './customers';
6
6
  export { ProvidersAPI } from './providers';
7
+ export { OrgsAPI } from './orgs';
7
8
  export { CalendarAPI } from './calendar';
8
9
  export { AnalyticsAPI } from './analytics';
9
10
  export { AvailabilityAPI } from './availability';
11
+ export { PaymentsAPI } from './payments';
10
12
  export * from './types';
11
13
  export * from './errors';
@@ -1,5 +1,5 @@
1
1
  import { AevumClient } from './client';
2
- import type { Offering, CreateOfferingParams, ListOfferingsParams, CreateSimpleOfferingParams, CreateRecurringWeeklyOfferingParams, CreateRecurringDailyOfferingParams, CreateSimpleOfferingEndpointParams } from './types';
2
+ import type { Offering, CreateOfferingParams, UpdateOfferingParams, ListOfferingsParams, CreateSimpleOfferingParams, CreateRecurringWeeklyOfferingParams, CreateRecurringDailyOfferingParams, CreateSimpleOfferingEndpointParams } from './types';
3
3
  /**
4
4
  * Offerings API methods
5
5
  */
@@ -14,6 +14,14 @@ export declare class OfferingsAPI {
14
14
  * Get a single offering by ID
15
15
  */
16
16
  get(offeringId: string): Promise<Offering>;
17
+ /**
18
+ * Update an existing offering
19
+ */
20
+ update(offeringId: string, params: UpdateOfferingParams): Promise<Offering>;
21
+ /**
22
+ * Delete an offering
23
+ */
24
+ delete(offeringId: string): Promise<void>;
17
25
  /**
18
26
  * Create a new offering
19
27
  */
package/dist/offerings.js CHANGED
@@ -73,6 +73,88 @@ export class OfferingsAPI {
73
73
  const response = await this.client.request('GET', `/api/v1/orgs/{orgId}/offerings/${offeringId}`);
74
74
  return response.offering;
75
75
  }
76
+ /**
77
+ * Update an existing offering
78
+ */
79
+ async update(offeringId, params) {
80
+ const body = {};
81
+ if (params.name !== undefined)
82
+ body.name = params.name;
83
+ if (params.description !== undefined)
84
+ body.description = params.description;
85
+ if (params.price_cents !== undefined)
86
+ body.price_cents = params.price_cents;
87
+ if (params.duration_minutes !== undefined)
88
+ body.duration_minutes = params.duration_minutes;
89
+ if (params.timezone !== undefined)
90
+ body.timezone = params.timezone;
91
+ if (params.is_all_day !== undefined)
92
+ body.is_all_day = params.is_all_day;
93
+ if (params.attendee_mode !== undefined)
94
+ body.attendee_mode = params.attendee_mode;
95
+ if (params.attendee_limit !== undefined)
96
+ body.attendee_limit = params.attendee_limit;
97
+ if (params.customer !== undefined)
98
+ body.customer = params.customer;
99
+ if (params.status !== undefined)
100
+ body.status = params.status;
101
+ if (params.type !== undefined)
102
+ body.type = params.type;
103
+ if (params.time_mode !== undefined)
104
+ body.time_mode = params.time_mode;
105
+ if (params.start_time !== undefined)
106
+ body.start_time = params.start_time;
107
+ if (params.end_time !== undefined)
108
+ body.end_time = params.end_time;
109
+ if (params.session_count !== undefined)
110
+ body.session_count = params.session_count;
111
+ if (params.recurrence_preset !== undefined)
112
+ body.recurrence_preset = params.recurrence_preset;
113
+ if (params.recurrence_interval_count !== undefined)
114
+ body.recurrence_interval_count = params.recurrence_interval_count;
115
+ if (params.recurrence_interval_unit !== undefined)
116
+ body.recurrence_interval_unit = params.recurrence_interval_unit;
117
+ if (params.recurrence_repeat_on !== undefined)
118
+ body.recurrence_repeat_on = params.recurrence_repeat_on;
119
+ if (params.recurrence_end_mode !== undefined)
120
+ body.recurrence_end_mode = params.recurrence_end_mode;
121
+ if (params.recurrence_end_date !== undefined)
122
+ body.recurrence_end_date = params.recurrence_end_date;
123
+ if (params.recurrence_end_count !== undefined)
124
+ body.recurrence_end_count = params.recurrence_end_count;
125
+ if (params.override_price_cents !== undefined)
126
+ body.override_price_cents = params.override_price_cents;
127
+ if (params.min_age !== undefined)
128
+ body.min_age = params.min_age;
129
+ if (params.max_age !== undefined)
130
+ body.max_age = params.max_age;
131
+ if (params.window_start_time !== undefined)
132
+ body.window_start_time = params.window_start_time;
133
+ if (params.window_end_time !== undefined)
134
+ body.window_end_time = params.window_end_time;
135
+ if (params.cadence_minutes !== undefined)
136
+ body.cadence_minutes = params.cadence_minutes;
137
+ if (params.slot_days !== undefined)
138
+ body.slot_days = params.slot_days;
139
+ if (params.auto_confirm !== undefined)
140
+ body.auto_confirm = params.auto_confirm;
141
+ if (params.providerIds !== undefined)
142
+ body.providerIds = params.providerIds;
143
+ if (params.hours !== undefined)
144
+ body.hours = params.hours;
145
+ if (params.weekly_hours !== undefined)
146
+ body.weekly_hours = params.weekly_hours;
147
+ if (params.monthly_recurrence !== undefined)
148
+ body.monthly_recurrence = params.monthly_recurrence;
149
+ const response = await this.client.request('PATCH', `/api/v1/orgs/{orgId}/offerings/${offeringId}`, { body });
150
+ return response.offering;
151
+ }
152
+ /**
153
+ * Delete an offering
154
+ */
155
+ async delete(offeringId) {
156
+ await this.client.request('DELETE', `/api/v1/orgs/{orgId}/offerings/${offeringId}`);
157
+ }
76
158
  /**
77
159
  * Create a new offering
78
160
  */
package/dist/orgs.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { AevumClient } from './client';
2
+ import type { Org, BookingSettings, UpdateBookingSettingsParams } from './types';
3
+ /**
4
+ * Organization API – org details for embedding, booking config, etc.
5
+ */
6
+ export declare class OrgsAPI {
7
+ private client;
8
+ constructor(client: AevumClient);
9
+ /**
10
+ * Get organization by ID (requires API key auth).
11
+ * Returns org details including slug for public booking URLs.
12
+ */
13
+ get(): Promise<Org>;
14
+ /**
15
+ * Get booking settings for the organization
16
+ * Returns booking configuration including safe period hours
17
+ */
18
+ getBookingSettings(): Promise<BookingSettings>;
19
+ /**
20
+ * Update booking settings for the organization
21
+ * Allows updating the safe period hours (minimum time before bookings can be made)
22
+ */
23
+ updateBookingSettings(params: UpdateBookingSettingsParams): Promise<BookingSettings>;
24
+ }
package/dist/orgs.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Organization API – org details for embedding, booking config, etc.
3
+ */
4
+ export class OrgsAPI {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get organization by ID (requires API key auth).
10
+ * Returns org details including slug for public booking URLs.
11
+ */
12
+ async get() {
13
+ const response = await this.client.request('GET', '/api/v1/orgs/{orgId}');
14
+ return response;
15
+ }
16
+ /**
17
+ * Get booking settings for the organization
18
+ * Returns booking configuration including safe period hours
19
+ */
20
+ async getBookingSettings() {
21
+ return this.client.request('GET', '/api/v1/orgs/{orgId}/settings/booking');
22
+ }
23
+ /**
24
+ * Update booking settings for the organization
25
+ * Allows updating the safe period hours (minimum time before bookings can be made)
26
+ */
27
+ async updateBookingSettings(params) {
28
+ return this.client.request('PATCH', '/api/v1/orgs/{orgId}/settings/booking', { body: params });
29
+ }
30
+ }
@@ -0,0 +1,33 @@
1
+ import type { AevumClient } from './client';
2
+ export interface PaymentIntentDetails {
3
+ paymentIntentId: string;
4
+ clientSecret: string | null;
5
+ amount: number;
6
+ status: string;
7
+ }
8
+ export interface UpdatePaymentIntentParams {
9
+ paymentIntentId: string;
10
+ tipAmountCents: number;
11
+ bookingId?: string;
12
+ }
13
+ export interface UpdatePaymentIntentResult {
14
+ success: boolean;
15
+ paymentIntentId: string;
16
+ amount: number;
17
+ clientSecret: string | null;
18
+ }
19
+ /**
20
+ * Payments API for managing payment intents
21
+ */
22
+ export declare class PaymentsAPI {
23
+ private readonly client;
24
+ constructor(client: AevumClient);
25
+ /**
26
+ * Get payment intent details including client secret
27
+ */
28
+ getIntent(paymentIntentId: string): Promise<PaymentIntentDetails>;
29
+ /**
30
+ * Update payment intent with tip amount
31
+ */
32
+ updateIntent(params: UpdatePaymentIntentParams): Promise<UpdatePaymentIntentResult>;
33
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Payments API for managing payment intents
3
+ */
4
+ export class PaymentsAPI {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get payment intent details including client secret
10
+ */
11
+ async getIntent(paymentIntentId) {
12
+ return this.client.request('GET', '/api/payments/intent', {
13
+ query: {
14
+ payment_intent_id: paymentIntentId,
15
+ },
16
+ });
17
+ }
18
+ /**
19
+ * Update payment intent with tip amount
20
+ */
21
+ async updateIntent(params) {
22
+ return this.client.request('POST', '/api/payments/update-intent', {
23
+ body: params,
24
+ });
25
+ }
26
+ }
package/dist/types.d.ts CHANGED
@@ -9,6 +9,30 @@ export interface AevumClientConfig {
9
9
  /** Organization ID (optional, will be resolved from API key if not provided) */
10
10
  orgId?: string;
11
11
  }
12
+ /**
13
+ * Organization (from GET /api/v1/orgs/:orgId)
14
+ */
15
+ export interface Org {
16
+ id: string;
17
+ name: string | null;
18
+ slug: string | null;
19
+ timezone: string | null;
20
+ clerk_org_id: string | null;
21
+ }
22
+ /**
23
+ * Booking settings for an organization
24
+ */
25
+ export interface BookingSettings {
26
+ /** Safe period in hours - no bookings allowed within this period (default: 24) */
27
+ safePeriodHours: number;
28
+ }
29
+ /**
30
+ * Parameters for updating booking settings
31
+ */
32
+ export interface UpdateBookingSettingsParams {
33
+ /** Safe period in hours (0-168, default: 24) */
34
+ safePeriodHours?: number;
35
+ }
12
36
  /**
13
37
  * Customer information
14
38
  */
@@ -211,6 +235,7 @@ export interface Offering {
211
235
  window_end_time?: string | null;
212
236
  cadence_minutes?: number | null;
213
237
  slot_days?: string | null;
238
+ auto_confirm?: boolean;
214
239
  hours?: any;
215
240
  weekly_hours?: any;
216
241
  monthly_recurrence?: any;
@@ -252,11 +277,18 @@ export interface CreateOfferingParams {
252
277
  window_end_time?: string;
253
278
  cadence_minutes?: number | null;
254
279
  slot_days?: string;
280
+ auto_confirm?: boolean;
255
281
  providerIds?: string[];
256
282
  hours?: any;
257
283
  weekly_hours?: any;
258
284
  monthly_recurrence?: any;
259
285
  }
286
+ /**
287
+ * Parameters for updating an offering (all fields optional)
288
+ */
289
+ export type UpdateOfferingParams = Partial<Omit<CreateOfferingParams, 'name'>> & {
290
+ name?: string;
291
+ };
260
292
  /**
261
293
  * Parameters for listing offerings
262
294
  */
@@ -380,6 +412,14 @@ export interface CreateCustomerParams {
380
412
  phone?: string | null;
381
413
  userId?: string | null;
382
414
  }
415
+ /**
416
+ * Parameters for updating a customer
417
+ */
418
+ export interface UpdateCustomerParams {
419
+ name?: string | null;
420
+ email?: string | null;
421
+ phone?: string | null;
422
+ }
383
423
  /**
384
424
  * Parameters for listing customers
385
425
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withaevum/sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.2",
4
4
  "description": "TypeScript SDK for the Aevum API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",