@cosmoops/connect-sdk 0.17.0 → 0.19.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 (31) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +20 -1
  3. package/dist/cjs/client/components/booking-calendar.js +170 -0
  4. package/dist/cjs/client/components/booking-dialogs.js +124 -0
  5. package/dist/cjs/client/components/booking-grid.js +206 -0
  6. package/dist/cjs/client/index.js +15 -1
  7. package/dist/cjs/client/use-scheduling.js +113 -0
  8. package/dist/cjs/server/client.js +5 -1
  9. package/dist/cjs/server/handler.js +136 -0
  10. package/dist/cjs/server/resources/contacts.js +66 -0
  11. package/dist/cjs/server/resources/scheduling.js +32 -1
  12. package/dist/esm/client/components/booking-calendar.js +167 -0
  13. package/dist/esm/client/components/booking-dialogs.js +120 -0
  14. package/dist/esm/client/components/booking-grid.js +199 -0
  15. package/dist/esm/client/index.js +4 -0
  16. package/dist/esm/client/use-scheduling.js +107 -0
  17. package/dist/esm/server/client.js +5 -1
  18. package/dist/esm/server/handler.js +136 -0
  19. package/dist/esm/server/resources/contacts.js +62 -0
  20. package/dist/esm/server/resources/scheduling.js +32 -1
  21. package/dist/types/client/components/booking-calendar.d.ts +38 -0
  22. package/dist/types/client/components/booking-dialogs.d.ts +33 -0
  23. package/dist/types/client/components/booking-grid.d.ts +102 -0
  24. package/dist/types/client/index.d.ts +5 -0
  25. package/dist/types/client/use-scheduling.d.ts +93 -0
  26. package/dist/types/server/client.d.ts +4 -1
  27. package/dist/types/server/index.d.ts +2 -1
  28. package/dist/types/server/resources/contacts.d.ts +60 -0
  29. package/dist/types/server/resources/scheduling.d.ts +51 -6
  30. package/dist/types/types.d.ts +58 -0
  31. package/package.json +1 -1
@@ -1,13 +1,45 @@
1
1
  import { type TransportOptions } from "../http.js";
2
- import type { BookableEventType, Booking, BookingAttendee, BookingSlots, BookingStatus, ListBookingsPage } from "../../types.js";
3
- export interface FindSlotsInput {
2
+ import type { BookableEventType, Booking, RescheduledBooking, BookingAttendee, BookingSlots, BookingStatus, ListBookingsPage } from "../../types.js";
3
+ /**
4
+ * Present on every method here.
5
+ *
6
+ * With `asUser`, Connect derives the workspace from **that member's session**
7
+ * and ignores `workspaceId`, then checks their own `calendar:read` /
8
+ * `calendar:manage`. Without it the call is your server acting for a workspace
9
+ * you name, gated only on your application being installed there. The bridge
10
+ * always sends it - a browser must never be trusted to name a tenant, and an
11
+ * end user of your app is not automatically allowed to book on their
12
+ * employer's calendar.
13
+ */
14
+ export interface ActingAsOption {
15
+ /** The signed-in member's opaque Connect session token. */
16
+ asUser?: string;
17
+ }
18
+ export interface FindSlotsInput extends ActingAsOption {
4
19
  workspaceId: string;
5
20
  eventTypeId: string;
6
21
  /** ISO-8601 instant, or a `Date`. */
7
22
  from: string | Date;
8
23
  to: string | Date;
24
+ /**
25
+ * A booking to treat as if it were not there - **set this when offering
26
+ * times to move an existing appointment to.**
27
+ *
28
+ * Without it the appointment counts as blocking its own replacement, so the
29
+ * adjustment people actually make - same day, half an hour later - comes
30
+ * back with nothing available.
31
+ */
32
+ excludeBookingId?: string;
9
33
  }
10
- export interface ListBookingsInput {
34
+ export interface RescheduleBookingInput extends ActingAsOption {
35
+ workspaceId: string;
36
+ bookingId: string;
37
+ /** The new time, from a `findSlots` result, passed back unchanged. */
38
+ startAt: string | Date;
39
+ /** Replaces the original note when given; it carries over otherwise. */
40
+ notes?: string | null;
41
+ }
42
+ export interface ListBookingsInput extends ActingAsOption {
11
43
  workspaceId: string;
12
44
  status?: BookingStatus;
13
45
  /** A Connect workspace member id - only bookings that committed them. */
@@ -19,7 +51,7 @@ export interface ListBookingsInput {
19
51
  cursor?: string;
20
52
  limit?: number;
21
53
  }
22
- export interface CreateBookingInput {
54
+ export interface CreateBookingInput extends ActingAsOption {
23
55
  workspaceId: string;
24
56
  eventTypeId: string;
25
57
  /**
@@ -50,7 +82,7 @@ export declare class SchedulingResource {
50
82
  private readonly transport;
51
83
  constructor(transport: TransportOptions);
52
84
  /** What this workspace offers as bookable. Active appointment types only. */
53
- listEventTypes(workspaceId: string): Promise<BookableEventType[]>;
85
+ listEventTypes(workspaceId: string, options?: ActingAsOption): Promise<BookableEventType[]>;
54
86
  /**
55
87
  * Free times for one appointment type over one window.
56
88
  *
@@ -76,6 +108,19 @@ export declare class SchedulingResource {
76
108
  * a `ConnectError` with `code: "conflict"` rather than double-booking.
77
109
  */
78
110
  createBooking(input: CreateBookingInput): Promise<Booking>;
111
+ /**
112
+ * Moves an appointment to a different time.
113
+ *
114
+ * **The original is retired, not edited.** It stays on the diary as
115
+ * `rescheduled` with `rescheduledToId` pointing at the replacement, and both
116
+ * come back here - so a booking id you cached still resolves, and still says
117
+ * where the appointment went.
118
+ *
119
+ * A refused move changes nothing: the new slot is claimed before the old one
120
+ * is released, so a `conflict` leaves the customer with the appointment they
121
+ * already had. Re-read the slots (with `excludeBookingId`) and offer another.
122
+ */
123
+ rescheduleBooking(input: RescheduleBookingInput): Promise<RescheduledBooking>;
79
124
  /**
80
125
  * Frees the slot and records why.
81
126
  *
@@ -83,7 +128,7 @@ export declare class SchedulingResource {
83
128
  * reason, which is what makes a late cancellation something anyone can look
84
129
  * up afterwards.
85
130
  */
86
- cancelBooking(input: {
131
+ cancelBooking(input: ActingAsOption & {
87
132
  workspaceId: string;
88
133
  bookingId: string;
89
134
  reason?: string | null;
@@ -1202,8 +1202,21 @@ export interface Booking {
1202
1202
  notes: string | null;
1203
1203
  source: BookingSource;
1204
1204
  cancelledReason: string | null;
1205
+ /**
1206
+ * Set when `status` is `rescheduled` - the booking that replaced this one.
1207
+ *
1208
+ * Rescheduling retires a booking rather than moving its `startAt`, so an id
1209
+ * you cached still resolves and still tells you where the appointment went.
1210
+ */
1211
+ rescheduledToId: string | null;
1205
1212
  createdAt: string;
1206
1213
  }
1214
+ export interface RescheduledBooking {
1215
+ /** The new appointment. This is the live one. */
1216
+ booking: Booking;
1217
+ /** The retired original, now `rescheduled` and pointing at `booking`. */
1218
+ previous: Booking;
1219
+ }
1207
1220
  export interface ListBookingsPage {
1208
1221
  bookings: Booking[];
1209
1222
  /** Pass back as `cursor`. A cursor belongs to one set of filters. */
@@ -1211,3 +1224,48 @@ export interface ListBookingsPage {
1211
1224
  hasMore: boolean;
1212
1225
  totalCount: number;
1213
1226
  }
1227
+ /**
1228
+ * A phone or email on a contact.
1229
+ *
1230
+ * `verified` means a human confirmed it reaches them - only a manual source
1231
+ * may ever set it. Branch on it: an unverified value is one an extraction
1232
+ * heard on a call and nobody has checked since.
1233
+ */
1234
+ export interface ContactChannelValue {
1235
+ value: string;
1236
+ label: string | null;
1237
+ verified: boolean;
1238
+ }
1239
+ /**
1240
+ * How a contact came to exist. `call` means a voice agent created it from an
1241
+ * inbound call; `manual` and `import` are the two a human stands behind.
1242
+ */
1243
+ export type ContactSource = "call" | "manual" | "import" | "api" | "extraction";
1244
+ /**
1245
+ * Someone a workspace knows how to reach - **the telephony identity**, not a
1246
+ * CRM record. See `ContactsResource` for why the difference decides whether
1247
+ * you reference this or copy it.
1248
+ */
1249
+ export interface ConnectContact {
1250
+ id: string;
1251
+ /** E.164, and immutable - the key this contact is identified by. */
1252
+ primaryPhone: string;
1253
+ phones: ContactChannelValue[];
1254
+ emails: ContactChannelValue[];
1255
+ name: {
1256
+ display: string | null;
1257
+ given: string | null;
1258
+ family: string | null;
1259
+ };
1260
+ business: {
1261
+ company: string | null;
1262
+ role: string | null;
1263
+ gstin: string | null;
1264
+ website: string | null;
1265
+ address: string | null;
1266
+ };
1267
+ tags: string[];
1268
+ source: ContactSource;
1269
+ createdAt: string;
1270
+ updatedAt: string;
1271
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoops/connect-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Official server-side SDK for the CosmoOps Connect platform API - Login with Connect, entitlements, billing and metering.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",