@cosmoops/connect-sdk 0.37.0 → 0.40.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 (47) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/cjs/client/components/availability-form.js +103 -0
  3. package/dist/cjs/client/components/create-workspace-form.js +66 -0
  4. package/dist/cjs/client/components/event-type-form.js +156 -0
  5. package/dist/cjs/client/components/user-menu.js +3 -24
  6. package/dist/cjs/client/components/workspace-switcher.js +42 -9
  7. package/dist/cjs/client/index.js +31 -3
  8. package/dist/cjs/client/portal-links.js +38 -0
  9. package/dist/cjs/client/use-scheduling.js +104 -8
  10. package/dist/cjs/client/use-workspaces.js +41 -0
  11. package/dist/cjs/server/client.js +1 -1
  12. package/dist/cjs/server/handler.js +181 -2
  13. package/dist/cjs/server/http.js +13 -1
  14. package/dist/cjs/server/resources/ai.js +6 -0
  15. package/dist/cjs/server/resources/scheduling.js +129 -0
  16. package/dist/cjs/server/resources/visitor.js +6 -0
  17. package/dist/cjs/server/resources/workspaces.js +30 -11
  18. package/dist/esm/client/components/availability-form.js +100 -0
  19. package/dist/esm/client/components/create-workspace-form.js +63 -0
  20. package/dist/esm/client/components/event-type-form.js +153 -0
  21. package/dist/esm/client/components/user-menu.js +3 -24
  22. package/dist/esm/client/components/workspace-switcher.js +42 -9
  23. package/dist/esm/client/index.js +17 -1
  24. package/dist/esm/client/portal-links.js +34 -0
  25. package/dist/esm/client/use-scheduling.js +98 -8
  26. package/dist/esm/client/use-workspaces.js +38 -0
  27. package/dist/esm/server/client.js +1 -1
  28. package/dist/esm/server/handler.js +181 -2
  29. package/dist/esm/server/http.js +12 -1
  30. package/dist/esm/server/resources/ai.js +7 -1
  31. package/dist/esm/server/resources/scheduling.js +129 -0
  32. package/dist/esm/server/resources/visitor.js +7 -1
  33. package/dist/esm/server/resources/workspaces.js +30 -11
  34. package/dist/types/client/components/availability-form.d.ts +33 -0
  35. package/dist/types/client/components/create-workspace-form.d.ts +32 -0
  36. package/dist/types/client/components/event-type-form.d.ts +44 -0
  37. package/dist/types/client/components/workspace-switcher.d.ts +9 -9
  38. package/dist/types/client/index.d.ts +10 -1
  39. package/dist/types/client/portal-links.d.ts +22 -0
  40. package/dist/types/client/use-scheduling.d.ts +93 -1
  41. package/dist/types/client/use-workspaces.d.ts +27 -0
  42. package/dist/types/server/client.d.ts +1 -1
  43. package/dist/types/server/http.d.ts +35 -0
  44. package/dist/types/server/resources/scheduling.d.ts +131 -1
  45. package/dist/types/server/resources/workspaces.d.ts +28 -0
  46. package/dist/types/types.d.ts +60 -0
  47. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { type TransportOptions } from "../http.js";
2
- import type { BookableEventType, Booking, RescheduledBooking, BookingAttendee, BookingSlots, BookingStatus, ListBookingsPage } from "../../types.js";
2
+ import type { AvailabilitySchedule, BookableEventType, Booking, ManageableEventType, RescheduledBooking, BookingAttendee, BookingSlots, BookingStatus, ListBookingsPage, WeeklyHours } from "../../types.js";
3
3
  /**
4
4
  * Present on every method here.
5
5
  *
@@ -56,6 +56,84 @@ export interface ListBookingsInput extends ActingAsOption {
56
56
  cursor?: string;
57
57
  limit?: number;
58
58
  }
59
+ export interface ListSchedulesInput extends ActingAsOption {
60
+ workspaceId: string;
61
+ }
62
+ /**
63
+ * What `createSchedule` takes - deliberately narrower than Connect's own
64
+ * Calendar settings form: no date overrides, and never owned by one person.
65
+ * Anything beyond this is a Console edit, not a second write path to
66
+ * maintain.
67
+ */
68
+ export interface CreateScheduleInput extends ActingAsOption {
69
+ workspaceId: string;
70
+ name: string;
71
+ /** Validated against the IANA database server-side, e.g. `"Asia/Kolkata"`. */
72
+ timezone: string;
73
+ weeklyHours: WeeklyHours;
74
+ }
75
+ /**
76
+ * What `createEventType` takes.
77
+ *
78
+ * Host is a specific member, never a team - there is no groups read in this
79
+ * API, so a round-robin team host stays a Console-only capability, reachable
80
+ * by following "Manage in Connect".
81
+ */
82
+ export interface CreateEventTypeInput extends ActingAsOption {
83
+ workspaceId: string;
84
+ name: string;
85
+ description?: string | null;
86
+ /** 5 to 480 minutes. */
87
+ durationMinutes: number;
88
+ /** Dead time reserved either side of the meeting. Both default to 5. */
89
+ bufferBeforeMinutes?: number;
90
+ bufferAfterMinutes?: number;
91
+ /** A `ConnectWorkspaceMember.memberId` - see `Booking.hostMemberIds`. */
92
+ hostMemberId: string;
93
+ scheduleId: string;
94
+ location: {
95
+ kind: "phone" | "address" | "link";
96
+ value?: string | null;
97
+ };
98
+ /** Off by default - most appointment types are booked by your integration or a member, not the public. */
99
+ publicBookingEnabled?: boolean;
100
+ }
101
+ /**
102
+ * What `updateSchedule` takes. Every field optional - send only what changed.
103
+ * `ownerMemberId` and date overrides are not settable from this surface at
104
+ * all, so an edit can never touch them.
105
+ */
106
+ export interface UpdateScheduleInput extends ActingAsOption {
107
+ workspaceId: string;
108
+ scheduleId: string;
109
+ name?: string;
110
+ timezone?: string;
111
+ weeklyHours?: WeeklyHours;
112
+ }
113
+ /**
114
+ * What `updateEventType` takes. Every field optional - send only what
115
+ * changed. `hostMemberId` omitted leaves the host untouched, including a
116
+ * *group* host this surface cannot represent; sending one always rewrites to
117
+ * a member host, by design.
118
+ */
119
+ export interface UpdateEventTypeInput extends ActingAsOption {
120
+ workspaceId: string;
121
+ eventTypeId: string;
122
+ name?: string;
123
+ description?: string | null;
124
+ durationMinutes?: number;
125
+ bufferBeforeMinutes?: number;
126
+ bufferAfterMinutes?: number;
127
+ hostMemberId?: string;
128
+ scheduleId?: string;
129
+ location?: {
130
+ kind: "phone" | "address" | "link";
131
+ value?: string | null;
132
+ };
133
+ publicBookingEnabled?: boolean;
134
+ /** Take an appointment type out of (or back into) service. */
135
+ active?: boolean;
136
+ }
59
137
  export interface CreateBookingInput extends ActingAsOption {
60
138
  workspaceId: string;
61
139
  eventTypeId: string;
@@ -88,6 +166,58 @@ export declare class SchedulingResource {
88
166
  constructor(transport: TransportOptions);
89
167
  /** What this workspace offers as bookable. Active appointment types only. */
90
168
  listEventTypes(workspaceId: string, options?: ActingAsOption): Promise<BookableEventType[]>;
169
+ /**
170
+ * The working-hours templates an appointment type can point at.
171
+ *
172
+ * Read this before offering to create one - a workspace that already has
173
+ * hours set does not need a second "Working hours" from your integration.
174
+ */
175
+ listSchedules(workspaceId: string, options?: ActingAsOption): Promise<AvailabilitySchedule[]>;
176
+ /**
177
+ * Gives a workspace its first working hours.
178
+ *
179
+ * Narrower than what the workspace's own Calendar settings can do - no date
180
+ * overrides, and never owned by one person (`ownerMemberId` stays `null`
181
+ * server-side). Anything beyond that is a Console edit, not a second write
182
+ * path for your integration to maintain.
183
+ */
184
+ createSchedule(input: CreateScheduleInput): Promise<AvailabilitySchedule>;
185
+ /**
186
+ * The first thing a workspace can be booked for.
187
+ *
188
+ * Needs a schedule - create or pick one with `listSchedules`/`createSchedule`
189
+ * first. The slug for a future public booking link is derived from `name`
190
+ * server-side; you cannot choose one.
191
+ *
192
+ * Answers the richer *manageable* shape, not `BookableEventType` - you just
193
+ * created this row and are about to manage it, not book against it.
194
+ */
195
+ createEventType(input: CreateEventTypeInput): Promise<ManageableEventType>;
196
+ /**
197
+ * The richer read `createEventType`/`updateEventType`'s edit mode needs -
198
+ * everything `listEventTypes`'s booking catalogue deliberately withholds,
199
+ * because this is the opposite audience: a member managing their own
200
+ * calendar, not a widget rendering someone else's. Includes inactive rows,
201
+ * since an edit screen is exactly where one gets reactivated.
202
+ */
203
+ listManageableEventTypes(workspaceId: string, options?: ActingAsOption): Promise<ManageableEventType[]>;
204
+ /**
205
+ * Edits an existing availability schedule.
206
+ *
207
+ * Narrower than what the workspace's own Calendar settings can do, the
208
+ * same way `createSchedule` is: `ownerMemberId` and date overrides stay
209
+ * untouched, since this surface never sets either.
210
+ */
211
+ updateSchedule(input: UpdateScheduleInput): Promise<AvailabilitySchedule>;
212
+ /**
213
+ * Edits an existing appointment type.
214
+ *
215
+ * `hostMemberId` omitted leaves the host untouched, including a *group*
216
+ * host this surface cannot represent - so an edit that says nothing about
217
+ * the host can never accidentally overwrite a team assignment made in
218
+ * Connect.
219
+ */
220
+ updateEventType(input: UpdateEventTypeInput): Promise<ManageableEventType>;
91
221
  /**
92
222
  * Free times for one appointment type over one window.
93
223
  *
@@ -11,6 +11,10 @@ import type { ConnectInvitation, ConnectMemberAccess, ConnectMemberAccessResult,
11
11
  * `createConnectHandler`, and it is why a partner cannot enumerate another
12
12
  * tenant's team with their own API key.
13
13
  */
14
+ export interface CreateUserWorkspaceInput {
15
+ name: string;
16
+ type: "individual" | "business";
17
+ }
14
18
  export declare class WorkspacesResource {
15
19
  private readonly transport;
16
20
  constructor(transport: TransportOptions);
@@ -24,6 +28,30 @@ export declare class WorkspacesResource {
24
28
  list(options: {
25
29
  asUser: string;
26
30
  }): Promise<UserWorkspace[]>;
31
+ /**
32
+ * Opens another workspace under the tenant the signed-in user already
33
+ * owns - a branch office, a second business unit.
34
+ *
35
+ * Every guard `CreateWorkspaceUseCase` enforces still applies: only the
36
+ * tenant's owner may call this, `type: "business"` still needs a non-free
37
+ * email domain, and the tenant's plan still decides whether it may hold
38
+ * another workspace at all - a `PreconditionError` surfaces as a thrown
39
+ * `ConnectError` with a message written to be shown ("Your current plan
40
+ * covers a single workspace...", "You've used all 3 of the workspaces
41
+ * your plans include..."). There is no `tenantId` parameter: the caller
42
+ * names no tenant, same as every other method on this resource names no
43
+ * workspace.
44
+ *
45
+ * `isActive`/`subscribed` on the result are always `false` - this does not
46
+ * switch the session, and the new workspace has no subscription yet. Chain
47
+ * `switch({workspaceId: result.workspaceId})` to move into it, but only
48
+ * when `result.inAudience` - a workspace outside this application's
49
+ * audience is refused by `switch` the same way `selectable()` in
50
+ * `<ConnectWorkspaceSwitcher>` already treats it.
51
+ */
52
+ create(input: CreateUserWorkspaceInput, options: {
53
+ asUser: string;
54
+ }): Promise<UserWorkspace>;
27
55
  /**
28
56
  * Moves this session to another workspace, returning a **new session
29
57
  * token**. The one you passed is revoked.
@@ -2003,6 +2003,66 @@ export interface ListBookingsPage {
2003
2003
  hasMore: boolean;
2004
2004
  totalCount: number;
2005
2005
  }
2006
+ /**
2007
+ * One interval within a day, in minutes since midnight - `540` is 9am.
2008
+ */
2009
+ export interface WeeklyInterval {
2010
+ startMinute: number;
2011
+ endMinute: number;
2012
+ }
2013
+ /**
2014
+ * A week of working hours, one entry per weekday - `0` is Sunday. An empty
2015
+ * array means closed that day; every key is required, so "closed on Sunday"
2016
+ * is an array the caller had to mean rather than a key they forgot.
2017
+ */
2018
+ export interface WeeklyHours {
2019
+ 0: WeeklyInterval[];
2020
+ 1: WeeklyInterval[];
2021
+ 2: WeeklyInterval[];
2022
+ 3: WeeklyInterval[];
2023
+ 4: WeeklyInterval[];
2024
+ 5: WeeklyInterval[];
2025
+ 6: WeeklyInterval[];
2026
+ }
2027
+ /** A working-hours template an appointment type points at. */
2028
+ export interface AvailabilitySchedule {
2029
+ id: string;
2030
+ name: string;
2031
+ timezone: string;
2032
+ weeklyHours: WeeklyHours;
2033
+ }
2034
+ /**
2035
+ * One appointment type, as a management UI sees it - richer than
2036
+ * `BookableEventType`'s booking-catalogue shape, which deliberately
2037
+ * withholds `location.value` and everything else here. Fetched from
2038
+ * `listManageableEventTypes`, never the booking flow's `listEventTypes`.
2039
+ *
2040
+ * `host` collapses a group host to `{kind:"group"}` with nothing else -
2041
+ * there is no groups read in this API, so a team host is representable only
2042
+ * as "not this, edit it in Connect".
2043
+ */
2044
+ export interface ManageableEventType {
2045
+ id: string;
2046
+ slug: string;
2047
+ name: string;
2048
+ description: string | null;
2049
+ durationMinutes: number;
2050
+ bufferBeforeMinutes: number;
2051
+ bufferAfterMinutes: number;
2052
+ host: {
2053
+ kind: "member";
2054
+ memberId: string;
2055
+ } | {
2056
+ kind: "group";
2057
+ };
2058
+ scheduleId: string;
2059
+ location: {
2060
+ kind: "phone" | "address" | "link";
2061
+ value: string | null;
2062
+ };
2063
+ active: boolean;
2064
+ publicBookingEnabled: boolean;
2065
+ }
2006
2066
  /**
2007
2067
  * A phone or email on a contact.
2008
2068
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoops/connect-sdk",
3
- "version": "0.37.0",
3
+ "version": "0.40.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",