@withaevum/sdk 1.3.0 → 1.3.3

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,22 @@ 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
+ // Default baseUrl: use provided, or check env var (Node.js only), or use production
24
+ if (config.baseUrl) {
25
+ this.baseUrl = config.baseUrl;
26
+ }
27
+ else if (typeof process !== 'undefined' && process.env?.AEVUM_API_BASE_URL) {
28
+ // Check environment variable if in Node.js
29
+ this.baseUrl = process.env.AEVUM_API_BASE_URL;
30
+ }
31
+ else if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development') {
32
+ // Default to localhost in development
33
+ this.baseUrl = 'http://localhost:3000';
34
+ }
35
+ else {
36
+ // Production default
37
+ this.baseUrl = 'https://withaevum.com';
38
+ }
22
39
  // Set orgId if provided in config (avoids extra API call)
23
40
  if (config.orgId) {
24
41
  this.orgId = config.orgId;
@@ -29,8 +46,10 @@ export class AevumClient {
29
46
  this.offerings = new OfferingsAPI(this);
30
47
  this.customers = new CustomersAPI(this);
31
48
  this.providers = new ProvidersAPI(this);
49
+ this.orgs = new OrgsAPI(this);
32
50
  this.calendar = new CalendarAPI(this);
33
51
  this.analytics = new AnalyticsAPI(this);
52
+ this.payments = new PaymentsAPI(this);
34
53
  }
35
54
  /**
36
55
  * Resolve organization ID from API key (cached after first call)
@@ -122,17 +141,21 @@ export class AevumClient {
122
141
  }
123
142
  // Handle errors
124
143
  if (!response.ok) {
125
- const errorData = data;
144
+ // Safely extract error data, handling null/undefined cases
145
+ const errorData = (data && typeof data === 'object') ? data : null;
146
+ const errorMessage = errorData?.error || `API request failed with status ${response.status}`;
147
+ const errorCode = errorData?.code;
148
+ const errorIssues = errorData?.issues;
126
149
  if (response.status === 401 || response.status === 403) {
127
- throw new AevumAuthenticationError(errorData.error || 'Authentication failed', response.status);
150
+ throw new AevumAuthenticationError(errorMessage, response.status);
128
151
  }
129
152
  if (response.status === 404) {
130
- throw new AevumNotFoundError(errorData.error || 'Resource not found');
153
+ throw new AevumNotFoundError(errorMessage);
131
154
  }
132
155
  if (response.status === 400) {
133
- throw new AevumValidationError(errorData.error || 'Validation error', errorData.issues);
156
+ throw new AevumValidationError(errorMessage, errorIssues);
134
157
  }
135
- throw new AevumAPIError(errorData.error || `API request failed with status ${response.status}`, response.status, errorData.code, errorData.issues);
158
+ throw new AevumAPIError(errorMessage, response.status, errorCode, errorIssues);
136
159
  }
137
160
  return data;
138
161
  }
@@ -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';
package/dist/offerings.js CHANGED
@@ -136,6 +136,8 @@ export class OfferingsAPI {
136
136
  body.cadence_minutes = params.cadence_minutes;
137
137
  if (params.slot_days !== undefined)
138
138
  body.slot_days = params.slot_days;
139
+ if (params.auto_confirm !== undefined)
140
+ body.auto_confirm = params.auto_confirm;
139
141
  if (params.providerIds !== undefined)
140
142
  body.providerIds = params.providerIds;
141
143
  if (params.hours !== undefined)
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,6 +277,7 @@ 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;
@@ -386,6 +412,14 @@ export interface CreateCustomerParams {
386
412
  phone?: string | null;
387
413
  userId?: string | null;
388
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
+ }
389
423
  /**
390
424
  * Parameters for listing customers
391
425
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withaevum/sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.3",
4
4
  "description": "TypeScript SDK for the Aevum API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,6 +46,7 @@
46
46
  "access": "public"
47
47
  },
48
48
  "devDependencies": {
49
+ "@types/node": "^25.2.1",
49
50
  "typescript": "^5.6.3"
50
51
  }
51
52
  }