@terros-inc/sdk 1.0.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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/models/account/api.d.ts +167 -0
  6. package/dist/models/account/api.js +1 -0
  7. package/dist/models/account/index.d.ts +2 -0
  8. package/dist/models/account/index.js +2 -0
  9. package/dist/models/account/model.d.ts +219 -0
  10. package/dist/models/account/model.js +1 -0
  11. package/dist/models/calendar/api.d.ts +122 -0
  12. package/dist/models/calendar/api.js +1 -0
  13. package/dist/models/calendar/index.d.ts +2 -0
  14. package/dist/models/calendar/index.js +2 -0
  15. package/dist/models/calendar/model.d.ts +83 -0
  16. package/dist/models/calendar/model.js +1 -0
  17. package/dist/models/company/index.d.ts +1 -0
  18. package/dist/models/company/index.js +1 -0
  19. package/dist/models/company/model.d.ts +37 -0
  20. package/dist/models/company/model.js +1 -0
  21. package/dist/models/index.d.ts +7 -0
  22. package/dist/models/index.js +7 -0
  23. package/dist/models/location/index.d.ts +1 -0
  24. package/dist/models/location/index.js +1 -0
  25. package/dist/models/location/model.d.ts +21 -0
  26. package/dist/models/location/model.js +1 -0
  27. package/dist/models/shared.d.ts +32 -0
  28. package/dist/models/shared.js +6 -0
  29. package/dist/models/team/index.d.ts +1 -0
  30. package/dist/models/team/index.js +1 -0
  31. package/dist/models/team/model.d.ts +17 -0
  32. package/dist/models/team/model.js +1 -0
  33. package/dist/models/user/api.d.ts +111 -0
  34. package/dist/models/user/api.js +1 -0
  35. package/dist/models/user/index.d.ts +2 -0
  36. package/dist/models/user/index.js +2 -0
  37. package/dist/models/user/model.d.ts +179 -0
  38. package/dist/models/user/model.js +1 -0
  39. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Terros Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # Terros SDK
2
+
3
+ Typescript SDK & API client interface for the Terros Sales platform.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 24 or newer
8
+ - A Terros API key with access to the platform
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,167 @@
1
+ import type { ApiSuccess, CustomFieldMap } from '../shared.ts';
2
+ import type { RoleId, SmallUser, TeamId, UserId, UserIdentifier } from '../user/model.ts';
3
+ import type { LatLng } from '../location/model.ts';
4
+ import type { CompanyId } from '../company/model.ts';
5
+ import type { AccountData, AccountDataResponse, AccountId, AccountSortBy, AccountSortOrder, AccountStatusData, AccountStatusId, BulkModifyAccountsAction, ContactId, CustomFieldFilter, ElasticFilter, LocationId, NoteId, PartialAddress, RangeFilter, SortCursor, StatusHistoryItem, TagId, UnsavedAccount, UnsavedAccountContact, UnsavedAccountNote, UnsavedAccountStatus, UpsertLatLng, UpsertTinyResidentData, WorkflowActionId, WorkflowId, WorkflowStageId } from './model.ts';
6
+ export type AccountStatusSearchInput = {
7
+ accountIds?: AccountId[];
8
+ workflowId?: WorkflowId;
9
+ stageIds?: WorkflowStageId[];
10
+ actionIds?: WorkflowActionId[];
11
+ /** @deprecated */
12
+ statusIds?: AccountStatusId[];
13
+ teamId?: TeamId;
14
+ userId?: UserId;
15
+ roleIds?: RoleId[];
16
+ startTime?: string | number;
17
+ endTime?: string | number;
18
+ sortTimestamp?: SortCursor;
19
+ query?: string;
20
+ searchByCurrentStage?: boolean;
21
+ tagIds?: TagId[];
22
+ cities?: string[];
23
+ states?: string[];
24
+ zipCodes?: string[];
25
+ customFields?: CustomFieldFilter;
26
+ coordinates?: LatLng[];
27
+ contactCount?: RangeFilter;
28
+ workflowActionCount?: RangeFilter;
29
+ lastActionDate?: RangeFilter;
30
+ sortBy?: AccountSortBy;
31
+ sortOrder?: AccountSortOrder;
32
+ };
33
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
34
+ export type AccountHooksInput = Record<string, unknown>;
35
+ export type AccountAddInput = {
36
+ account: UnsavedAccount & {
37
+ hooks?: AccountHooksInput;
38
+ };
39
+ };
40
+ export type AccountAddSuccess = ApiSuccess<{
41
+ account: AccountData;
42
+ duplicate?: boolean;
43
+ }>;
44
+ export type AccountPartialUpdateInput = Partial<Omit<AccountData, 'accountId' | 'contacts' | 'notes'>> & {
45
+ actorId?: UserIdentifier;
46
+ checkpoints?: WorkflowStageId[];
47
+ hooks?: AccountHooksInput;
48
+ contacts?: UnsavedAccountContact[];
49
+ notes?: UnsavedAccountNote[];
50
+ deletedContacts?: ContactId[];
51
+ deletedNotes?: NoteId[];
52
+ };
53
+ export type AccountUpdateInput = {
54
+ account: AccountPartialUpdateInput & {
55
+ accountId: AccountId;
56
+ };
57
+ };
58
+ export type AccountUpdateSuccess = ApiSuccess<{
59
+ account: AccountData;
60
+ }>;
61
+ export type AccountUpdateBatchInput = {
62
+ accounts: (AccountPartialUpdateInput & {
63
+ accountId: AccountId;
64
+ })[];
65
+ };
66
+ export type AccountUpdateBatchSuccess = ApiSuccess<{
67
+ accounts: AccountData[];
68
+ }>;
69
+ export type AccountListInput = {
70
+ nearby?: LatLng;
71
+ searchInput?: AccountStatusSearchInput;
72
+ /** 10-1000 */
73
+ size?: number;
74
+ };
75
+ export type AccountListSuccess = ApiSuccess<AccountDataResponse>;
76
+ export type BulkModifyAccountsInput = {
77
+ filter: ElasticFilter;
78
+ actions: BulkModifyAccountsAction;
79
+ };
80
+ export type AccountGetInput = {
81
+ accountId: AccountId;
82
+ };
83
+ export type AccountGetSuccess = ApiSuccess<{
84
+ account: AccountData;
85
+ potentialDuplicates?: AccountData[];
86
+ }>;
87
+ type AccountMatchCriterion = 'accountId' | 'externalLeadId' | 'sourceId' | 'address';
88
+ export type AccountMatchInput = {
89
+ accountId?: AccountId;
90
+ externalLeadId?: string;
91
+ sourceId?: string;
92
+ location?: PartialAddress;
93
+ };
94
+ export type AccountMatchSuccess = ApiSuccess<{
95
+ account?: AccountData;
96
+ matchedOn?: AccountMatchCriterion;
97
+ additionalMatches?: AccountData[];
98
+ }>;
99
+ export type AccountRemoveInput = {
100
+ accountId: AccountId;
101
+ };
102
+ type AccountRequestType = 'add' | 'update' | 'upsert';
103
+ export type AccountUpsertInput = {
104
+ /** Defaults to 'upsert'. */
105
+ requestType?: AccountRequestType;
106
+ account: {
107
+ accountId?: AccountId;
108
+ actorId?: UserIdentifier;
109
+ /** @deprecated */
110
+ statusId?: AccountStatusId;
111
+ /** @deprecated */
112
+ statusHistory?: StatusHistoryItem[];
113
+ workflowId?: WorkflowId;
114
+ /** @deprecated use workflowTarget */
115
+ workflowActionOrStageId?: WorkflowActionId | WorkflowStageId;
116
+ workflowTarget?: string;
117
+ owner?: Partial<SmallUser>;
118
+ closer?: Partial<SmallUser>;
119
+ location?: Partial<PartialAddress & {
120
+ locationId?: LocationId;
121
+ latlng?: UpsertLatLng;
122
+ }>;
123
+ resident?: Partial<UpsertTinyResidentData>;
124
+ resident2?: Partial<UpsertTinyResidentData>;
125
+ accountSource?: string;
126
+ sourceStatus?: string;
127
+ lastActionDate?: number;
128
+ sourceId?: string;
129
+ externalLeadId?: string;
130
+ test?: boolean;
131
+ teamId?: TeamId;
132
+ customFields?: CustomFieldMap;
133
+ notes?: UnsavedAccountNote[];
134
+ };
135
+ opts?: {
136
+ /** Defaults to true. */
137
+ createCustomLocation?: boolean;
138
+ };
139
+ };
140
+ export type AccountUpsertSuccess = ApiSuccess<{
141
+ account?: AccountData;
142
+ }>;
143
+ export type AccountStatusAddInput = {
144
+ status: UnsavedAccountStatus;
145
+ };
146
+ export type AccountStatusAddSuccess = ApiSuccess<{
147
+ status: AccountStatusData;
148
+ }>;
149
+ export type AccountStatusUpdateInput = {
150
+ status: AccountStatusData;
151
+ };
152
+ export type AccountStatusUpdateSuccess = ApiSuccess<{
153
+ status: AccountStatusData;
154
+ }>;
155
+ export type AccountStatusListInput = {
156
+ archived?: true | false | 'all';
157
+ companyId?: CompanyId;
158
+ };
159
+ export type AccountStatusListSuccess = ApiSuccess<{
160
+ statuses: AccountStatusData[];
161
+ includesDefaults?: boolean;
162
+ }>;
163
+ export type AccountStatusRemoveInput = {
164
+ archive?: boolean;
165
+ statusId: AccountStatusId;
166
+ };
167
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './model.ts';
2
+ export * from './api.ts';
@@ -0,0 +1,2 @@
1
+ export * from "./model.js";
2
+ export * from "./api.js";
@@ -0,0 +1,219 @@
1
+ import type { RoleId, SmallUser, TeamId, UserId } from '../user/model.ts';
2
+ import type { CustomFieldMap } from '../shared.ts';
3
+ import type { LatLng, SmallAddress } from '../location/model.ts';
4
+ export type AccountId = `Account:${string}` | `Account.${string}`;
5
+ export type AccountStatusId = `AS.${string}`;
6
+ export type WorkflowId = `WF.${string}`;
7
+ export type WorkflowStageId = `S.${string}`;
8
+ export type WorkflowActionId = `A.${string}`;
9
+ export type ContactId = `Contact:${string}` | `Contact.${string}`;
10
+ export type NoteId = `Note.${string}`;
11
+ export type TagId = `Tag.${string}`;
12
+ export type LocationId = `Can.${string}` | `LocNew:${string}` | `LocNew.${string}` | `Loc:${string}` | `TLoc:${string}` | `TLoc.${string}` | `FA.${string}` | `PR.${string}`;
13
+ export type DispositionId = `Disposition:${string}` | `Disposition.${string}` | 'NotHome' | 'Comeback' | 'NotNow' | 'NotQualified' | 'PartialPitch' | 'NewAccount' | 'Competitor' | 'Custom1' | 'Custom2' | 'Custom3';
14
+ type ContactMethod = 'door' | 'phone';
15
+ export type RangeFilter = {
16
+ gte?: number;
17
+ lte?: number;
18
+ };
19
+ /** A cursor for paging through sorted account lists. */
20
+ export type SortCursor = number | number[];
21
+ export type AccountUserDetails = Omit<SmallUser, 'userId' | 'memberOf'>;
22
+ export type StatusHistoryItem = {
23
+ statusId: AccountStatusId;
24
+ sourceStatus?: string;
25
+ statusChangedDate: number;
26
+ };
27
+ export type WorkflowHistoryItem = {
28
+ stageId: WorkflowStageId;
29
+ actionId?: WorkflowActionId;
30
+ userId: UserId;
31
+ timestamp: number;
32
+ latlng?: LatLng;
33
+ sourceStatus?: string;
34
+ };
35
+ export type UserHistory = {
36
+ userId: UserId;
37
+ timestamp: number;
38
+ }[];
39
+ export type UnsavedAccountContact = {
40
+ timestamp: number;
41
+ method: ContactMethod;
42
+ userId: UserId;
43
+ contactId?: ContactId;
44
+ dispositionId: DispositionId;
45
+ deviceLocation?: LatLng;
46
+ isPitch?: boolean;
47
+ };
48
+ export type AccountContact = UnsavedAccountContact & {
49
+ contactId: ContactId;
50
+ };
51
+ export type UnsavedAccountNote = {
52
+ timestamp: number;
53
+ text: string;
54
+ userId: UserId;
55
+ noteId?: NoteId;
56
+ };
57
+ export type AccountNote = UnsavedAccountNote & {
58
+ noteId: NoteId;
59
+ };
60
+ type TagWithDate = {
61
+ tagId: TagId;
62
+ timestamp: number;
63
+ userId: UserId;
64
+ };
65
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
66
+ export type TinyResidentData = Record<string, unknown>;
67
+ export type UnsavedAccount = {
68
+ customFields?: CustomFieldMap;
69
+ importId?: string;
70
+ workflowId?: WorkflowId;
71
+ workflowHistory?: WorkflowHistoryItem[];
72
+ workflowStageId?: WorkflowStageId;
73
+ workflowActionId?: WorkflowActionId;
74
+ deviceLocation?: LatLng;
75
+ checkpoints?: WorkflowStageId[];
76
+ accountId?: AccountId;
77
+ /** @deprecated use workflowStageId/workflowActionId */
78
+ statusId?: AccountStatusId;
79
+ accountSource?: string;
80
+ sourceStatus?: string;
81
+ sourceId?: string;
82
+ externalLeadId?: string;
83
+ locationId?: LocationId;
84
+ location?: SmallAddress;
85
+ ownerId?: UserId;
86
+ owner?: AccountUserDetails;
87
+ closerId?: UserId;
88
+ closer?: AccountUserDetails;
89
+ resident?: TinyResidentData;
90
+ resident2?: TinyResidentData;
91
+ language?: string;
92
+ /** @deprecated */
93
+ rescheduleCount?: number;
94
+ /** @deprecated */
95
+ dealSize?: number;
96
+ appointmentDate?: number;
97
+ test?: boolean;
98
+ teamId?: TeamId;
99
+ contacts?: UnsavedAccountContact[];
100
+ notes?: UnsavedAccountNote[];
101
+ isParent?: boolean;
102
+ parentAccountId?: AccountId;
103
+ tags?: TagWithDate[];
104
+ };
105
+ export type TinyWorkflowAccount = {
106
+ accountId: AccountId;
107
+ workflowId: WorkflowId;
108
+ workflowStageId: WorkflowStageId;
109
+ workflowActionId?: WorkflowActionId;
110
+ workflowLastActionDate?: number;
111
+ workflowHistory: WorkflowHistoryItem[];
112
+ customFields?: CustomFieldMap;
113
+ };
114
+ export type AccountData = Omit<UnsavedAccount, 'contacts' | 'notes'> & {
115
+ accountId: AccountId;
116
+ createdAt?: number;
117
+ createdBy?: UserId;
118
+ updatedAt?: number;
119
+ updatedBy?: UserId;
120
+ statusHistory: StatusHistoryItem[];
121
+ workflowStageName?: string;
122
+ workflowActionName?: string;
123
+ homeowner?: TinyResidentData;
124
+ userMissDate?: number;
125
+ locationMissDate?: number;
126
+ expiresAt?: number;
127
+ contacts?: AccountContact[];
128
+ notes?: AccountNote[];
129
+ lastActionDate?: number;
130
+ recruitId?: UserId;
131
+ ownerHistory?: UserHistory;
132
+ closerHistory?: UserHistory;
133
+ editable?: boolean;
134
+ };
135
+ export type AccountSortBy = 'createdDate' | 'lastActionDate' | 'lastUpdatedDate' | `CF.${string}`;
136
+ export type AccountSortOrder = 'asc' | 'desc';
137
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
138
+ export type CustomFieldFilter = Record<string, unknown>;
139
+ export type AccountDataResponse = {
140
+ accounts: AccountData[];
141
+ sortTimestamp?: SortCursor;
142
+ total?: number;
143
+ };
144
+ export type BulkModifyAccountsAction = ({
145
+ actionType: 'updateStatus';
146
+ statusId: AccountStatusId;
147
+ } | {
148
+ actionType: 'updateStage';
149
+ stageId: WorkflowStageId;
150
+ } | {
151
+ actionType: 'delete' | 'clearDisposition';
152
+ })[];
153
+ /** Not modeled in detail by this SDK — treat as an opaque record. */
154
+ export type ElasticFilter = {
155
+ cities?: string[];
156
+ states?: string[];
157
+ zipCodes?: string[];
158
+ advancedCustomFields?: CustomFieldFilter;
159
+ statusIds?: AccountStatusId[];
160
+ workflowStageIds?: WorkflowStageId[];
161
+ tagIds?: TagId[];
162
+ teamIds?: TeamId[];
163
+ userIds?: UserId[];
164
+ coordinates?: LatLng[];
165
+ boundingBox?: {
166
+ top: LatLng;
167
+ bottom: LatLng;
168
+ };
169
+ workflowActionCount?: RangeFilter;
170
+ contactCount?: RangeFilter;
171
+ };
172
+ export type PartialAddress = Partial<Omit<SmallAddress, 'latlng'>> & {
173
+ latlng?: Partial<LatLng>;
174
+ };
175
+ export type UpsertLatLng = {
176
+ latitude?: string | number;
177
+ longitude?: string | number;
178
+ };
179
+ export type UpsertTinyResidentData = Record<string, unknown>;
180
+ export type AccountStatusCode = 'Lead' | 'Set' | 'Sit' | 'Closed' | 'Approved' | 'Permit Submitted' | 'Permit Approved' | 'Installed' | 'Archived' | 'Do Not Contact';
181
+ type SetterCloserConfig = {
182
+ includeOnPlan?: boolean;
183
+ allowPayment?: boolean;
184
+ };
185
+ /** The account/list entity scope this status applies to. */
186
+ type AccountStatusScope = string;
187
+ export type UnsavedAccountStatus = {
188
+ name: string;
189
+ /** @deprecated */
190
+ order?: number;
191
+ short?: string;
192
+ plural?: string;
193
+ description?: string;
194
+ legacyCode?: AccountStatusCode;
195
+ color?: string;
196
+ icon?: string;
197
+ restricted?: boolean;
198
+ roles?: Record<RoleId, SetterCloserConfig>;
199
+ integrationMapping?: string[];
200
+ scope: AccountStatusScope;
201
+ setter?: SetterCloserConfig;
202
+ closer?: SetterCloserConfig;
203
+ selfgen?: SetterCloserConfig;
204
+ isFinalState?: boolean;
205
+ createUser?: boolean;
206
+ columnVisibility?: TeamId[];
207
+ requiredFields?: string[];
208
+ isArchivedState?: boolean;
209
+ };
210
+ export type AccountStatusData = UnsavedAccountStatus & {
211
+ statusId: AccountStatusId;
212
+ isDeleted?: boolean;
213
+ createdAt?: number;
214
+ createdBy?: UserId;
215
+ updatedAt?: number;
216
+ updatedBy?: UserId;
217
+ };
218
+ export type TinyAccountStatus = Pick<AccountStatusData, 'name' | 'statusId'>;
219
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,122 @@
1
+ import type { ApiSuccess } from '../shared.ts';
2
+ import type { AvailableCloser, RoleId, TeamId, TinyCloser, UserId } from '../user/model.ts';
3
+ import type { LatLng } from '../location/model.ts';
4
+ import type { AccountId, LocationId, UpsertLatLng } from '../account/model.ts';
5
+ import type { CalendarEventData, CalendarEventDataWithDetails, CalendarEventId, EventType, UnsavedCalendarEventData } from './model.ts';
6
+ type CalendarEventRoleFilter = 'owner' | 'attendee';
7
+ type OptionalCalendarEventLocation = UpsertLatLng & {
8
+ locationId?: LocationId;
9
+ oneLine?: string;
10
+ };
11
+ /** A yes/no/unset filter — matches events where the field is true, false, unset, or set to any value. */
12
+ type BooleanFilter = 'true' | 'false' | 'undefined' | 'defined';
13
+ export type CalendarAvailabilityInput = {
14
+ /** UTC milliseconds. */
15
+ startDate: number;
16
+ /** Minutes. Defaults to 30. */
17
+ duration?: number;
18
+ teamId?: TeamId;
19
+ };
20
+ export type CalendarAvailabilitySuccess = ApiSuccess<{
21
+ available: boolean;
22
+ }>;
23
+ export type CalendarClosersInput = CalendarAvailabilityInput & {
24
+ latLng?: LatLng;
25
+ };
26
+ export type CalendarClosersSuccess = ApiSuccess<{
27
+ closers: AvailableCloser[];
28
+ }>;
29
+ export type CalendarTimeslotsInput = {
30
+ targetId?: TeamId | UserId;
31
+ days?: number;
32
+ locationId?: LocationId;
33
+ /** UTC milliseconds. */
34
+ startTime?: number;
35
+ };
36
+ export type CalendarTimeslotsSuccess = ApiSuccess<{
37
+ closers: TinyCloser[];
38
+ }>;
39
+ export type CalendarEventAddInput = {
40
+ event: UnsavedCalendarEventData;
41
+ /** Defaults to true. */
42
+ errorOnCloserUnavailable?: boolean;
43
+ };
44
+ export type CalendarEventAddSuccess = ApiSuccess<{
45
+ event: CalendarEventData;
46
+ }>;
47
+ export type CalendarEventGetInput = {
48
+ eventId: CalendarEventId;
49
+ };
50
+ export type CalendarEventGetSuccess = ApiSuccess<{
51
+ event: CalendarEventDataWithDetails;
52
+ }>;
53
+ export type CalendarEventListInput = {
54
+ startTime?: number;
55
+ endTime?: number;
56
+ ownerId?: UserId;
57
+ locationId?: LocationId;
58
+ companyId?: string;
59
+ /** @deprecated use teamIds */
60
+ teamId?: TeamId;
61
+ teamIds?: TeamId[];
62
+ roleIds?: RoleId[];
63
+ occurred?: BooleanFilter;
64
+ closed?: BooleanFilter;
65
+ eventType?: EventType;
66
+ filterByRoles?: CalendarEventRoleFilter[];
67
+ };
68
+ export type CalendarEventListSuccess = ApiSuccess<{
69
+ events: CalendarEventDataWithDetails[];
70
+ }>;
71
+ export type CalendarEventUpdateInput = {
72
+ event: Partial<CalendarEventData> & {
73
+ eventId: CalendarEventId;
74
+ attendeeId?: UserId | null;
75
+ };
76
+ errorOnCloserUnavailable?: boolean;
77
+ };
78
+ export type CalendarEventUpdateSuccess = ApiSuccess<{
79
+ event: CalendarEventData;
80
+ }>;
81
+ export type CalendarEventUpsertInput = {
82
+ event: Partial<{
83
+ eventId: CalendarEventId;
84
+ sourceId: string;
85
+ /** Defaults to 'Consultation' on create. */
86
+ eventType: string;
87
+ title: string;
88
+ /** Defaults to now on create. */
89
+ eventDate: string | number;
90
+ /** An EventOutcomeId, integration mapping string, or case-insensitive name. */
91
+ outcomeId: string;
92
+ /** Minutes. */
93
+ duration: number;
94
+ accountId: AccountId;
95
+ location: OptionalCalendarEventLocation;
96
+ /** A UserId or email. Defaults to the authenticated user on create. */
97
+ ownerId: string;
98
+ /** A UserId or email. Pass null to clear on update. */
99
+ attendeeId: string | null;
100
+ /** A UserId or email. */
101
+ dispatcherId: string;
102
+ occurredOwner: boolean;
103
+ occurredAttendee: boolean;
104
+ notes: string;
105
+ previousEventId: CalendarEventId;
106
+ }>;
107
+ };
108
+ export type CalendarEventUpsertSuccess = ApiSuccess<{
109
+ event: CalendarEventData;
110
+ }>;
111
+ export type CalendarEventConfirmInput = {
112
+ eventId: CalendarEventId;
113
+ occurred?: boolean;
114
+ };
115
+ export type CalendarEventConfirmSuccess = ApiSuccess<{
116
+ event: CalendarEventData;
117
+ }>;
118
+ export type CalendarEventRemoveInput = {
119
+ archive?: boolean;
120
+ eventId: CalendarEventId;
121
+ };
122
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './model.ts';
2
+ export * from './api.ts';
@@ -0,0 +1,2 @@
1
+ export * from "./model.js";
2
+ export * from "./api.js";
@@ -0,0 +1,83 @@
1
+ import type { SmallUser, TeamId, UserId } from '../user/model.ts';
2
+ import type { TinyTeam } from '../team/model.ts';
3
+ import type { Address, LatLng } from '../location/model.ts';
4
+ import type { AccountId, DispositionId, LocationId, TinyResidentData, TinyWorkflowAccount } from '../account/model.ts';
5
+ export type CalendarEventId = `Event:${string}` | `Event.${string}`;
6
+ /** @deprecated */
7
+ export type EventOutcomeId = `O.${string}`;
8
+ export type InterviewId = `Interview:${string}` | `Interview.${string}`;
9
+ export type AttachmentId = `Attachment:${string}` | `Attachment.${string}`;
10
+ export type EventType = 'Consultation' | 'Comeback' | 'Interview' | 'GeneralVisit' | 'Shadow' | 'Team';
11
+ export type SpecialtyAttachments = {
12
+ utilityBill?: AttachmentId;
13
+ customerVerification?: AttachmentId;
14
+ };
15
+ /** @deprecated */
16
+ export type SyncedCalendarEvent = {
17
+ calendarType: string;
18
+ calendarId: string;
19
+ userId: UserId;
20
+ deviceId: string;
21
+ eventId: string;
22
+ };
23
+ export type CalendarEventLocation = Pick<Address, 'oneLine'> & LatLng;
24
+ export type UnsavedCalendarEventData = {
25
+ importId?: string;
26
+ eventType: EventType;
27
+ title: string;
28
+ sourceId?: string;
29
+ /** UTC milliseconds. */
30
+ eventDate: number;
31
+ outcomeId?: EventOutcomeId;
32
+ dispositionId?: DispositionId;
33
+ /** Minutes. */
34
+ duration: number;
35
+ attachments?: AttachmentId[];
36
+ specialtyAttachments?: SpecialtyAttachments;
37
+ accountId?: AccountId;
38
+ locationId?: LocationId;
39
+ location?: CalendarEventLocation;
40
+ ownerId?: UserId;
41
+ attendeeId?: UserId;
42
+ dispatcherId?: UserId;
43
+ occurredOwner?: boolean;
44
+ occurredAttendee?: boolean;
45
+ interviewId?: InterviewId;
46
+ /** @deprecated */
47
+ notes?: string;
48
+ previousEventId?: CalendarEventId;
49
+ /** @deprecated */
50
+ syncedCalendarIds?: string[];
51
+ /** @deprecated */
52
+ syncedCalendarEvents?: SyncedCalendarEvent[];
53
+ teamId?: TeamId;
54
+ };
55
+ export type EventOutcomeHistory = {
56
+ outcomeId: EventOutcomeId;
57
+ userId: UserId;
58
+ timestamp: number;
59
+ };
60
+ type SitOutcomeFault = string;
61
+ export type CalendarEventData = UnsavedCalendarEventData & {
62
+ outcomeHistory?: EventOutcomeHistory[];
63
+ createdAt?: number;
64
+ createdBy?: UserId;
65
+ updatedAt?: number;
66
+ updatedBy?: UserId;
67
+ eventId: CalendarEventId;
68
+ ownerId: UserId;
69
+ occurred?: boolean;
70
+ closed?: boolean;
71
+ reasonNotOccurred?: string;
72
+ fault?: SitOutcomeFault;
73
+ allDay?: boolean;
74
+ canDelete?: boolean;
75
+ };
76
+ export type CalendarEventDataWithDetails = CalendarEventData & {
77
+ resident?: TinyResidentData;
78
+ owner?: SmallUser;
79
+ attendee?: SmallUser;
80
+ teams?: TinyTeam[];
81
+ account?: TinyWorkflowAccount;
82
+ };
83
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './model.ts';
@@ -0,0 +1 @@
1
+ export * from "./model.js";
@@ -0,0 +1,37 @@
1
+ import type { UserId } from '../user/model.ts';
2
+ export type CompanyState = 'active' | 'trial' | 'internal' | 'demo' | 'sandbox' | 'template' | 'suspended';
3
+ export type CompanyKind = 'customer' | 'sandbox' | 'demo' | 'template' | 'development';
4
+ export type AccessStatus = 'active' | 'suspended';
5
+ export type BillingMethod = 'stripe' | 'none';
6
+ export type CompanyIndustry = 'solar' | 'pest' | 'alarm' | 'roofing' | 'fiber' | 'insurance' | 'home_improvement' | 'windows' | 'satellite_tv' | 'retail' | 'other' | 'solar_cleaning';
7
+ export type CompanyId = `C:${string}` | `C.${string}`;
8
+ export type CompanyData = {
9
+ companyId: CompanyId;
10
+ name: string;
11
+ legalName?: string;
12
+ kind?: CompanyKind;
13
+ accessStatus?: AccessStatus;
14
+ internalOwnerId?: UserId;
15
+ billingEmail?: string;
16
+ billingMethod?: BillingMethod;
17
+ state: CompanyState;
18
+ maxUsers?: number;
19
+ size?: number;
20
+ industries?: CompanyIndustry[];
21
+ salesChannels?: string[];
22
+ highestTeamLevel?: number;
23
+ lowestTeamLevel?: number;
24
+ levelNames?: Record<string, string>;
25
+ timeZone?: string;
26
+ avatarUrl?: string;
27
+ avatarBlurhash?: string;
28
+ uploadAvatarUrl?: string;
29
+ iconUrl?: string;
30
+ iconBlurhash?: string;
31
+ uploadIconUrl?: string;
32
+ isDeleted?: boolean;
33
+ createdAt?: number;
34
+ createdBy?: UserId;
35
+ updatedAt?: number;
36
+ updatedBy?: UserId;
37
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './shared.ts';
2
+ export * from './location/index.ts';
3
+ export * from './team/index.ts';
4
+ export * from './company/index.ts';
5
+ export * from './user/index.ts';
6
+ export * from './account/index.ts';
7
+ export * from './calendar/index.ts';
@@ -0,0 +1,7 @@
1
+ export * from "./shared.js";
2
+ export * from "./location/index.js";
3
+ export * from "./team/index.js";
4
+ export * from "./company/index.js";
5
+ export * from "./user/index.js";
6
+ export * from "./account/index.js";
7
+ export * from "./calendar/index.js";
@@ -0,0 +1 @@
1
+ export * from './model.ts';
@@ -0,0 +1 @@
1
+ export * from "./model.js";
@@ -0,0 +1,21 @@
1
+ export type LatLng = {
2
+ latitude: number;
3
+ longitude: number;
4
+ };
5
+ export type Address = {
6
+ country: 'US' | 'CA' | 'PR';
7
+ countrySubd: string;
8
+ line1: string;
9
+ line2: string;
10
+ locality: string;
11
+ oneLine: string;
12
+ postal1: string;
13
+ postal2?: string;
14
+ postal3?: string;
15
+ unitNbr?: string;
16
+ };
17
+ export type SmallAddress = Pick<Address, 'countrySubd' | 'line1' | 'locality' | 'postal1' | 'postal2' | 'postal3' | 'unitNbr'> & {
18
+ line2?: string;
19
+ oneLine?: string;
20
+ latlng: LatLng;
21
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { UserId } from './user/model.ts';
2
+ /** A Connect API route string, e.g. "user/get" or "account/status/add". */
3
+ export type ApiRoute = string;
4
+ export type ApiSuccess<T = unknown> = {
5
+ type: 'success';
6
+ } & T;
7
+ export type ResponseError = {
8
+ type: 'error';
9
+ error: string;
10
+ message?: string;
11
+ retry?: boolean;
12
+ };
13
+ export type ResponseOutput = ApiSuccess | ResponseError;
14
+ export declare function isResponseError(response: unknown): response is ResponseError;
15
+ export type CustomFieldMap = Record<string, string | number | boolean | null>;
16
+ export type AuditLog = {
17
+ userId: UserId;
18
+ timestamp: number;
19
+ updateProcess?: string;
20
+ };
21
+ export type AuditProps = {
22
+ modifiedBy?: AuditLog[];
23
+ /** @deprecated */
24
+ createdAt?: number;
25
+ /** @deprecated */
26
+ createdBy?: UserId;
27
+ updatedAt?: number;
28
+ /** @deprecated */
29
+ updatedBy?: UserId;
30
+ lastUpdateProcess?: string;
31
+ version?: number;
32
+ };
@@ -0,0 +1,6 @@
1
+ export function isResponseError(response) {
2
+ return (typeof response === 'object' &&
3
+ response !== null &&
4
+ response.type === 'error' &&
5
+ Boolean(response.error));
6
+ }
@@ -0,0 +1 @@
1
+ export * from './model.ts';
@@ -0,0 +1 @@
1
+ export * from "./model.js";
@@ -0,0 +1,17 @@
1
+ import type { TeamId } from '../user/model.ts';
2
+ export 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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,111 @@
1
+ import type { ApiSuccess } from '../shared.ts';
2
+ import type { CompanyData, CompanyId } from '../company/model.ts';
3
+ import type { CloserStatus, EntityId, RoleId, SmallCloser, SmallUser, TeamId, TinyUser, UnsavedUser, UserData, UserId, UserIdentifier, UserProfileData } from './model.ts';
4
+ export type UserListInput = {
5
+ showArchived?: true | false | 'all';
6
+ companyId?: CompanyId;
7
+ teamId?: TeamId;
8
+ userIds?: UserId[];
9
+ showBeta?: boolean;
10
+ };
11
+ export type UserListSuccess = ApiSuccess<{
12
+ users: SmallUser[];
13
+ }>;
14
+ export type UserAddInput = {
15
+ user: UnsavedUser & {
16
+ userId?: UserId;
17
+ };
18
+ teamMemberships?: {
19
+ teamId: TeamId;
20
+ roleIds?: RoleId[];
21
+ }[];
22
+ directRoles?: RoleId[];
23
+ };
24
+ export type UserAddSuccess = ApiSuccess<{
25
+ user: UserProfileData;
26
+ password?: string;
27
+ }>;
28
+ export type UserUpdateInput = {
29
+ user: Partial<UserProfileData>;
30
+ };
31
+ export type UserUpdateSuccess = ApiSuccess<{
32
+ user: UserProfileData;
33
+ }>;
34
+ export type UserBulkUpdateInput = {
35
+ entityIds: EntityId[];
36
+ operation: {
37
+ type: 'invalidateCloserSettings';
38
+ };
39
+ };
40
+ export type UserBulkUpdateSuccess = ApiSuccess<{
41
+ updatedCount: number;
42
+ }>;
43
+ export type UserRemoveInput = {
44
+ archive?: boolean;
45
+ userId: UserIdentifier;
46
+ } | {
47
+ archive?: boolean;
48
+ userIds: UserId[];
49
+ };
50
+ export type UserGetInput = {
51
+ /** User ID, email, or clientUserId. Defaults to the current user if not provided. */
52
+ userId?: UserIdentifier;
53
+ };
54
+ export type UserGetSuccess = ApiSuccess<{
55
+ user: UserData;
56
+ }>;
57
+ export type UserProfileInput = {
58
+ userId?: string;
59
+ };
60
+ export type UserProfileSuccess = ApiSuccess<{
61
+ user: UserProfileData;
62
+ company: CompanyData;
63
+ }>;
64
+ export type UserSearchInput = {
65
+ archived?: true | false | 'all';
66
+ companyId?: CompanyId;
67
+ query: string;
68
+ teamIds?: TeamId[];
69
+ closerStatus?: CloserStatus[];
70
+ options?: {
71
+ /** Show the first 20 users from your downline. */
72
+ downline?: boolean;
73
+ size?: number;
74
+ };
75
+ };
76
+ export type UserSearchSuccess = ApiSuccess<{
77
+ users: TinyUser[];
78
+ }>;
79
+ export type UserTimezoneInput = {
80
+ timeZone: string;
81
+ };
82
+ export type UserReportInput = {
83
+ userId?: UserId;
84
+ };
85
+ export type UserReportSuccess = ApiSuccess<{
86
+ manager?: TinyUser;
87
+ managers: TinyUser[];
88
+ members: TinyUser[];
89
+ directReports: TinyUser[];
90
+ }>;
91
+ export type UserClosersInput = {
92
+ /**
93
+ * CompanyId: all closers in the company.
94
+ * TeamId: all closers from the highest relevant parent team and its downline.
95
+ * TeamId + direct: all closers directly on the team.
96
+ * UserId: the target user's closer settings.
97
+ * Omitted: all closers from the user's teams, their highest relevant parent team, and its downline.
98
+ */
99
+ entityId?: EntityId;
100
+ direct?: boolean;
101
+ };
102
+ export type UserClosersSuccess = ApiSuccess<{
103
+ closers: SmallCloser[];
104
+ }>;
105
+ export type UserManagerInput = {
106
+ userId?: UserId;
107
+ };
108
+ export type UserManagerSuccess = ApiSuccess<{
109
+ possibleManagers: TinyUser[];
110
+ primaryManager?: TinyUser;
111
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './model.ts';
2
+ export * from './api.ts';
@@ -0,0 +1,2 @@
1
+ export * from "./model.js";
2
+ export * from "./api.js";
@@ -0,0 +1,179 @@
1
+ import type { TinyTeam } from '../team/model.ts';
2
+ import type { AuditProps, CustomFieldMap } from '../shared.ts';
3
+ import type { Address } from '../location/model.ts';
4
+ import type { CompanyId } from '../company/model.ts';
5
+ export type UserId = `U:${string}` | `U.${string}`;
6
+ export type TeamId = `Team:${string}` | `Team.${string}`;
7
+ export type RoleId = `Role.${string}`;
8
+ /** A user ID, email, or clientUserId. */
9
+ export type UserIdentifier = string;
10
+ export type CloserStatus = 'None' | 'Needs_Help' | 'Can_Close' | 'Can_Help' | 'Closer_Only';
11
+ export type TinyRole = {
12
+ roleId: RoleId;
13
+ roleType: 'admin' | 'manager' | 'recruit' | null;
14
+ name: string;
15
+ };
16
+ export type TinyUser = {
17
+ userId: UserId;
18
+ clientUserId?: string;
19
+ firstName: string;
20
+ lastName: string;
21
+ preferredName?: string;
22
+ avatarBlurhash?: string;
23
+ avatarUrl?: string;
24
+ lastAccess?: number;
25
+ isDeleted?: boolean;
26
+ color?: string;
27
+ };
28
+ export type SmallUser = TinyUser & {
29
+ email: string;
30
+ phone?: string;
31
+ title?: string;
32
+ timeZone?: string;
33
+ teamIds?: TeamId[];
34
+ closerStatus?: CloserStatus;
35
+ roles?: TinyRole[];
36
+ memberOf?: Pick<TinyTeam, 'teamId' | 'name'>[];
37
+ companyId?: CompanyId;
38
+ };
39
+ export type Weekday = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
40
+ export type CloserSettings = {
41
+ order?: number;
42
+ taskLockout?: boolean;
43
+ bookingPercent?: number;
44
+ meetingDuration?: number;
45
+ timeBetweenAppointments?: number;
46
+ serviceCenter?: {
47
+ latitude: number;
48
+ longitude: number;
49
+ };
50
+ serviceRadius?: number;
51
+ minimumNotice?: number;
52
+ maximumNotice?: number;
53
+ timeslots?: Partial<Record<Weekday, number[]>>;
54
+ excludes?: number[];
55
+ includes?: number[];
56
+ lastUpdatedDate?: number;
57
+ };
58
+ export type TinyCloser = {
59
+ user: TinyUser;
60
+ times: {
61
+ startTime: number;
62
+ duration: number;
63
+ }[];
64
+ };
65
+ export type SmallCloser = TinyUser & CloserSettings & {
66
+ timezone: string;
67
+ };
68
+ export type AvailableCloser = TinyUser & {
69
+ inServiceArea?: boolean;
70
+ available: boolean;
71
+ locked?: boolean;
72
+ unavailableReason?: string;
73
+ };
74
+ type UserScope = {
75
+ entity: 'self' | 'company' | 'withinRestrictions' | 'none';
76
+ } | {
77
+ entity: 'downline';
78
+ entityId: UserId | TeamId;
79
+ };
80
+ type PermissionEntityId = EntityId | RoleId;
81
+ type ScopeWithSource = UserScope & AuditProps & {
82
+ source: PermissionEntityId;
83
+ };
84
+ type PermissionType = string;
85
+ /** A reduced view of a user's permission overrides, keyed by permission type. */
86
+ export type PermissionMap = Partial<Record<PermissionType, ScopeWithSource[]>>;
87
+ export type NotificationPreference = {
88
+ push?: boolean;
89
+ email?: boolean;
90
+ };
91
+ export type UserPreferences = Partial<Record<string, NotificationPreference>>;
92
+ export type UnsavedUser = {
93
+ isDeleted?: boolean;
94
+ importId?: string;
95
+ phone?: string;
96
+ firstName: string;
97
+ lastName: string;
98
+ preferredName?: string;
99
+ email: string;
100
+ timeZone?: string;
101
+ clientUserId?: string;
102
+ title?: string;
103
+ closerStatus?: CloserStatus;
104
+ companyId?: CompanyId;
105
+ managerId?: UserId;
106
+ hasManager?: boolean;
107
+ selfReportedManager?: {
108
+ managerId?: UserId;
109
+ updatedAt: number;
110
+ };
111
+ primaryTeam?: {
112
+ teamId: TeamId;
113
+ staleAfter: number;
114
+ };
115
+ betaProgram?: boolean;
116
+ language?: string;
117
+ secondaryLanguages?: string[];
118
+ color?: string;
119
+ superuserScore?: number;
120
+ customFields?: CustomFieldMap;
121
+ accountId?: string;
122
+ whitelist?: boolean;
123
+ closer?: CloserSettings;
124
+ };
125
+ export type UserTeamsByLevel = {
126
+ team1?: TinyTeam[];
127
+ team2?: TinyTeam[];
128
+ team3?: TinyTeam[];
129
+ team4?: TinyTeam[];
130
+ team5?: TinyTeam[];
131
+ team6?: TinyTeam[];
132
+ team7?: TinyTeam[];
133
+ team8?: TinyTeam[];
134
+ groups: TinyTeam[];
135
+ };
136
+ export type UserTeamData = UserTeamsByLevel & {
137
+ manages: TeamId[];
138
+ directMemberOf: TinyTeam[];
139
+ memberOf: TinyTeam[];
140
+ managers: TinyUser[];
141
+ manager?: TinyUser;
142
+ };
143
+ export type UserData = UnsavedUser & {
144
+ lastAccess?: number;
145
+ avatarBlurhash?: string;
146
+ avatarUrl?: string;
147
+ userId: UserId;
148
+ companyId: CompanyId;
149
+ firstAccess?: number;
150
+ startDate?: number;
151
+ clientTeamId?: string;
152
+ teams?: UserTeamData;
153
+ roles?: TinyRole[];
154
+ biography?: string;
155
+ notificationPrefs?: UserPreferences;
156
+ agreeToTerms?: number;
157
+ agreeToLicensing?: number;
158
+ agreeToAITraining?: boolean;
159
+ };
160
+ export type UserProfileData = UserData & {
161
+ createdAt?: number;
162
+ createdBy?: UserId;
163
+ updatedAt?: number;
164
+ updatedBy?: UserId;
165
+ permissionMap?: PermissionMap;
166
+ mailingAddress?: Address;
167
+ shoeSize?: string;
168
+ shirtSize?: string;
169
+ birth?: {
170
+ month?: number;
171
+ day?: number;
172
+ };
173
+ uploadAvatarUrl?: string;
174
+ closerIds?: UserId[];
175
+ directRoles?: TinyRole[];
176
+ };
177
+ /** Every entity type that can own users/teams in bulk operations. */
178
+ export type EntityId = UserId | TeamId | CompanyId;
179
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "author": "Terros Inc.",
3
+ "bugs": {
4
+ "url": "https://github.com/terros-inc/sdk/issues"
5
+ },
6
+ "description": "Typescript SDK for Terros Sales platform",
7
+ "devDependencies": {
8
+ "@types/node": "^24.13.2",
9
+ "oxfmt": "^0.56.0",
10
+ "oxlint": "^1.71.0",
11
+ "typescript": "^6.0.3",
12
+ "vitest": "^4.1.9"
13
+ },
14
+ "engines": {
15
+ "node": "^24"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "homepage": "https://github.com/terros-inc/sdk#readme",
21
+ "keywords": [
22
+ "terros",
23
+ "sdk"
24
+ ],
25
+ "license": "MIT",
26
+ "main": "./dist/index.js",
27
+ "name": "@terros-inc/sdk",
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "tag": "latest"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/terros-inc/sdk.git"
35
+ },
36
+ "type": "module",
37
+ "version": "1.0.0",
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "format": "oxfmt --write .",
41
+ "lint": "oxlint",
42
+ "lint:fix": "oxlint --fix",
43
+ "test": "vitest run"
44
+ }
45
+ }