@terros-inc/sdk 1.0.4 → 1.0.6

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 (56) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.d.mts +1028 -0
  3. package/dist/index.mjs +224 -0
  4. package/package.json +11 -12
  5. package/dist/analytics.d.ts +0 -8
  6. package/dist/analytics.js +0 -22
  7. package/dist/apiCaller.d.ts +0 -12
  8. package/dist/apiCaller.js +0 -44
  9. package/dist/client.d.ts +0 -8
  10. package/dist/client.js +0 -13
  11. package/dist/client.test.d.ts +0 -1
  12. package/dist/client.test.js +0 -81
  13. package/dist/clients/account.d.ts +0 -24
  14. package/dist/clients/account.js +0 -53
  15. package/dist/clients/calendar.d.ts +0 -21
  16. package/dist/clients/calendar.js +0 -44
  17. package/dist/clients/index.d.ts +0 -3
  18. package/dist/clients/index.js +0 -3
  19. package/dist/clients/user.d.ts +0 -18
  20. package/dist/clients/user.js +0 -42
  21. package/dist/index.d.ts +0 -2
  22. package/dist/index.js +0 -2
  23. package/dist/models/account/api.d.ts +0 -167
  24. package/dist/models/account/api.js +0 -1
  25. package/dist/models/account/index.d.ts +0 -2
  26. package/dist/models/account/index.js +0 -2
  27. package/dist/models/account/model.d.ts +0 -219
  28. package/dist/models/account/model.js +0 -1
  29. package/dist/models/calendar/api.d.ts +0 -122
  30. package/dist/models/calendar/api.js +0 -1
  31. package/dist/models/calendar/index.d.ts +0 -2
  32. package/dist/models/calendar/index.js +0 -2
  33. package/dist/models/calendar/model.d.ts +0 -83
  34. package/dist/models/calendar/model.js +0 -1
  35. package/dist/models/company/index.d.ts +0 -1
  36. package/dist/models/company/index.js +0 -1
  37. package/dist/models/company/model.d.ts +0 -37
  38. package/dist/models/company/model.js +0 -1
  39. package/dist/models/index.d.ts +0 -7
  40. package/dist/models/index.js +0 -7
  41. package/dist/models/location/index.d.ts +0 -1
  42. package/dist/models/location/index.js +0 -1
  43. package/dist/models/location/model.d.ts +0 -21
  44. package/dist/models/location/model.js +0 -1
  45. package/dist/models/shared.d.ts +0 -32
  46. package/dist/models/shared.js +0 -6
  47. package/dist/models/team/index.d.ts +0 -1
  48. package/dist/models/team/index.js +0 -1
  49. package/dist/models/team/model.d.ts +0 -17
  50. package/dist/models/team/model.js +0 -1
  51. package/dist/models/user/api.d.ts +0 -111
  52. package/dist/models/user/api.js +0 -1
  53. package/dist/models/user/index.d.ts +0 -2
  54. package/dist/models/user/index.js +0 -2
  55. package/dist/models/user/model.d.ts +0 -179
  56. package/dist/models/user/model.js +0 -1
@@ -0,0 +1,1028 @@
1
+ //#region src/models/team/model.d.ts
2
+ type TinyTeam = {
3
+ teamId: TeamId;
4
+ name: string;
5
+ parentId?: TeamId;
6
+ isDeleted?: boolean;
7
+ externalId?: string;
8
+ avatarBlurhash?: string;
9
+ avatarUrl?: string;
10
+ restrictVisibility?: boolean;
11
+ level: number;
12
+ meetingTimes?: {
13
+ day: number;
14
+ start: number;
15
+ end: number;
16
+ }[];
17
+ };
18
+ //#endregion
19
+ //#region src/models/location/model.d.ts
20
+ type LatLng = {
21
+ latitude: number;
22
+ longitude: number;
23
+ };
24
+ type Address = {
25
+ country: 'US' | 'CA' | 'PR';
26
+ countrySubd: string;
27
+ line1: string;
28
+ line2: string;
29
+ locality: string;
30
+ oneLine: string;
31
+ postal1: string;
32
+ postal2?: string;
33
+ postal3?: string;
34
+ unitNbr?: string;
35
+ };
36
+ type SmallAddress = Pick<Address, 'countrySubd' | 'line1' | 'locality' | 'postal1' | 'postal2' | 'postal3' | 'unitNbr'> & {
37
+ line2?: string;
38
+ oneLine?: string;
39
+ latlng: LatLng;
40
+ };
41
+ //#endregion
42
+ //#region src/models/company/model.d.ts
43
+ type CompanyState = 'active' | 'trial' | 'internal' | 'demo' | 'sandbox' | 'template' | 'suspended';
44
+ type CompanyKind = 'customer' | 'sandbox' | 'demo' | 'template' | 'development';
45
+ type AccessStatus = 'active' | 'suspended';
46
+ type BillingMethod = 'stripe' | 'none';
47
+ type CompanyIndustry = 'solar' | 'pest' | 'alarm' | 'roofing' | 'fiber' | 'insurance' | 'home_improvement' | 'windows' | 'satellite_tv' | 'retail' | 'other' | 'solar_cleaning';
48
+ type CompanyId = `C:${string}` | `C.${string}`;
49
+ type CompanyData = {
50
+ companyId: CompanyId;
51
+ name: string;
52
+ legalName?: string;
53
+ kind?: CompanyKind;
54
+ accessStatus?: AccessStatus;
55
+ internalOwnerId?: UserId;
56
+ billingEmail?: string;
57
+ billingMethod?: BillingMethod;
58
+ state: CompanyState;
59
+ maxUsers?: number;
60
+ size?: number;
61
+ industries?: CompanyIndustry[];
62
+ salesChannels?: string[];
63
+ highestTeamLevel?: number;
64
+ lowestTeamLevel?: number;
65
+ levelNames?: Record<string, string>;
66
+ timeZone?: string;
67
+ avatarUrl?: string;
68
+ avatarBlurhash?: string;
69
+ uploadAvatarUrl?: string;
70
+ iconUrl?: string;
71
+ iconBlurhash?: string;
72
+ uploadIconUrl?: string;
73
+ isDeleted?: boolean;
74
+ createdAt?: number;
75
+ createdBy?: UserId;
76
+ updatedAt?: number;
77
+ updatedBy?: UserId;
78
+ };
79
+ //#endregion
80
+ //#region src/models/user/model.d.ts
81
+ type UserId = `U:${string}` | `U.${string}`;
82
+ type TeamId = `Team:${string}` | `Team.${string}`;
83
+ type RoleId = `Role.${string}`;
84
+ /** A user ID, email, or clientUserId. */
85
+ type UserIdentifier = string;
86
+ type CloserStatus = 'None' | 'Needs_Help' | 'Can_Close' | 'Can_Help' | 'Closer_Only';
87
+ type TinyRole = {
88
+ roleId: RoleId;
89
+ roleType: 'admin' | 'manager' | 'recruit' | null;
90
+ name: string;
91
+ };
92
+ type TinyUser = {
93
+ userId: UserId;
94
+ clientUserId?: string;
95
+ firstName: string;
96
+ lastName: string;
97
+ preferredName?: string;
98
+ avatarBlurhash?: string;
99
+ avatarUrl?: string;
100
+ lastAccess?: number;
101
+ isDeleted?: boolean;
102
+ color?: string;
103
+ };
104
+ type SmallUser = TinyUser & {
105
+ email: string;
106
+ phone?: string;
107
+ title?: string;
108
+ timeZone?: string;
109
+ teamIds?: TeamId[];
110
+ closerStatus?: CloserStatus;
111
+ roles?: TinyRole[];
112
+ memberOf?: Pick<TinyTeam, 'teamId' | 'name'>[];
113
+ companyId?: CompanyId;
114
+ };
115
+ type Weekday = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
116
+ type CloserSettings = {
117
+ order?: number;
118
+ taskLockout?: boolean;
119
+ bookingPercent?: number;
120
+ meetingDuration?: number;
121
+ timeBetweenAppointments?: number;
122
+ serviceCenter?: {
123
+ latitude: number;
124
+ longitude: number;
125
+ };
126
+ serviceRadius?: number;
127
+ minimumNotice?: number;
128
+ maximumNotice?: number;
129
+ timeslots?: Partial<Record<Weekday, number[]>>;
130
+ excludes?: number[];
131
+ includes?: number[];
132
+ lastUpdatedDate?: number;
133
+ };
134
+ type TinyCloser = {
135
+ user: TinyUser;
136
+ times: {
137
+ startTime: number;
138
+ duration: number;
139
+ }[];
140
+ };
141
+ type SmallCloser = TinyUser & CloserSettings & {
142
+ timezone: string;
143
+ };
144
+ type AvailableCloser = TinyUser & {
145
+ inServiceArea?: boolean;
146
+ available: boolean;
147
+ locked?: boolean;
148
+ unavailableReason?: string;
149
+ };
150
+ type UserScope = {
151
+ entity: 'self' | 'company' | 'withinRestrictions' | 'none';
152
+ } | {
153
+ entity: 'downline';
154
+ entityId: UserId | TeamId;
155
+ };
156
+ type PermissionEntityId = EntityId | RoleId;
157
+ type ScopeWithSource = UserScope & AuditProps & {
158
+ source: PermissionEntityId;
159
+ };
160
+ type PermissionType = string;
161
+ /** A reduced view of a user's permission overrides, keyed by permission type. */
162
+ type PermissionMap = Partial<Record<PermissionType, ScopeWithSource[]>>;
163
+ type NotificationPreference = {
164
+ push?: boolean;
165
+ email?: boolean;
166
+ };
167
+ type UserPreferences = Partial<Record<string, NotificationPreference>>;
168
+ type UnsavedUser = {
169
+ isDeleted?: boolean;
170
+ importId?: string;
171
+ phone?: string;
172
+ firstName: string;
173
+ lastName: string;
174
+ preferredName?: string;
175
+ email: string;
176
+ timeZone?: string;
177
+ clientUserId?: string;
178
+ title?: string;
179
+ closerStatus?: CloserStatus;
180
+ companyId?: CompanyId;
181
+ managerId?: UserId;
182
+ hasManager?: boolean;
183
+ selfReportedManager?: {
184
+ managerId?: UserId;
185
+ updatedAt: number;
186
+ };
187
+ primaryTeam?: {
188
+ teamId: TeamId;
189
+ staleAfter: number;
190
+ };
191
+ betaProgram?: boolean;
192
+ language?: string;
193
+ secondaryLanguages?: string[];
194
+ color?: string;
195
+ superuserScore?: number;
196
+ customFields?: CustomFieldMap;
197
+ accountId?: string;
198
+ whitelist?: boolean;
199
+ closer?: CloserSettings;
200
+ };
201
+ type UserTeamsByLevel = {
202
+ team1?: TinyTeam[];
203
+ team2?: TinyTeam[];
204
+ team3?: TinyTeam[];
205
+ team4?: TinyTeam[];
206
+ team5?: TinyTeam[];
207
+ team6?: TinyTeam[];
208
+ team7?: TinyTeam[];
209
+ team8?: TinyTeam[];
210
+ groups: TinyTeam[];
211
+ };
212
+ type UserTeamData = UserTeamsByLevel & {
213
+ manages: TeamId[];
214
+ directMemberOf: TinyTeam[];
215
+ memberOf: TinyTeam[];
216
+ managers: TinyUser[];
217
+ manager?: TinyUser;
218
+ };
219
+ type UserData = UnsavedUser & {
220
+ lastAccess?: number;
221
+ avatarBlurhash?: string;
222
+ avatarUrl?: string;
223
+ userId: UserId;
224
+ companyId: CompanyId;
225
+ firstAccess?: number;
226
+ startDate?: number;
227
+ clientTeamId?: string;
228
+ teams?: UserTeamData;
229
+ roles?: TinyRole[];
230
+ biography?: string;
231
+ notificationPrefs?: UserPreferences;
232
+ agreeToTerms?: number;
233
+ agreeToLicensing?: number;
234
+ agreeToAITraining?: boolean;
235
+ };
236
+ type UserProfileData = UserData & {
237
+ createdAt?: number;
238
+ createdBy?: UserId;
239
+ updatedAt?: number;
240
+ updatedBy?: UserId;
241
+ permissionMap?: PermissionMap;
242
+ mailingAddress?: Address;
243
+ shoeSize?: string;
244
+ shirtSize?: string;
245
+ birth?: {
246
+ month?: number;
247
+ day?: number;
248
+ };
249
+ uploadAvatarUrl?: string;
250
+ closerIds?: UserId[];
251
+ directRoles?: TinyRole[];
252
+ };
253
+ /** Every entity type that can own users/teams in bulk operations. */
254
+ type EntityId = UserId | TeamId | CompanyId;
255
+ //#endregion
256
+ //#region src/models/user/api.d.ts
257
+ type UserListInput = {
258
+ showArchived?: true | false | 'all';
259
+ companyId?: CompanyId;
260
+ teamId?: TeamId;
261
+ userIds?: UserId[];
262
+ showBeta?: boolean;
263
+ };
264
+ type UserListSuccess = ApiSuccess<{
265
+ users: SmallUser[];
266
+ }>;
267
+ type UserAddInput = {
268
+ user: UnsavedUser & {
269
+ userId?: UserId;
270
+ };
271
+ teamMemberships?: {
272
+ teamId: TeamId;
273
+ roleIds?: RoleId[];
274
+ }[];
275
+ directRoles?: RoleId[];
276
+ };
277
+ type UserAddSuccess = ApiSuccess<{
278
+ user: UserProfileData;
279
+ password?: string;
280
+ }>;
281
+ type UserUpdateInput = {
282
+ user: Partial<UserProfileData>;
283
+ };
284
+ type UserUpdateSuccess = ApiSuccess<{
285
+ user: UserProfileData;
286
+ }>;
287
+ type UserBulkUpdateInput = {
288
+ entityIds: EntityId[];
289
+ operation: {
290
+ type: 'invalidateCloserSettings';
291
+ };
292
+ };
293
+ type UserBulkUpdateSuccess = ApiSuccess<{
294
+ updatedCount: number;
295
+ }>;
296
+ type UserRemoveInput = {
297
+ archive?: boolean;
298
+ userId: UserIdentifier;
299
+ } | {
300
+ archive?: boolean;
301
+ userIds: UserId[];
302
+ };
303
+ type UserGetInput = {
304
+ /** User ID, email, or clientUserId. Defaults to the current user if not provided. */userId?: UserIdentifier;
305
+ };
306
+ type UserGetSuccess = ApiSuccess<{
307
+ user: UserData;
308
+ }>;
309
+ type UserProfileInput = {
310
+ userId?: string;
311
+ };
312
+ type UserProfileSuccess = ApiSuccess<{
313
+ user: UserProfileData;
314
+ company: CompanyData;
315
+ }>;
316
+ type UserSearchInput = {
317
+ archived?: true | false | 'all';
318
+ companyId?: CompanyId;
319
+ query: string;
320
+ teamIds?: TeamId[];
321
+ closerStatus?: CloserStatus[];
322
+ options?: {
323
+ /** Show the first 20 users from your downline. */downline?: boolean;
324
+ size?: number;
325
+ };
326
+ };
327
+ type UserSearchSuccess = ApiSuccess<{
328
+ users: TinyUser[];
329
+ }>;
330
+ type UserTimezoneInput = {
331
+ timeZone: string;
332
+ };
333
+ type UserReportInput = {
334
+ userId?: UserId;
335
+ };
336
+ type UserReportSuccess = ApiSuccess<{
337
+ manager?: TinyUser;
338
+ managers: TinyUser[];
339
+ members: TinyUser[];
340
+ directReports: TinyUser[];
341
+ }>;
342
+ type UserClosersInput = {
343
+ /**
344
+ * CompanyId: all closers in the company.
345
+ * TeamId: all closers from the highest relevant parent team and its downline.
346
+ * TeamId + direct: all closers directly on the team.
347
+ * UserId: the target user's closer settings.
348
+ * Omitted: all closers from the user's teams, their highest relevant parent team, and its downline.
349
+ */
350
+ entityId?: EntityId;
351
+ direct?: boolean;
352
+ };
353
+ type UserClosersSuccess = ApiSuccess<{
354
+ closers: SmallCloser[];
355
+ }>;
356
+ type UserManagerInput = {
357
+ userId?: UserId;
358
+ };
359
+ type UserManagerSuccess = ApiSuccess<{
360
+ possibleManagers: TinyUser[];
361
+ primaryManager?: TinyUser;
362
+ }>;
363
+ //#endregion
364
+ //#region src/models/shared.d.ts
365
+ /** A Connect API route string, e.g. "user/get" or "account/status/add". */
366
+ type ApiRoute = string;
367
+ type ApiSuccess<T = unknown> = {
368
+ type: 'success';
369
+ } & T;
370
+ type ResponseError = {
371
+ type: 'error';
372
+ error: string;
373
+ message?: string;
374
+ retry?: boolean;
375
+ };
376
+ type ResponseOutput = ApiSuccess | ResponseError;
377
+ declare function isResponseError(response: unknown): response is ResponseError;
378
+ type CustomFieldMap = Record<string, string | number | boolean | null>;
379
+ type AuditLog = {
380
+ userId: UserId;
381
+ timestamp: number;
382
+ updateProcess?: string;
383
+ };
384
+ type AuditProps = {
385
+ modifiedBy?: AuditLog[]; /** @deprecated */
386
+ createdAt?: number; /** @deprecated */
387
+ createdBy?: UserId;
388
+ updatedAt?: number; /** @deprecated */
389
+ updatedBy?: UserId;
390
+ lastUpdateProcess?: string;
391
+ version?: number;
392
+ };
393
+ //#endregion
394
+ //#region src/models/account/model.d.ts
395
+ type AccountId = `Account:${string}` | `Account.${string}`;
396
+ type AccountStatusId = `AS.${string}`;
397
+ type WorkflowId = `WF.${string}`;
398
+ type WorkflowStageId = `S.${string}`;
399
+ type WorkflowActionId = `A.${string}`;
400
+ type ContactId = `Contact:${string}` | `Contact.${string}`;
401
+ type NoteId = `Note.${string}`;
402
+ type TagId = `Tag.${string}`;
403
+ type LocationId = `Can.${string}` | `LocNew:${string}` | `LocNew.${string}` | `Loc:${string}` | `TLoc:${string}` | `TLoc.${string}` | `FA.${string}` | `PR.${string}`;
404
+ type DispositionId = `Disposition:${string}` | `Disposition.${string}` | 'NotHome' | 'Comeback' | 'NotNow' | 'NotQualified' | 'PartialPitch' | 'NewAccount' | 'Competitor' | 'Custom1' | 'Custom2' | 'Custom3';
405
+ type ContactMethod = 'door' | 'phone';
406
+ type RangeFilter = {
407
+ gte?: number;
408
+ lte?: number;
409
+ };
410
+ /** A cursor for paging through sorted account lists. */
411
+ type SortCursor = number | number[];
412
+ type AccountUserDetails = Omit<SmallUser, 'userId' | 'memberOf'>;
413
+ type StatusHistoryItem = {
414
+ statusId: AccountStatusId;
415
+ sourceStatus?: string;
416
+ statusChangedDate: number;
417
+ };
418
+ type WorkflowHistoryItem = {
419
+ stageId: WorkflowStageId;
420
+ actionId?: WorkflowActionId;
421
+ userId: UserId;
422
+ timestamp: number;
423
+ latlng?: LatLng;
424
+ sourceStatus?: string;
425
+ };
426
+ type UserHistory = {
427
+ userId: UserId;
428
+ timestamp: number;
429
+ }[];
430
+ type UnsavedAccountContact = {
431
+ timestamp: number;
432
+ method: ContactMethod;
433
+ userId: UserId;
434
+ contactId?: ContactId;
435
+ dispositionId: DispositionId;
436
+ deviceLocation?: LatLng;
437
+ isPitch?: boolean;
438
+ };
439
+ type AccountContact = UnsavedAccountContact & {
440
+ contactId: ContactId;
441
+ };
442
+ type UnsavedAccountNote = {
443
+ timestamp: number;
444
+ text: string;
445
+ userId: UserId;
446
+ noteId?: NoteId;
447
+ };
448
+ type AccountNote = UnsavedAccountNote & {
449
+ noteId: NoteId;
450
+ };
451
+ type TagWithDate = {
452
+ tagId: TagId;
453
+ timestamp: number;
454
+ userId: UserId;
455
+ };
456
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
457
+ type TinyResidentData = Record<string, unknown>;
458
+ type UnsavedAccount = {
459
+ customFields?: CustomFieldMap;
460
+ importId?: string;
461
+ workflowId?: WorkflowId;
462
+ workflowHistory?: WorkflowHistoryItem[];
463
+ workflowStageId?: WorkflowStageId;
464
+ workflowActionId?: WorkflowActionId;
465
+ deviceLocation?: LatLng;
466
+ checkpoints?: WorkflowStageId[];
467
+ accountId?: AccountId; /** @deprecated use workflowStageId/workflowActionId */
468
+ statusId?: AccountStatusId;
469
+ accountSource?: string;
470
+ sourceStatus?: string;
471
+ sourceId?: string;
472
+ externalLeadId?: string;
473
+ locationId?: LocationId;
474
+ location?: SmallAddress;
475
+ ownerId?: UserId;
476
+ owner?: AccountUserDetails;
477
+ closerId?: UserId;
478
+ closer?: AccountUserDetails;
479
+ resident?: TinyResidentData;
480
+ resident2?: TinyResidentData;
481
+ language?: string; /** @deprecated */
482
+ rescheduleCount?: number; /** @deprecated */
483
+ dealSize?: number;
484
+ appointmentDate?: number;
485
+ test?: boolean;
486
+ teamId?: TeamId;
487
+ contacts?: UnsavedAccountContact[];
488
+ notes?: UnsavedAccountNote[];
489
+ isParent?: boolean;
490
+ parentAccountId?: AccountId;
491
+ tags?: TagWithDate[];
492
+ };
493
+ type TinyWorkflowAccount = {
494
+ accountId: AccountId;
495
+ workflowId: WorkflowId;
496
+ workflowStageId: WorkflowStageId;
497
+ workflowActionId?: WorkflowActionId;
498
+ workflowLastActionDate?: number;
499
+ workflowHistory: WorkflowHistoryItem[];
500
+ customFields?: CustomFieldMap;
501
+ };
502
+ type AccountData = Omit<UnsavedAccount, 'contacts' | 'notes'> & {
503
+ accountId: AccountId;
504
+ createdAt?: number;
505
+ createdBy?: UserId;
506
+ updatedAt?: number;
507
+ updatedBy?: UserId;
508
+ statusHistory: StatusHistoryItem[];
509
+ workflowStageName?: string;
510
+ workflowActionName?: string;
511
+ homeowner?: TinyResidentData;
512
+ userMissDate?: number;
513
+ locationMissDate?: number;
514
+ expiresAt?: number;
515
+ contacts?: AccountContact[];
516
+ notes?: AccountNote[];
517
+ lastActionDate?: number;
518
+ recruitId?: UserId;
519
+ ownerHistory?: UserHistory;
520
+ closerHistory?: UserHistory;
521
+ editable?: boolean;
522
+ };
523
+ type AccountSortBy = 'createdDate' | 'lastActionDate' | 'lastUpdatedDate' | `CF.${string}`;
524
+ type AccountSortOrder = 'asc' | 'desc';
525
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
526
+ type CustomFieldFilter = Record<string, unknown>;
527
+ type AccountDataResponse = {
528
+ accounts: AccountData[];
529
+ sortTimestamp?: SortCursor;
530
+ total?: number;
531
+ };
532
+ type BulkModifyAccountsAction = ({
533
+ actionType: 'updateStatus';
534
+ statusId: AccountStatusId;
535
+ } | {
536
+ actionType: 'updateStage';
537
+ stageId: WorkflowStageId;
538
+ } | {
539
+ actionType: 'delete' | 'clearDisposition';
540
+ })[];
541
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
542
+ type ElasticFilter = {
543
+ cities?: string[];
544
+ states?: string[];
545
+ zipCodes?: string[];
546
+ advancedCustomFields?: CustomFieldFilter;
547
+ statusIds?: AccountStatusId[];
548
+ workflowStageIds?: WorkflowStageId[];
549
+ tagIds?: TagId[];
550
+ teamIds?: TeamId[];
551
+ userIds?: UserId[];
552
+ coordinates?: LatLng[];
553
+ boundingBox?: {
554
+ top: LatLng;
555
+ bottom: LatLng;
556
+ };
557
+ workflowActionCount?: RangeFilter;
558
+ contactCount?: RangeFilter;
559
+ };
560
+ type PartialAddress = Partial<Omit<SmallAddress, 'latlng'>> & {
561
+ latlng?: Partial<LatLng>;
562
+ };
563
+ type UpsertLatLng = {
564
+ latitude?: string | number;
565
+ longitude?: string | number;
566
+ };
567
+ type UpsertTinyResidentData = Record<string, unknown>;
568
+ type AccountStatusCode = 'Lead' | 'Set' | 'Sit' | 'Closed' | 'Approved' | 'Permit Submitted' | 'Permit Approved' | 'Installed' | 'Archived' | 'Do Not Contact';
569
+ type SetterCloserConfig = {
570
+ includeOnPlan?: boolean;
571
+ allowPayment?: boolean;
572
+ };
573
+ /** The account/list entity scope this status applies to. */
574
+ type AccountStatusScope = string;
575
+ type UnsavedAccountStatus = {
576
+ name: string; /** @deprecated */
577
+ order?: number;
578
+ short?: string;
579
+ plural?: string;
580
+ description?: string;
581
+ legacyCode?: AccountStatusCode;
582
+ color?: string;
583
+ icon?: string;
584
+ restricted?: boolean;
585
+ roles?: Record<RoleId, SetterCloserConfig>;
586
+ integrationMapping?: string[];
587
+ scope: AccountStatusScope;
588
+ setter?: SetterCloserConfig;
589
+ closer?: SetterCloserConfig;
590
+ selfgen?: SetterCloserConfig;
591
+ isFinalState?: boolean;
592
+ createUser?: boolean;
593
+ columnVisibility?: TeamId[];
594
+ requiredFields?: string[];
595
+ isArchivedState?: boolean;
596
+ };
597
+ type AccountStatusData = UnsavedAccountStatus & {
598
+ statusId: AccountStatusId;
599
+ isDeleted?: boolean;
600
+ createdAt?: number;
601
+ createdBy?: UserId;
602
+ updatedAt?: number;
603
+ updatedBy?: UserId;
604
+ };
605
+ type TinyAccountStatus = Pick<AccountStatusData, 'name' | 'statusId'>;
606
+ //#endregion
607
+ //#region src/models/account/api.d.ts
608
+ type AccountStatusSearchInput = {
609
+ accountIds?: AccountId[];
610
+ workflowId?: WorkflowId;
611
+ stageIds?: WorkflowStageId[];
612
+ actionIds?: WorkflowActionId[]; /** @deprecated */
613
+ statusIds?: AccountStatusId[];
614
+ teamId?: TeamId;
615
+ userId?: UserId;
616
+ roleIds?: RoleId[];
617
+ startTime?: string | number;
618
+ endTime?: string | number;
619
+ sortTimestamp?: SortCursor;
620
+ query?: string;
621
+ searchByCurrentStage?: boolean;
622
+ tagIds?: TagId[];
623
+ cities?: string[];
624
+ states?: string[];
625
+ zipCodes?: string[];
626
+ customFields?: CustomFieldFilter;
627
+ coordinates?: LatLng[];
628
+ contactCount?: RangeFilter;
629
+ workflowActionCount?: RangeFilter;
630
+ lastActionDate?: RangeFilter;
631
+ sortBy?: AccountSortBy;
632
+ sortOrder?: AccountSortOrder;
633
+ };
634
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
635
+ type AccountHooksInput = Record<string, unknown>;
636
+ type AccountAddInput = {
637
+ account: UnsavedAccount & {
638
+ hooks?: AccountHooksInput;
639
+ };
640
+ };
641
+ type AccountAddSuccess = ApiSuccess<{
642
+ account: AccountData;
643
+ duplicate?: boolean;
644
+ }>;
645
+ type AccountPartialUpdateInput = Partial<Omit<AccountData, 'accountId' | 'contacts' | 'notes'>> & {
646
+ actorId?: UserIdentifier;
647
+ checkpoints?: WorkflowStageId[];
648
+ hooks?: AccountHooksInput;
649
+ contacts?: UnsavedAccountContact[];
650
+ notes?: UnsavedAccountNote[];
651
+ deletedContacts?: ContactId[];
652
+ deletedNotes?: NoteId[];
653
+ };
654
+ type AccountUpdateInput = {
655
+ account: AccountPartialUpdateInput & {
656
+ accountId: AccountId;
657
+ };
658
+ };
659
+ type AccountUpdateSuccess = ApiSuccess<{
660
+ account: AccountData;
661
+ }>;
662
+ type AccountUpdateBatchInput = {
663
+ accounts: (AccountPartialUpdateInput & {
664
+ accountId: AccountId;
665
+ })[];
666
+ };
667
+ type AccountUpdateBatchSuccess = ApiSuccess<{
668
+ accounts: AccountData[];
669
+ }>;
670
+ type AccountListInput = {
671
+ nearby?: LatLng;
672
+ searchInput?: AccountStatusSearchInput; /** 10-1000 */
673
+ size?: number;
674
+ };
675
+ type AccountListSuccess = ApiSuccess<AccountDataResponse>;
676
+ type BulkModifyAccountsInput = {
677
+ filter: ElasticFilter;
678
+ actions: BulkModifyAccountsAction;
679
+ };
680
+ type AccountGetInput = {
681
+ accountId: AccountId;
682
+ };
683
+ type AccountGetSuccess = ApiSuccess<{
684
+ account: AccountData;
685
+ potentialDuplicates?: AccountData[];
686
+ }>;
687
+ type AccountMatchCriterion = 'accountId' | 'externalLeadId' | 'sourceId' | 'address';
688
+ type AccountMatchInput = {
689
+ accountId?: AccountId;
690
+ externalLeadId?: string;
691
+ sourceId?: string;
692
+ location?: PartialAddress;
693
+ };
694
+ type AccountMatchSuccess = ApiSuccess<{
695
+ account?: AccountData;
696
+ matchedOn?: AccountMatchCriterion;
697
+ additionalMatches?: AccountData[];
698
+ }>;
699
+ type AccountRemoveInput = {
700
+ accountId: AccountId;
701
+ };
702
+ type AccountRequestType = 'add' | 'update' | 'upsert';
703
+ type AccountUpsertInput = {
704
+ /** Defaults to 'upsert'. */requestType?: AccountRequestType;
705
+ account: {
706
+ accountId?: AccountId;
707
+ actorId?: UserIdentifier; /** @deprecated */
708
+ statusId?: AccountStatusId; /** @deprecated */
709
+ statusHistory?: StatusHistoryItem[];
710
+ workflowId?: WorkflowId; /** @deprecated use workflowTarget */
711
+ workflowActionOrStageId?: WorkflowActionId | WorkflowStageId;
712
+ workflowTarget?: string;
713
+ owner?: Partial<SmallUser>;
714
+ closer?: Partial<SmallUser>;
715
+ location?: Partial<PartialAddress & {
716
+ locationId?: LocationId;
717
+ latlng?: UpsertLatLng;
718
+ }>;
719
+ resident?: Partial<UpsertTinyResidentData>;
720
+ resident2?: Partial<UpsertTinyResidentData>;
721
+ accountSource?: string;
722
+ sourceStatus?: string;
723
+ lastActionDate?: number;
724
+ sourceId?: string;
725
+ externalLeadId?: string;
726
+ test?: boolean;
727
+ teamId?: TeamId;
728
+ customFields?: CustomFieldMap;
729
+ notes?: UnsavedAccountNote[];
730
+ };
731
+ opts?: {
732
+ /** Defaults to true. */createCustomLocation?: boolean;
733
+ };
734
+ };
735
+ type AccountUpsertSuccess = ApiSuccess<{
736
+ account?: AccountData;
737
+ }>;
738
+ type AccountStatusAddInput = {
739
+ status: UnsavedAccountStatus;
740
+ };
741
+ type AccountStatusAddSuccess = ApiSuccess<{
742
+ status: AccountStatusData;
743
+ }>;
744
+ type AccountStatusUpdateInput = {
745
+ status: AccountStatusData;
746
+ };
747
+ type AccountStatusUpdateSuccess = ApiSuccess<{
748
+ status: AccountStatusData;
749
+ }>;
750
+ type AccountStatusListInput = {
751
+ archived?: true | false | 'all';
752
+ companyId?: CompanyId;
753
+ };
754
+ type AccountStatusListSuccess = ApiSuccess<{
755
+ statuses: AccountStatusData[];
756
+ includesDefaults?: boolean;
757
+ }>;
758
+ type AccountStatusRemoveInput = {
759
+ archive?: boolean;
760
+ statusId: AccountStatusId;
761
+ };
762
+ //#endregion
763
+ //#region src/models/calendar/model.d.ts
764
+ type CalendarEventId = `Event:${string}` | `Event.${string}`;
765
+ /** @deprecated */
766
+ type EventOutcomeId = `O.${string}`;
767
+ type InterviewId = `Interview:${string}` | `Interview.${string}`;
768
+ type AttachmentId = `Attachment:${string}` | `Attachment.${string}`;
769
+ type EventType = 'Consultation' | 'Comeback' | 'Interview' | 'GeneralVisit' | 'Shadow' | 'Team';
770
+ type SpecialtyAttachments = {
771
+ utilityBill?: AttachmentId;
772
+ customerVerification?: AttachmentId;
773
+ };
774
+ /** @deprecated */
775
+ type SyncedCalendarEvent = {
776
+ calendarType: string;
777
+ calendarId: string;
778
+ userId: UserId;
779
+ deviceId: string;
780
+ eventId: string;
781
+ };
782
+ type CalendarEventLocation = Pick<Address, 'oneLine'> & LatLng;
783
+ type UnsavedCalendarEventData = {
784
+ importId?: string;
785
+ eventType: EventType;
786
+ title: string;
787
+ sourceId?: string; /** UTC milliseconds. */
788
+ eventDate: number;
789
+ outcomeId?: EventOutcomeId;
790
+ dispositionId?: DispositionId; /** Minutes. */
791
+ duration: number;
792
+ attachments?: AttachmentId[];
793
+ specialtyAttachments?: SpecialtyAttachments;
794
+ accountId?: AccountId;
795
+ locationId?: LocationId;
796
+ location?: CalendarEventLocation;
797
+ ownerId?: UserId;
798
+ attendeeId?: UserId;
799
+ dispatcherId?: UserId;
800
+ occurredOwner?: boolean;
801
+ occurredAttendee?: boolean;
802
+ interviewId?: InterviewId; /** @deprecated */
803
+ notes?: string;
804
+ previousEventId?: CalendarEventId; /** @deprecated */
805
+ syncedCalendarIds?: string[]; /** @deprecated */
806
+ syncedCalendarEvents?: SyncedCalendarEvent[];
807
+ teamId?: TeamId;
808
+ };
809
+ type EventOutcomeHistory = {
810
+ outcomeId: EventOutcomeId;
811
+ userId: UserId;
812
+ timestamp: number;
813
+ };
814
+ type SitOutcomeFault = string;
815
+ type CalendarEventData = UnsavedCalendarEventData & {
816
+ outcomeHistory?: EventOutcomeHistory[];
817
+ createdAt?: number;
818
+ createdBy?: UserId;
819
+ updatedAt?: number;
820
+ updatedBy?: UserId;
821
+ eventId: CalendarEventId;
822
+ ownerId: UserId;
823
+ occurred?: boolean;
824
+ closed?: boolean;
825
+ reasonNotOccurred?: string;
826
+ fault?: SitOutcomeFault;
827
+ allDay?: boolean;
828
+ canDelete?: boolean;
829
+ };
830
+ type CalendarEventDataWithDetails = CalendarEventData & {
831
+ resident?: TinyResidentData;
832
+ owner?: SmallUser;
833
+ attendee?: SmallUser;
834
+ teams?: TinyTeam[];
835
+ account?: TinyWorkflowAccount;
836
+ };
837
+ //#endregion
838
+ //#region src/models/calendar/api.d.ts
839
+ type CalendarEventRoleFilter = 'owner' | 'attendee';
840
+ type OptionalCalendarEventLocation = UpsertLatLng & {
841
+ locationId?: LocationId;
842
+ oneLine?: string;
843
+ };
844
+ /** A yes/no/unset filter — matches events where the field is true, false, unset, or set to any value. */
845
+ type BooleanFilter = 'true' | 'false' | 'undefined' | 'defined';
846
+ type CalendarAvailabilityInput = {
847
+ /** UTC milliseconds. */startDate: number; /** Minutes. Defaults to 30. */
848
+ duration?: number;
849
+ teamId?: TeamId;
850
+ };
851
+ type CalendarAvailabilitySuccess = ApiSuccess<{
852
+ available: boolean;
853
+ }>;
854
+ type CalendarClosersInput = CalendarAvailabilityInput & {
855
+ latLng?: LatLng;
856
+ };
857
+ type CalendarClosersSuccess = ApiSuccess<{
858
+ closers: AvailableCloser[];
859
+ }>;
860
+ type CalendarTimeslotsInput = {
861
+ targetId?: TeamId | UserId;
862
+ days?: number;
863
+ locationId?: LocationId; /** UTC milliseconds. */
864
+ startTime?: number;
865
+ };
866
+ type CalendarTimeslotsSuccess = ApiSuccess<{
867
+ closers: TinyCloser[];
868
+ }>;
869
+ type CalendarEventAddInput = {
870
+ event: UnsavedCalendarEventData; /** Defaults to true. */
871
+ errorOnCloserUnavailable?: boolean;
872
+ };
873
+ type CalendarEventAddSuccess = ApiSuccess<{
874
+ event: CalendarEventData;
875
+ }>;
876
+ type CalendarEventGetInput = {
877
+ eventId: CalendarEventId;
878
+ };
879
+ type CalendarEventGetSuccess = ApiSuccess<{
880
+ event: CalendarEventDataWithDetails;
881
+ }>;
882
+ type CalendarEventListInput = {
883
+ startTime?: number;
884
+ endTime?: number;
885
+ ownerId?: UserId;
886
+ locationId?: LocationId;
887
+ companyId?: string; /** @deprecated use teamIds */
888
+ teamId?: TeamId;
889
+ teamIds?: TeamId[];
890
+ roleIds?: RoleId[];
891
+ occurred?: BooleanFilter;
892
+ closed?: BooleanFilter;
893
+ eventType?: EventType;
894
+ filterByRoles?: CalendarEventRoleFilter[];
895
+ };
896
+ type CalendarEventListSuccess = ApiSuccess<{
897
+ events: CalendarEventDataWithDetails[];
898
+ }>;
899
+ type CalendarEventUpdateInput = {
900
+ event: Partial<CalendarEventData> & {
901
+ eventId: CalendarEventId;
902
+ attendeeId?: UserId | null;
903
+ };
904
+ errorOnCloserUnavailable?: boolean;
905
+ };
906
+ type CalendarEventUpdateSuccess = ApiSuccess<{
907
+ event: CalendarEventData;
908
+ }>;
909
+ type CalendarEventUpsertInput = {
910
+ event: Partial<{
911
+ eventId: CalendarEventId;
912
+ sourceId: string; /** Defaults to 'Consultation' on create. */
913
+ eventType: string;
914
+ title: string; /** Defaults to now on create. */
915
+ eventDate: string | number; /** An EventOutcomeId, integration mapping string, or case-insensitive name. */
916
+ outcomeId: string; /** Minutes. */
917
+ duration: number;
918
+ accountId: AccountId;
919
+ location: OptionalCalendarEventLocation; /** A UserId or email. Defaults to the authenticated user on create. */
920
+ ownerId: string; /** A UserId or email. Pass null to clear on update. */
921
+ attendeeId: string | null; /** A UserId or email. */
922
+ dispatcherId: string;
923
+ occurredOwner: boolean;
924
+ occurredAttendee: boolean;
925
+ notes: string;
926
+ previousEventId: CalendarEventId;
927
+ }>;
928
+ };
929
+ type CalendarEventUpsertSuccess = ApiSuccess<{
930
+ event: CalendarEventData;
931
+ }>;
932
+ type CalendarEventConfirmInput = {
933
+ eventId: CalendarEventId;
934
+ occurred?: boolean;
935
+ };
936
+ type CalendarEventConfirmSuccess = ApiSuccess<{
937
+ event: CalendarEventData;
938
+ }>;
939
+ type CalendarEventRemoveInput = {
940
+ archive?: boolean;
941
+ eventId: CalendarEventId;
942
+ };
943
+ //#endregion
944
+ //#region src/apiCaller.d.ts
945
+ type ClientConfig = {
946
+ apiKey?: string;
947
+ baseUrl?: string;
948
+ };
949
+ declare class ApiCaller {
950
+ private readonly baseUrl;
951
+ private readonly auth;
952
+ private readonly analytics;
953
+ constructor(config: ClientConfig);
954
+ call<Success>(route: ApiRoute, input: object): Promise<Success>;
955
+ }
956
+ //#endregion
957
+ //#region src/clients/account.d.ts
958
+ declare class AccountStatusClient {
959
+ private readonly api;
960
+ constructor(api: ApiCaller);
961
+ add(input: AccountStatusAddInput): Promise<AccountStatusAddSuccess>;
962
+ update(input: AccountStatusUpdateInput): Promise<AccountStatusUpdateSuccess>;
963
+ list(input: AccountStatusListInput): Promise<AccountStatusListSuccess>;
964
+ remove(input: AccountStatusRemoveInput): Promise<ApiSuccess>;
965
+ }
966
+ declare class AccountClient {
967
+ private readonly api;
968
+ readonly status: AccountStatusClient;
969
+ constructor(api: ApiCaller);
970
+ add(input: AccountAddInput): Promise<AccountAddSuccess>;
971
+ update(input: AccountUpdateInput): Promise<AccountUpdateSuccess>;
972
+ updateBatch(input: AccountUpdateBatchInput): Promise<AccountUpdateBatchSuccess>;
973
+ list(input: AccountListInput): Promise<AccountListSuccess>;
974
+ bulk(input: BulkModifyAccountsInput): Promise<ApiSuccess>;
975
+ get(input: AccountGetInput): Promise<AccountGetSuccess>;
976
+ match(input: AccountMatchInput): Promise<AccountMatchSuccess>;
977
+ remove(input: AccountRemoveInput): Promise<ApiSuccess>;
978
+ upsert(input: AccountUpsertInput): Promise<AccountUpsertSuccess>;
979
+ }
980
+ //#endregion
981
+ //#region src/clients/calendar.d.ts
982
+ declare class CalendarEventClient {
983
+ private readonly api;
984
+ constructor(api: ApiCaller);
985
+ add(input: CalendarEventAddInput): Promise<CalendarEventAddSuccess>;
986
+ get(input: CalendarEventGetInput): Promise<CalendarEventGetSuccess>;
987
+ list(input: CalendarEventListInput): Promise<CalendarEventListSuccess>;
988
+ update(input: CalendarEventUpdateInput): Promise<CalendarEventUpdateSuccess>;
989
+ upsert(input: CalendarEventUpsertInput): Promise<CalendarEventUpsertSuccess>;
990
+ confirm(input: CalendarEventConfirmInput): Promise<CalendarEventConfirmSuccess>;
991
+ remove(input: CalendarEventRemoveInput): Promise<ApiSuccess>;
992
+ }
993
+ declare class CalendarClient {
994
+ private readonly api;
995
+ readonly event: CalendarEventClient;
996
+ constructor(api: ApiCaller);
997
+ availability(input: CalendarAvailabilityInput): Promise<CalendarAvailabilitySuccess>;
998
+ closers(input: CalendarClosersInput): Promise<CalendarClosersSuccess>;
999
+ timeslots(input: CalendarTimeslotsInput): Promise<CalendarTimeslotsSuccess>;
1000
+ }
1001
+ //#endregion
1002
+ //#region src/clients/user.d.ts
1003
+ declare class UserClient {
1004
+ private readonly api;
1005
+ constructor(api: ApiCaller);
1006
+ list(input: UserListInput): Promise<UserListSuccess>;
1007
+ add(input: UserAddInput): Promise<UserAddSuccess>;
1008
+ update(input: UserUpdateInput): Promise<UserUpdateSuccess>;
1009
+ updateBulk(input: UserBulkUpdateInput): Promise<UserBulkUpdateSuccess>;
1010
+ remove(input: UserRemoveInput): Promise<ApiSuccess>;
1011
+ get(input?: UserGetInput): Promise<UserGetSuccess>;
1012
+ profile(input?: UserProfileInput): Promise<UserProfileSuccess>;
1013
+ search(input: UserSearchInput): Promise<UserSearchSuccess>;
1014
+ timezone(input: UserTimezoneInput): Promise<ApiSuccess>;
1015
+ report(input: UserReportInput): Promise<UserReportSuccess>;
1016
+ closers(input: UserClosersInput): Promise<UserClosersSuccess>;
1017
+ manager(input: UserManagerInput): Promise<UserManagerSuccess>;
1018
+ }
1019
+ //#endregion
1020
+ //#region src/client.d.ts
1021
+ declare class TerrosClient {
1022
+ readonly user: UserClient;
1023
+ readonly account: AccountClient;
1024
+ readonly calendar: CalendarClient;
1025
+ constructor(config?: ClientConfig);
1026
+ }
1027
+ //#endregion
1028
+ export { AccessStatus, AccountAddInput, AccountAddSuccess, AccountContact, AccountData, AccountDataResponse, AccountGetInput, AccountGetSuccess, AccountHooksInput, AccountId, AccountListInput, AccountListSuccess, AccountMatchInput, AccountMatchSuccess, AccountNote, AccountPartialUpdateInput, AccountRemoveInput, AccountSortBy, AccountSortOrder, AccountStatusAddInput, AccountStatusAddSuccess, AccountStatusCode, AccountStatusData, AccountStatusId, AccountStatusListInput, AccountStatusListSuccess, AccountStatusRemoveInput, AccountStatusSearchInput, AccountStatusUpdateInput, AccountStatusUpdateSuccess, AccountUpdateBatchInput, AccountUpdateBatchSuccess, AccountUpdateInput, AccountUpdateSuccess, AccountUpsertInput, AccountUpsertSuccess, AccountUserDetails, Address, ApiRoute, ApiSuccess, AttachmentId, AuditLog, AuditProps, AvailableCloser, BillingMethod, BulkModifyAccountsAction, BulkModifyAccountsInput, CalendarAvailabilityInput, CalendarAvailabilitySuccess, CalendarClosersInput, CalendarClosersSuccess, CalendarEventAddInput, CalendarEventAddSuccess, CalendarEventConfirmInput, CalendarEventConfirmSuccess, CalendarEventData, CalendarEventDataWithDetails, CalendarEventGetInput, CalendarEventGetSuccess, CalendarEventId, CalendarEventListInput, CalendarEventListSuccess, CalendarEventLocation, CalendarEventRemoveInput, CalendarEventUpdateInput, CalendarEventUpdateSuccess, CalendarEventUpsertInput, CalendarEventUpsertSuccess, CalendarTimeslotsInput, CalendarTimeslotsSuccess, CloserSettings, CloserStatus, CompanyData, CompanyId, CompanyIndustry, CompanyKind, CompanyState, ContactId, CustomFieldFilter, CustomFieldMap, DispositionId, ElasticFilter, EntityId, EventOutcomeHistory, EventOutcomeId, EventType, InterviewId, LatLng, LocationId, NoteId, NotificationPreference, PartialAddress, PermissionMap, RangeFilter, ResponseError, ResponseOutput, RoleId, SmallAddress, SmallCloser, SmallUser, SortCursor, SpecialtyAttachments, StatusHistoryItem, SyncedCalendarEvent, TagId, TeamId, TerrosClient, TinyAccountStatus, TinyCloser, TinyResidentData, TinyRole, TinyTeam, TinyUser, TinyWorkflowAccount, UnsavedAccount, UnsavedAccountContact, UnsavedAccountNote, UnsavedAccountStatus, UnsavedCalendarEventData, UnsavedUser, UpsertLatLng, UpsertTinyResidentData, UserAddInput, UserAddSuccess, UserBulkUpdateInput, UserBulkUpdateSuccess, UserClosersInput, UserClosersSuccess, UserData, UserGetInput, UserGetSuccess, UserHistory, UserId, UserIdentifier, UserListInput, UserListSuccess, UserManagerInput, UserManagerSuccess, UserPreferences, UserProfileData, UserProfileInput, UserProfileSuccess, UserRemoveInput, UserReportInput, UserReportSuccess, UserSearchInput, UserSearchSuccess, UserTeamData, UserTeamsByLevel, UserTimezoneInput, UserUpdateInput, UserUpdateSuccess, Weekday, WorkflowActionId, WorkflowHistoryItem, WorkflowId, WorkflowStageId, isResponseError };