@terros-inc/sdk 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +333 -189
- package/dist/index.mjs +39 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -18,11 +18,13 @@ type TerrosClientConfig = {
|
|
|
18
18
|
apiKey?: string;
|
|
19
19
|
baseUrl?: string;
|
|
20
20
|
analytics?: TerrosHeaderMetadata;
|
|
21
|
+
impersonateUserId?: string;
|
|
21
22
|
};
|
|
22
23
|
declare class TerrosApiClient {
|
|
23
24
|
private readonly baseUrl;
|
|
24
25
|
private readonly authStrategy;
|
|
25
26
|
private readonly analytics;
|
|
27
|
+
private readonly impersonateUserId;
|
|
26
28
|
constructor(config?: TerrosClientConfig);
|
|
27
29
|
call<Success>(route: ApiRoute, input: object): Promise<Success>;
|
|
28
30
|
private getAuthorizationHeader;
|
|
@@ -49,7 +51,6 @@ type TinyTeam = {
|
|
|
49
51
|
};
|
|
50
52
|
//#endregion
|
|
51
53
|
//#region src/models/shared.d.ts
|
|
52
|
-
type CustomFieldMap = Record<string, string | number | boolean | null>;
|
|
53
54
|
type AuditLog = {
|
|
54
55
|
userId: UserId;
|
|
55
56
|
timestamp: number;
|
|
@@ -88,6 +89,208 @@ type SmallAddress = Pick<Address, 'countrySubd' | 'line1' | 'locality' | 'postal
|
|
|
88
89
|
latlng: LatLng;
|
|
89
90
|
};
|
|
90
91
|
//#endregion
|
|
92
|
+
//#region src/models/calendar/model.d.ts
|
|
93
|
+
type CalendarEventId = `Event:${string}` | `Event.${string}`;
|
|
94
|
+
/** @deprecated */
|
|
95
|
+
type EventOutcomeId = `O.${string}`;
|
|
96
|
+
type InterviewId = `Interview:${string}` | `Interview.${string}`;
|
|
97
|
+
type AttachmentId = `Attachment:${string}` | `Attachment.${string}`;
|
|
98
|
+
type EventType = 'Consultation' | 'Comeback' | 'Interview' | 'GeneralVisit' | 'Shadow' | 'Team';
|
|
99
|
+
type SpecialtyAttachments = {
|
|
100
|
+
utilityBill?: AttachmentId;
|
|
101
|
+
customerVerification?: AttachmentId;
|
|
102
|
+
};
|
|
103
|
+
/** @deprecated */
|
|
104
|
+
type SyncedCalendarEvent = {
|
|
105
|
+
calendarType: string;
|
|
106
|
+
calendarId: string;
|
|
107
|
+
userId: UserId;
|
|
108
|
+
deviceId: string;
|
|
109
|
+
eventId: string;
|
|
110
|
+
};
|
|
111
|
+
type CalendarEventLocation = Pick<Address, 'oneLine'> & LatLng;
|
|
112
|
+
type UnsavedCalendarEventData = {
|
|
113
|
+
importId?: string;
|
|
114
|
+
eventType: EventType;
|
|
115
|
+
title: string;
|
|
116
|
+
sourceId?: string; /** UTC milliseconds. */
|
|
117
|
+
eventDate: number;
|
|
118
|
+
outcomeId?: EventOutcomeId;
|
|
119
|
+
dispositionId?: DispositionId; /** Minutes. */
|
|
120
|
+
duration: number;
|
|
121
|
+
attachments?: AttachmentId[];
|
|
122
|
+
specialtyAttachments?: SpecialtyAttachments;
|
|
123
|
+
accountId?: AccountId;
|
|
124
|
+
locationId?: LocationId;
|
|
125
|
+
location?: CalendarEventLocation;
|
|
126
|
+
ownerId?: UserId;
|
|
127
|
+
attendeeId?: UserId;
|
|
128
|
+
dispatcherId?: UserId;
|
|
129
|
+
occurredOwner?: boolean;
|
|
130
|
+
occurredAttendee?: boolean;
|
|
131
|
+
interviewId?: InterviewId; /** @deprecated */
|
|
132
|
+
notes?: string;
|
|
133
|
+
previousEventId?: CalendarEventId; /** @deprecated */
|
|
134
|
+
syncedCalendarIds?: string[]; /** @deprecated */
|
|
135
|
+
syncedCalendarEvents?: SyncedCalendarEvent[];
|
|
136
|
+
teamId?: TeamId;
|
|
137
|
+
};
|
|
138
|
+
type EventOutcomeHistory = {
|
|
139
|
+
outcomeId: EventOutcomeId;
|
|
140
|
+
userId: UserId;
|
|
141
|
+
timestamp: number;
|
|
142
|
+
};
|
|
143
|
+
type SitOutcomeFault = string;
|
|
144
|
+
type CalendarEventData = UnsavedCalendarEventData & {
|
|
145
|
+
outcomeHistory?: EventOutcomeHistory[];
|
|
146
|
+
createdAt?: number;
|
|
147
|
+
createdBy?: UserId;
|
|
148
|
+
updatedAt?: number;
|
|
149
|
+
updatedBy?: UserId;
|
|
150
|
+
eventId: CalendarEventId;
|
|
151
|
+
ownerId: UserId;
|
|
152
|
+
occurred?: boolean;
|
|
153
|
+
closed?: boolean;
|
|
154
|
+
reasonNotOccurred?: string;
|
|
155
|
+
fault?: SitOutcomeFault;
|
|
156
|
+
allDay?: boolean;
|
|
157
|
+
canDelete?: boolean;
|
|
158
|
+
};
|
|
159
|
+
type CalendarEventDataWithDetails = CalendarEventData & {
|
|
160
|
+
resident?: TinyResidentData;
|
|
161
|
+
owner?: SmallUser;
|
|
162
|
+
attendee?: SmallUser;
|
|
163
|
+
teams?: TinyTeam[];
|
|
164
|
+
account?: TinyWorkflowAccount;
|
|
165
|
+
};
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/models/calendar/api.d.ts
|
|
168
|
+
type CalendarEventRoleFilter = 'owner' | 'attendee';
|
|
169
|
+
type OptionalCalendarEventLocation = UpsertLatLng & {
|
|
170
|
+
locationId?: LocationId;
|
|
171
|
+
oneLine?: string;
|
|
172
|
+
};
|
|
173
|
+
/** A yes/no/unset filter — matches events where the field is true, false, unset, or set to any value. */
|
|
174
|
+
type BooleanFilter = 'true' | 'false' | 'undefined' | 'defined';
|
|
175
|
+
type CalendarAvailabilityInput = {
|
|
176
|
+
/** UTC milliseconds. */startDate: number; /** Minutes. Defaults to 30. */
|
|
177
|
+
duration?: number;
|
|
178
|
+
teamId?: TeamId;
|
|
179
|
+
};
|
|
180
|
+
type CalendarAvailabilitySuccess = ApiSuccess<{
|
|
181
|
+
available: boolean;
|
|
182
|
+
}>;
|
|
183
|
+
type CalendarClosersInput = CalendarAvailabilityInput & {
|
|
184
|
+
latLng?: LatLng;
|
|
185
|
+
};
|
|
186
|
+
type CalendarClosersSuccess = ApiSuccess<{
|
|
187
|
+
closers: AvailableCloser[];
|
|
188
|
+
}>;
|
|
189
|
+
type CalendarTimeslotsInput = {
|
|
190
|
+
targetId?: TeamId | UserId;
|
|
191
|
+
days?: number;
|
|
192
|
+
locationId?: LocationId; /** UTC milliseconds. */
|
|
193
|
+
startTime?: number;
|
|
194
|
+
};
|
|
195
|
+
type CalendarTimeslotsSuccess = ApiSuccess<{
|
|
196
|
+
closers: TinyCloser[];
|
|
197
|
+
}>;
|
|
198
|
+
type CalendarEventAddInput = {
|
|
199
|
+
event: UnsavedCalendarEventData; /** Defaults to true. */
|
|
200
|
+
errorOnCloserUnavailable?: boolean;
|
|
201
|
+
};
|
|
202
|
+
type CalendarEventAddSuccess = ApiSuccess<{
|
|
203
|
+
event: CalendarEventData;
|
|
204
|
+
}>;
|
|
205
|
+
type CalendarEventGetInput = {
|
|
206
|
+
eventId: CalendarEventId;
|
|
207
|
+
};
|
|
208
|
+
type CalendarEventGetSuccess = ApiSuccess<{
|
|
209
|
+
event: CalendarEventDataWithDetails;
|
|
210
|
+
}>;
|
|
211
|
+
type CalendarEventListInput = {
|
|
212
|
+
startTime?: number;
|
|
213
|
+
endTime?: number;
|
|
214
|
+
ownerId?: UserId;
|
|
215
|
+
locationId?: LocationId;
|
|
216
|
+
companyId?: string; /** @deprecated use teamIds */
|
|
217
|
+
teamId?: TeamId;
|
|
218
|
+
teamIds?: TeamId[];
|
|
219
|
+
roleIds?: RoleId[];
|
|
220
|
+
occurred?: BooleanFilter;
|
|
221
|
+
closed?: BooleanFilter;
|
|
222
|
+
eventType?: EventType;
|
|
223
|
+
filterByRoles?: CalendarEventRoleFilter[];
|
|
224
|
+
};
|
|
225
|
+
type CalendarEventListSuccess = ApiSuccess<{
|
|
226
|
+
events: CalendarEventDataWithDetails[];
|
|
227
|
+
}>;
|
|
228
|
+
type CalendarEventUpdateInput = {
|
|
229
|
+
event: Partial<CalendarEventData> & {
|
|
230
|
+
eventId: CalendarEventId;
|
|
231
|
+
attendeeId?: UserId | null;
|
|
232
|
+
};
|
|
233
|
+
errorOnCloserUnavailable?: boolean;
|
|
234
|
+
};
|
|
235
|
+
type CalendarEventUpdateSuccess = ApiSuccess<{
|
|
236
|
+
event: CalendarEventData;
|
|
237
|
+
}>;
|
|
238
|
+
type CalendarEventUpsertInput = {
|
|
239
|
+
event: Partial<{
|
|
240
|
+
eventId: CalendarEventId;
|
|
241
|
+
sourceId: string; /** Defaults to 'Consultation' on create. */
|
|
242
|
+
eventType: string;
|
|
243
|
+
title: string; /** Defaults to now on create. */
|
|
244
|
+
eventDate: string | number; /** An EventOutcomeId, integration mapping string, or case-insensitive name. */
|
|
245
|
+
outcomeId: string; /** Minutes. */
|
|
246
|
+
duration: number;
|
|
247
|
+
accountId: AccountId;
|
|
248
|
+
location: OptionalCalendarEventLocation; /** A UserId or email. Defaults to the authenticated user on create. */
|
|
249
|
+
ownerId: string; /** A UserId or email. Pass null to clear on update. */
|
|
250
|
+
attendeeId: string | null; /** A UserId or email. */
|
|
251
|
+
dispatcherId: string;
|
|
252
|
+
occurredOwner: boolean;
|
|
253
|
+
occurredAttendee: boolean;
|
|
254
|
+
notes: string;
|
|
255
|
+
previousEventId: CalendarEventId;
|
|
256
|
+
}>;
|
|
257
|
+
};
|
|
258
|
+
type CalendarEventUpsertSuccess = ApiSuccess<{
|
|
259
|
+
event: CalendarEventData;
|
|
260
|
+
}>;
|
|
261
|
+
type CalendarEventConfirmInput = {
|
|
262
|
+
eventId: CalendarEventId;
|
|
263
|
+
occurred?: boolean;
|
|
264
|
+
};
|
|
265
|
+
type CalendarEventConfirmSuccess = ApiSuccess<{
|
|
266
|
+
event: CalendarEventData;
|
|
267
|
+
}>;
|
|
268
|
+
type CalendarEventRemoveInput = {
|
|
269
|
+
archive?: boolean;
|
|
270
|
+
eventId: CalendarEventId;
|
|
271
|
+
};
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/models/customFields/model.d.ts
|
|
274
|
+
type CustomFieldId = `CF.${string}`;
|
|
275
|
+
/** use null to clear this field */
|
|
276
|
+
type CustomFieldType = string | number | boolean | AttachmentId | null;
|
|
277
|
+
type CustomFieldMap = Record<CustomFieldId, CustomFieldType>;
|
|
278
|
+
type RangeFilter = {
|
|
279
|
+
gte?: number;
|
|
280
|
+
lte?: number;
|
|
281
|
+
};
|
|
282
|
+
type CustomFieldFilter = Record<CustomFieldId, CustomFieldFilterValue>;
|
|
283
|
+
type CustomFieldFilterValue = {
|
|
284
|
+
type: 'range';
|
|
285
|
+
range: RangeFilter;
|
|
286
|
+
} | {
|
|
287
|
+
type: 'multipleChoice';
|
|
288
|
+
values: CustomFieldType[];
|
|
289
|
+
} | {
|
|
290
|
+
type: 'exists';
|
|
291
|
+
exists: boolean;
|
|
292
|
+
};
|
|
293
|
+
//#endregion
|
|
91
294
|
//#region src/models/company/model.d.ts
|
|
92
295
|
type CompanyKind = 'customer' | 'sandbox' | 'demo' | 'template' | 'development';
|
|
93
296
|
type AccessStatus = 'active' | 'suspended';
|
|
@@ -420,10 +623,6 @@ type TagId = `Tag.${string}`;
|
|
|
420
623
|
type LocationId = `Can.${string}` | `LocNew:${string}` | `LocNew.${string}` | `Loc:${string}` | `TLoc:${string}` | `TLoc.${string}` | `FA.${string}` | `PR.${string}`;
|
|
421
624
|
type DispositionId = `Disposition:${string}` | `Disposition.${string}` | 'NotHome' | 'Comeback' | 'NotNow' | 'NotQualified' | 'PartialPitch' | 'NewAccount' | 'Competitor' | 'Custom1' | 'Custom2' | 'Custom3';
|
|
422
625
|
type ContactMethod = 'door' | 'phone';
|
|
423
|
-
type RangeFilter = {
|
|
424
|
-
gte?: number;
|
|
425
|
-
lte?: number;
|
|
426
|
-
};
|
|
427
626
|
/** A cursor for paging through sorted account lists. */
|
|
428
627
|
type SortCursor = number | number[];
|
|
429
628
|
type AccountUserDetails = Omit<SmallUser, 'userId' | 'memberOf'>;
|
|
@@ -539,8 +738,6 @@ type AccountData = Omit<UnsavedAccount, 'contacts' | 'notes'> & {
|
|
|
539
738
|
};
|
|
540
739
|
type AccountSortBy = 'createdDate' | 'lastActionDate' | 'lastUpdatedDate' | `CF.${string}`;
|
|
541
740
|
type AccountSortOrder = 'asc' | 'desc';
|
|
542
|
-
/** Not modeled in detail by this SDK — treat as an opaque record. */
|
|
543
|
-
type CustomFieldFilter = Record<string, unknown>;
|
|
544
741
|
type AccountDataResponse = {
|
|
545
742
|
accounts: AccountData[];
|
|
546
743
|
sortTimestamp?: SortCursor;
|
|
@@ -552,28 +749,13 @@ type BulkModifyAccountsAction = ({
|
|
|
552
749
|
} | {
|
|
553
750
|
actionType: 'updateStage';
|
|
554
751
|
stageId: WorkflowStageId;
|
|
752
|
+
} | {
|
|
753
|
+
actionType: 'updateCustomField';
|
|
754
|
+
fieldId: CustomFieldId;
|
|
755
|
+
value: CustomFieldType;
|
|
555
756
|
} | {
|
|
556
757
|
actionType: 'delete' | 'clearDisposition';
|
|
557
758
|
})[];
|
|
558
|
-
/** Not modeled in detail by this SDK — treat as an opaque record. */
|
|
559
|
-
type ElasticFilter = {
|
|
560
|
-
cities?: string[];
|
|
561
|
-
states?: string[];
|
|
562
|
-
zipCodes?: string[];
|
|
563
|
-
advancedCustomFields?: CustomFieldFilter;
|
|
564
|
-
statusIds?: AccountStatusId[];
|
|
565
|
-
workflowStageIds?: WorkflowStageId[];
|
|
566
|
-
tagIds?: TagId[];
|
|
567
|
-
teamIds?: TeamId[];
|
|
568
|
-
userIds?: UserId[];
|
|
569
|
-
coordinates?: LatLng[];
|
|
570
|
-
boundingBox?: {
|
|
571
|
-
top: LatLng;
|
|
572
|
-
bottom: LatLng;
|
|
573
|
-
};
|
|
574
|
-
workflowActionCount?: RangeFilter;
|
|
575
|
-
contactCount?: RangeFilter;
|
|
576
|
-
};
|
|
577
759
|
type PartialAddress = Partial<Omit<SmallAddress, 'latlng'>> & {
|
|
578
760
|
latlng?: Partial<LatLng>;
|
|
579
761
|
};
|
|
@@ -622,6 +804,24 @@ type AccountStatusData = UnsavedAccountStatus & {
|
|
|
622
804
|
type TinyAccountStatus = Pick<AccountStatusData, 'name' | 'statusId'>;
|
|
623
805
|
//#endregion
|
|
624
806
|
//#region src/models/account/api.d.ts
|
|
807
|
+
type ElasticFilter = {
|
|
808
|
+
cities?: string[];
|
|
809
|
+
states?: string[];
|
|
810
|
+
zipCodes?: string[];
|
|
811
|
+
advancedCustomFields?: CustomFieldFilter;
|
|
812
|
+
statusIds?: AccountStatusId[];
|
|
813
|
+
workflowStageIds?: WorkflowStageId[];
|
|
814
|
+
tagIds?: TagId[];
|
|
815
|
+
teamIds?: TeamId[];
|
|
816
|
+
userIds?: UserId[];
|
|
817
|
+
coordinates?: LatLng[];
|
|
818
|
+
boundingBox?: {
|
|
819
|
+
top: LatLng;
|
|
820
|
+
bottom: LatLng;
|
|
821
|
+
};
|
|
822
|
+
workflowActionCount?: RangeFilter;
|
|
823
|
+
contactCount?: RangeFilter;
|
|
824
|
+
};
|
|
625
825
|
type AccountStatusSearchInput = {
|
|
626
826
|
accountIds?: AccountId[];
|
|
627
827
|
workflowId?: WorkflowId;
|
|
@@ -777,185 +977,112 @@ type AccountStatusRemoveInput = {
|
|
|
777
977
|
statusId: AccountStatusId;
|
|
778
978
|
};
|
|
779
979
|
//#endregion
|
|
780
|
-
//#region src/models/
|
|
781
|
-
type
|
|
782
|
-
|
|
783
|
-
type
|
|
784
|
-
type
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
980
|
+
//#region src/models/area/model.d.ts
|
|
981
|
+
type AreaId = `Area.${string}`;
|
|
982
|
+
type AreaAssignmentType = 'user' | 'team' | 'company' | 'draft';
|
|
983
|
+
type AreaRunType = 'assign' | 'unassign' | 'reassign';
|
|
984
|
+
type AreaFilters = {
|
|
985
|
+
cities?: string[];
|
|
986
|
+
states?: string[];
|
|
987
|
+
zipCodes?: string[];
|
|
988
|
+
statusIds?: AccountStatusId[];
|
|
989
|
+
workflowStageIds?: WorkflowStageId[];
|
|
990
|
+
teamIds?: TeamId[];
|
|
991
|
+
userIds?: UserId[];
|
|
992
|
+
customFields?: {
|
|
993
|
+
id: CustomFieldId;
|
|
994
|
+
value: CustomFieldType;
|
|
995
|
+
}[];
|
|
996
|
+
advancedCustomFields?: CustomFieldFilter;
|
|
790
997
|
};
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
998
|
+
type AreaAssignmentConfig = {
|
|
999
|
+
enabled: false;
|
|
1000
|
+
autoRunOnImport?: boolean;
|
|
1001
|
+
} | {
|
|
1002
|
+
enabled: true;
|
|
1003
|
+
autoRunOnImport?: boolean;
|
|
1004
|
+
order: number;
|
|
798
1005
|
};
|
|
799
|
-
type
|
|
800
|
-
type
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
eventDate: number;
|
|
806
|
-
outcomeId?: EventOutcomeId;
|
|
807
|
-
dispositionId?: DispositionId; /** Minutes. */
|
|
808
|
-
duration: number;
|
|
809
|
-
attachments?: AttachmentId[];
|
|
810
|
-
specialtyAttachments?: SpecialtyAttachments;
|
|
811
|
-
accountId?: AccountId;
|
|
812
|
-
locationId?: LocationId;
|
|
813
|
-
location?: CalendarEventLocation;
|
|
814
|
-
ownerId?: UserId;
|
|
815
|
-
attendeeId?: UserId;
|
|
816
|
-
dispatcherId?: UserId;
|
|
817
|
-
occurredOwner?: boolean;
|
|
818
|
-
occurredAttendee?: boolean;
|
|
819
|
-
interviewId?: InterviewId; /** @deprecated */
|
|
820
|
-
notes?: string;
|
|
821
|
-
previousEventId?: CalendarEventId; /** @deprecated */
|
|
822
|
-
syncedCalendarIds?: string[]; /** @deprecated */
|
|
823
|
-
syncedCalendarEvents?: SyncedCalendarEvent[];
|
|
1006
|
+
type AreaScheduleEntry = {
|
|
1007
|
+
type: 'assign' | 'unassign';
|
|
1008
|
+
at: number;
|
|
1009
|
+
} | {
|
|
1010
|
+
type: 'reassign';
|
|
1011
|
+
at: number;
|
|
824
1012
|
teamId?: TeamId;
|
|
1013
|
+
userIds?: UserId[];
|
|
825
1014
|
};
|
|
826
|
-
type
|
|
827
|
-
outcomeId: EventOutcomeId;
|
|
828
|
-
userId: UserId;
|
|
1015
|
+
type AreaRunHistoryEntry = {
|
|
829
1016
|
timestamp: number;
|
|
830
|
-
|
|
831
|
-
type
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
createdAt?: number;
|
|
835
|
-
createdBy?: UserId;
|
|
836
|
-
updatedAt?: number;
|
|
837
|
-
updatedBy?: UserId;
|
|
838
|
-
eventId: CalendarEventId;
|
|
839
|
-
ownerId: UserId;
|
|
840
|
-
occurred?: boolean;
|
|
841
|
-
closed?: boolean;
|
|
842
|
-
reasonNotOccurred?: string;
|
|
843
|
-
fault?: SitOutcomeFault;
|
|
844
|
-
allDay?: boolean;
|
|
845
|
-
canDelete?: boolean;
|
|
846
|
-
};
|
|
847
|
-
type CalendarEventDataWithDetails = CalendarEventData & {
|
|
848
|
-
resident?: TinyResidentData;
|
|
849
|
-
owner?: SmallUser;
|
|
850
|
-
attendee?: SmallUser;
|
|
851
|
-
teams?: TinyTeam[];
|
|
852
|
-
account?: TinyWorkflowAccount;
|
|
853
|
-
};
|
|
854
|
-
//#endregion
|
|
855
|
-
//#region src/models/calendar/api.d.ts
|
|
856
|
-
type CalendarEventRoleFilter = 'owner' | 'attendee';
|
|
857
|
-
type OptionalCalendarEventLocation = UpsertLatLng & {
|
|
858
|
-
locationId?: LocationId;
|
|
859
|
-
oneLine?: string;
|
|
860
|
-
};
|
|
861
|
-
/** A yes/no/unset filter — matches events where the field is true, false, unset, or set to any value. */
|
|
862
|
-
type BooleanFilter = 'true' | 'false' | 'undefined' | 'defined';
|
|
863
|
-
type CalendarAvailabilityInput = {
|
|
864
|
-
/** UTC milliseconds. */startDate: number; /** Minutes. Defaults to 30. */
|
|
865
|
-
duration?: number;
|
|
1017
|
+
count: number;
|
|
1018
|
+
type?: AreaRunType;
|
|
1019
|
+
runBy?: UserId;
|
|
1020
|
+
process?: string;
|
|
866
1021
|
teamId?: TeamId;
|
|
1022
|
+
userIds?: UserId[];
|
|
867
1023
|
};
|
|
868
|
-
type
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1024
|
+
type AreaJobInfo = {
|
|
1025
|
+
total: number;
|
|
1026
|
+
assigned: number;
|
|
1027
|
+
assignedDate: number;
|
|
1028
|
+
isRunning: boolean;
|
|
1029
|
+
status: 'preparing' | 'queued' | 'running' | 'completed';
|
|
1030
|
+
};
|
|
1031
|
+
type UnsavedArea = {
|
|
1032
|
+
name?: string;
|
|
1033
|
+
coordinates: LatLng[];
|
|
1034
|
+
assignmentType: AreaAssignmentType;
|
|
1035
|
+
teamId?: TeamId;
|
|
1036
|
+
userIds?: UserId[];
|
|
1037
|
+
color?: string;
|
|
1038
|
+
note?: string;
|
|
1039
|
+
filters?: AreaFilters;
|
|
1040
|
+
assignmentConfig?: AreaAssignmentConfig;
|
|
1041
|
+
schedule?: AreaScheduleEntry[];
|
|
882
1042
|
};
|
|
883
|
-
type
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1043
|
+
type AreaData = UnsavedArea & AuditProps & {
|
|
1044
|
+
areaId: AreaId;
|
|
1045
|
+
importId?: string;
|
|
1046
|
+
deleteOnCompletion?: boolean;
|
|
1047
|
+
runHistory?: AreaRunHistoryEntry[];
|
|
1048
|
+
jobInfo?: AreaJobInfo;
|
|
889
1049
|
};
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
type
|
|
894
|
-
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region src/models/area/api.d.ts
|
|
1052
|
+
type AreaSortCursor = string | number | boolean | (string | number | boolean)[];
|
|
1053
|
+
type AreaGetInput = {
|
|
1054
|
+
areaId: AreaId;
|
|
895
1055
|
};
|
|
896
|
-
type
|
|
897
|
-
|
|
1056
|
+
type AreaGetSuccess = ApiSuccess<{
|
|
1057
|
+
area: AreaData;
|
|
898
1058
|
}>;
|
|
899
|
-
type
|
|
900
|
-
|
|
901
|
-
endTime?: number;
|
|
902
|
-
ownerId?: UserId;
|
|
903
|
-
locationId?: LocationId;
|
|
904
|
-
companyId?: string; /** @deprecated use teamIds */
|
|
1059
|
+
type AreaListInput = {
|
|
1060
|
+
userId?: UserId;
|
|
905
1061
|
teamId?: TeamId;
|
|
906
1062
|
teamIds?: TeamId[];
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
eventType?: EventType;
|
|
911
|
-
filterByRoles?: CalendarEventRoleFilter[];
|
|
912
|
-
};
|
|
913
|
-
type CalendarEventListSuccess = ApiSuccess<{
|
|
914
|
-
events: CalendarEventDataWithDetails[];
|
|
915
|
-
}>;
|
|
916
|
-
type CalendarEventUpdateInput = {
|
|
917
|
-
event: Partial<CalendarEventData> & {
|
|
918
|
-
eventId: CalendarEventId;
|
|
919
|
-
attendeeId?: UserId | null;
|
|
920
|
-
};
|
|
921
|
-
errorOnCloserUnavailable?: boolean;
|
|
1063
|
+
downlineTeamIds?: TeamId[];
|
|
1064
|
+
cursor?: AreaSortCursor;
|
|
1065
|
+
size?: number;
|
|
922
1066
|
};
|
|
923
|
-
type
|
|
924
|
-
|
|
1067
|
+
type AreaListSuccess = ApiSuccess<{
|
|
1068
|
+
areas: AreaData[];
|
|
1069
|
+
cursor?: AreaSortCursor;
|
|
925
1070
|
}>;
|
|
926
|
-
type
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
sourceId: string; /** Defaults to 'Consultation' on create. */
|
|
930
|
-
eventType: string;
|
|
931
|
-
title: string; /** Defaults to now on create. */
|
|
932
|
-
eventDate: string | number; /** An EventOutcomeId, integration mapping string, or case-insensitive name. */
|
|
933
|
-
outcomeId: string; /** Minutes. */
|
|
934
|
-
duration: number;
|
|
935
|
-
accountId: AccountId;
|
|
936
|
-
location: OptionalCalendarEventLocation; /** A UserId or email. Defaults to the authenticated user on create. */
|
|
937
|
-
ownerId: string; /** A UserId or email. Pass null to clear on update. */
|
|
938
|
-
attendeeId: string | null; /** A UserId or email. */
|
|
939
|
-
dispatcherId: string;
|
|
940
|
-
occurredOwner: boolean;
|
|
941
|
-
occurredAttendee: boolean;
|
|
942
|
-
notes: string;
|
|
943
|
-
previousEventId: CalendarEventId;
|
|
944
|
-
}>;
|
|
945
|
-
};
|
|
946
|
-
type CalendarEventUpsertSuccess = ApiSuccess<{
|
|
947
|
-
event: CalendarEventData;
|
|
1071
|
+
type AreaAddInput = UnsavedArea;
|
|
1072
|
+
type AreaAddSuccess = ApiSuccess<{
|
|
1073
|
+
area: AreaData;
|
|
948
1074
|
}>;
|
|
949
|
-
type
|
|
950
|
-
|
|
951
|
-
occurred?: boolean;
|
|
1075
|
+
type AreaUpdateInput = {
|
|
1076
|
+
area: AreaData;
|
|
952
1077
|
};
|
|
953
|
-
type
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
type CalendarEventRemoveInput = {
|
|
1078
|
+
type AreaUpdateSuccess = AreaAddSuccess;
|
|
1079
|
+
type AreaRemoveInput = {
|
|
1080
|
+
areaId: AreaId;
|
|
957
1081
|
archive?: boolean;
|
|
958
|
-
|
|
1082
|
+
};
|
|
1083
|
+
type AreaAssignInput = {
|
|
1084
|
+
areas: AreaData[];
|
|
1085
|
+
runType: AreaRunType;
|
|
959
1086
|
};
|
|
960
1087
|
//#endregion
|
|
961
1088
|
//#region src/models/connect/app/model.d.ts
|
|
@@ -1062,6 +1189,10 @@ type CompanyWebhookData = WebhookAuditProps & Omit<CompanyData, 'companyId'> & {
|
|
|
1062
1189
|
id: CompanyId;
|
|
1063
1190
|
};
|
|
1064
1191
|
type CompanyWebhook = WebhookPayload<'Company', CompanyWebhookData, 'id'>;
|
|
1192
|
+
type AccountWebhookData = WebhookAuditProps & Omit<AccountData, 'accountId' | 'resident'> & {
|
|
1193
|
+
id: AccountId;
|
|
1194
|
+
};
|
|
1195
|
+
type AccountWebhook = WebhookPayload<'Account', AccountWebhookData, 'id'>;
|
|
1065
1196
|
//#endregion
|
|
1066
1197
|
//#region src/clients/account.d.ts
|
|
1067
1198
|
declare class AccountStatusClient {
|
|
@@ -1087,6 +1218,18 @@ declare class AccountClient {
|
|
|
1087
1218
|
upsert(input: AccountUpsertInput): Promise<AccountUpsertSuccess>;
|
|
1088
1219
|
}
|
|
1089
1220
|
//#endregion
|
|
1221
|
+
//#region src/clients/area.d.ts
|
|
1222
|
+
declare class AreaClient {
|
|
1223
|
+
private readonly api;
|
|
1224
|
+
constructor(api: TerrosApiClient);
|
|
1225
|
+
list(input: AreaListInput): Promise<AreaListSuccess>;
|
|
1226
|
+
get(input: AreaGetInput): Promise<AreaGetSuccess>;
|
|
1227
|
+
add(input: AreaAddInput): Promise<AreaAddSuccess>;
|
|
1228
|
+
update(input: AreaUpdateInput): Promise<AreaUpdateSuccess>;
|
|
1229
|
+
remove(input: AreaRemoveInput): Promise<ApiSuccess>;
|
|
1230
|
+
assign(input: AreaAssignInput): Promise<ApiSuccess>;
|
|
1231
|
+
}
|
|
1232
|
+
//#endregion
|
|
1090
1233
|
//#region src/clients/calendar.d.ts
|
|
1091
1234
|
declare class CalendarEventClient {
|
|
1092
1235
|
private readonly api;
|
|
@@ -1148,6 +1291,7 @@ declare class UserClient {
|
|
|
1148
1291
|
//#region src/client.d.ts
|
|
1149
1292
|
declare class TerrosClient {
|
|
1150
1293
|
readonly account: AccountClient;
|
|
1294
|
+
readonly area: AreaClient;
|
|
1151
1295
|
readonly calendar: CalendarClient;
|
|
1152
1296
|
readonly connect: ConnectClient;
|
|
1153
1297
|
readonly user: UserClient;
|
|
@@ -1155,7 +1299,7 @@ declare class TerrosClient {
|
|
|
1155
1299
|
}
|
|
1156
1300
|
//#endregion
|
|
1157
1301
|
//#region src/connect/handler.d.ts
|
|
1158
|
-
type ConnectHandlerFunction<Input, Result> = (payload: ConnectExecutionInput<Input>, client:
|
|
1302
|
+
type ConnectHandlerFunction<Input, Result> = (payload: ConnectExecutionInput<Input>, client: TerrosClient) => Promise<Result>;
|
|
1159
1303
|
type ConnectExecutionConfig = {
|
|
1160
1304
|
scriptConfig: Record<string, string>;
|
|
1161
1305
|
secrets: Record<string, string>;
|
|
@@ -1172,4 +1316,4 @@ type ConnectExecutionInput<Payload> = {
|
|
|
1172
1316
|
type WrappedHandler<Input, Result> = (input: ConnectExecutionInput<Input>) => Promise<Result>;
|
|
1173
1317
|
declare function wrapConnectHandler<Input, Result = void>(handler: ConnectHandlerFunction<Input, Result>): WrappedHandler<Input, Result>;
|
|
1174
1318
|
//#endregion
|
|
1175
|
-
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, AppId, AppVersionData, AppVersionId, 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, CompanyWebhook, CompanyWebhookData, ConfigSchemaField, ConnectHandlerFunction, ContactId, CustomFieldFilter, CustomFieldMap, DispositionId, ElasticFilter, EntityId, EventOutcomeHistory, EventOutcomeId, EventType, IncomingScript, InterviewId, LatLng, LocationId, NoteId, NotificationPreference, OutgoingScript, PartialAddress, PermissionMap, RangeFilter, RoleId, ScheduledScript, ScriptAddInput, ScriptAddSuccess, ScriptBase, ScriptData, SmallAddress, SmallCloser, SmallUser, SortCursor, SpecialtyAttachments, StatusHistoryItem, SyncedCalendarEvent, TagId, TeamId, TerrosClient, TinyAccountStatus, TinyCloser, TinyResidentData, TinyRole, TinyTeam, TinyUser, TinyWorkflowAccount, UnsavedAccount, UnsavedAccountContact, UnsavedAccountNote, UnsavedAccountStatus, UnsavedAppVersion, UnsavedCalendarEventData, UnsavedScript, 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, UserWebhook, UserWebhookData, VersionAddInput, VersionAddSuccess, VersionUpdateInput, VersionUpdateSuccess, WebhookAddUpdatePayload, WebhookAuditProps, WebhookPayload, WebhookRemovePayload, Weekday, WorkflowActionId, WorkflowHistoryItem, WorkflowId, WorkflowStageId, wrapConnectHandler };
|
|
1319
|
+
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, AccountWebhook, AccountWebhookData, Address, AppId, AppVersionData, AppVersionId, AreaAddInput, AreaAddSuccess, AreaAssignInput, AreaAssignmentConfig, AreaAssignmentType, AreaData, AreaFilters, AreaGetInput, AreaGetSuccess, AreaId, AreaJobInfo, AreaListInput, AreaListSuccess, AreaRemoveInput, AreaRunHistoryEntry, AreaRunType, AreaScheduleEntry, AreaSortCursor, AreaUpdateInput, AreaUpdateSuccess, 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, CompanyWebhook, CompanyWebhookData, ConfigSchemaField, ConnectHandlerFunction, ContactId, CustomFieldFilter, CustomFieldFilterValue, CustomFieldId, CustomFieldMap, CustomFieldType, DispositionId, ElasticFilter, EntityId, EventOutcomeHistory, EventOutcomeId, EventType, IncomingScript, InterviewId, LatLng, LocationId, NoteId, NotificationPreference, OutgoingScript, PartialAddress, PermissionMap, RangeFilter, RoleId, ScheduledScript, ScriptAddInput, ScriptAddSuccess, ScriptBase, ScriptData, SmallAddress, SmallCloser, SmallUser, SortCursor, SpecialtyAttachments, StatusHistoryItem, SyncedCalendarEvent, TagId, TeamId, TerrosClient, TinyAccountStatus, TinyCloser, TinyResidentData, TinyRole, TinyTeam, TinyUser, TinyWorkflowAccount, UnsavedAccount, UnsavedAccountContact, UnsavedAccountNote, UnsavedAccountStatus, UnsavedAppVersion, UnsavedArea, UnsavedCalendarEventData, UnsavedScript, 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, UserWebhook, UserWebhookData, VersionAddInput, VersionAddSuccess, VersionUpdateInput, VersionUpdateSuccess, WebhookAddUpdatePayload, WebhookAuditProps, WebhookPayload, WebhookRemovePayload, Weekday, WorkflowActionId, WorkflowHistoryItem, WorkflowId, WorkflowStageId, wrapConnectHandler };
|
package/dist/index.mjs
CHANGED
|
@@ -92,22 +92,26 @@ var TerrosApiClient = class {
|
|
|
92
92
|
baseUrl;
|
|
93
93
|
authStrategy;
|
|
94
94
|
analytics;
|
|
95
|
+
impersonateUserId;
|
|
95
96
|
constructor(config = {}) {
|
|
96
97
|
this.baseUrl = this.determineBaseUrl(config);
|
|
97
98
|
this.analytics = getAnalyticsHeaders(config.analytics);
|
|
98
99
|
this.authStrategy = this.determineAuthStrategy(config);
|
|
100
|
+
this.impersonateUserId = config.impersonateUserId ?? readProcessEnv("TERROS_IMPERSONATE");
|
|
99
101
|
}
|
|
100
102
|
async call(route, input) {
|
|
101
103
|
let response;
|
|
102
104
|
try {
|
|
103
105
|
const authorization = await this.getAuthorizationHeader();
|
|
106
|
+
const headers = {
|
|
107
|
+
...this.analytics,
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
authorization
|
|
110
|
+
};
|
|
111
|
+
if (this.impersonateUserId) headers.impersonate_user_id = this.impersonateUserId;
|
|
104
112
|
response = await fetch(`${this.baseUrl}/${route}`, {
|
|
105
113
|
method: "POST",
|
|
106
|
-
headers
|
|
107
|
-
...this.analytics,
|
|
108
|
-
"Content-Type": "application/json",
|
|
109
|
-
authorization
|
|
110
|
-
},
|
|
114
|
+
headers,
|
|
111
115
|
body: JSON.stringify(input)
|
|
112
116
|
});
|
|
113
117
|
} catch (cause) {
|
|
@@ -149,7 +153,7 @@ function readProcessEnv(key) {
|
|
|
149
153
|
}
|
|
150
154
|
//#endregion
|
|
151
155
|
//#region package.json
|
|
152
|
-
var version = "1.0.
|
|
156
|
+
var version = "1.0.12";
|
|
153
157
|
//#endregion
|
|
154
158
|
//#region src/clients/account.ts
|
|
155
159
|
var AccountStatusClient = class {
|
|
@@ -206,6 +210,32 @@ var AccountClient = class {
|
|
|
206
210
|
}
|
|
207
211
|
};
|
|
208
212
|
//#endregion
|
|
213
|
+
//#region src/clients/area.ts
|
|
214
|
+
var AreaClient = class {
|
|
215
|
+
api;
|
|
216
|
+
constructor(api) {
|
|
217
|
+
this.api = api;
|
|
218
|
+
}
|
|
219
|
+
list(input) {
|
|
220
|
+
return this.api.call("area/list", input);
|
|
221
|
+
}
|
|
222
|
+
get(input) {
|
|
223
|
+
return this.api.call("area/get", input);
|
|
224
|
+
}
|
|
225
|
+
add(input) {
|
|
226
|
+
return this.api.call("area/add", input);
|
|
227
|
+
}
|
|
228
|
+
update(input) {
|
|
229
|
+
return this.api.call("area/update", input);
|
|
230
|
+
}
|
|
231
|
+
remove(input) {
|
|
232
|
+
return this.api.call("area/remove", input);
|
|
233
|
+
}
|
|
234
|
+
assign(input) {
|
|
235
|
+
return this.api.call("area/assign", input);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
209
239
|
//#region src/clients/calendar.ts
|
|
210
240
|
var CalendarEventClient = class {
|
|
211
241
|
api;
|
|
@@ -332,6 +362,7 @@ var UserClient = class {
|
|
|
332
362
|
//#region src/client.ts
|
|
333
363
|
var TerrosClient = class {
|
|
334
364
|
account;
|
|
365
|
+
area;
|
|
335
366
|
calendar;
|
|
336
367
|
connect;
|
|
337
368
|
user;
|
|
@@ -341,6 +372,7 @@ var TerrosClient = class {
|
|
|
341
372
|
analytics: { "Terros-App-Version": version }
|
|
342
373
|
});
|
|
343
374
|
this.account = new AccountClient(api);
|
|
375
|
+
this.area = new AreaClient(api);
|
|
344
376
|
this.calendar = new CalendarClient(api);
|
|
345
377
|
this.connect = new ConnectClient(api);
|
|
346
378
|
this.user = new UserClient(api);
|
|
@@ -352,7 +384,7 @@ function wrapConnectHandler(handler) {
|
|
|
352
384
|
return async (input) => {
|
|
353
385
|
const apiKey = input.context.config.authorization;
|
|
354
386
|
delete input.context.config.authorization;
|
|
355
|
-
return await handler(input, new
|
|
387
|
+
return await handler(input, new TerrosClient({ apiKey: apiKey?.replace(/^ApiKey /, "") }));
|
|
356
388
|
};
|
|
357
389
|
}
|
|
358
390
|
//#endregion
|