@terros-inc/sdk 1.0.13 → 1.0.15
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 +43 -7
- package/dist/index.mjs +13 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,7 @@ type TerrosHeaderMetadata = {
|
|
|
16
16
|
//#region ../packages/connect-common/dist/terrosApiClient.d.ts
|
|
17
17
|
type TerrosClientConfig = {
|
|
18
18
|
apiKey?: string;
|
|
19
|
+
authType?: 'ApiKey' | 'ConnectKey';
|
|
19
20
|
baseUrl?: string;
|
|
20
21
|
analytics?: TerrosHeaderMetadata;
|
|
21
22
|
impersonateUserId?: string;
|
|
@@ -346,7 +347,7 @@ type PartialCompanyData = Partial<CompanyData> & {
|
|
|
346
347
|
salesforceAccountId?: string | null;
|
|
347
348
|
demoOwnerId?: UserId | null;
|
|
348
349
|
};
|
|
349
|
-
type TinyCompany = Pick<CompanyData, 'companyId' | 'name' | 'kind' | 'accessStatus' | 'modifiedBy' | 'demoState' | 'avatarUrl' | 'avatarBlurhash' | 'maxUsers'>;
|
|
350
|
+
type TinyCompany = Pick<CompanyData, 'companyId' | 'name' | 'kind' | 'accessStatus' | 'modifiedBy' | 'demoState' | 'avatarUrl' | 'avatarBlurhash' | 'maxUsers' | 'activeUserCount' | 'salesforceAccountId'>;
|
|
350
351
|
//#endregion
|
|
351
352
|
//#region src/models/company/api.d.ts
|
|
352
353
|
type CompanyListInput = {
|
|
@@ -467,6 +468,19 @@ type TinyCloser = {
|
|
|
467
468
|
startTime: number;
|
|
468
469
|
duration: number;
|
|
469
470
|
}[];
|
|
471
|
+
bookingPercent: number;
|
|
472
|
+
serviceArea: {
|
|
473
|
+
type: 'unrestricted';
|
|
474
|
+
} | {
|
|
475
|
+
type: 'radius';
|
|
476
|
+
center: {
|
|
477
|
+
latitude: number;
|
|
478
|
+
longitude: number;
|
|
479
|
+
};
|
|
480
|
+
radiusMeters: number;
|
|
481
|
+
} | {
|
|
482
|
+
type: 'unknown';
|
|
483
|
+
};
|
|
470
484
|
};
|
|
471
485
|
type SmallCloser = TinyUser & CloserSettings & {
|
|
472
486
|
timezone: string;
|
|
@@ -805,8 +819,6 @@ type AccountData = Omit<UnsavedAccount, 'contacts' | 'notes'> & {
|
|
|
805
819
|
workflowStageName?: string;
|
|
806
820
|
workflowActionName?: string;
|
|
807
821
|
homeowner?: TinyResidentData;
|
|
808
|
-
userMissDate?: number;
|
|
809
|
-
locationMissDate?: number;
|
|
810
822
|
expiresAt?: number;
|
|
811
823
|
contacts?: AccountContact[];
|
|
812
824
|
notes?: AccountNote[];
|
|
@@ -901,6 +913,7 @@ type ElasticFilter = {
|
|
|
901
913
|
};
|
|
902
914
|
workflowActionCount?: RangeFilter;
|
|
903
915
|
contactCount?: RangeFilter;
|
|
916
|
+
stageEntryDate?: RangeFilter;
|
|
904
917
|
};
|
|
905
918
|
type AccountStatusSearchInput = {
|
|
906
919
|
accountIds?: AccountId[];
|
|
@@ -909,6 +922,7 @@ type AccountStatusSearchInput = {
|
|
|
909
922
|
actionIds?: WorkflowActionId[]; /** @deprecated */
|
|
910
923
|
statusIds?: AccountStatusId[];
|
|
911
924
|
teamId?: TeamId;
|
|
925
|
+
teamIds?: TeamId[];
|
|
912
926
|
userId?: UserId;
|
|
913
927
|
roleIds?: RoleId[];
|
|
914
928
|
startTime?: string | number;
|
|
@@ -925,6 +939,7 @@ type AccountStatusSearchInput = {
|
|
|
925
939
|
contactCount?: RangeFilter;
|
|
926
940
|
workflowActionCount?: RangeFilter;
|
|
927
941
|
lastActionDate?: RangeFilter;
|
|
942
|
+
stageEntryDate?: RangeFilter;
|
|
928
943
|
sortBy?: AccountSortBy;
|
|
929
944
|
sortOrder?: AccountSortOrder;
|
|
930
945
|
};
|
|
@@ -1060,6 +1075,7 @@ type AccountStatusRemoveInput = {
|
|
|
1060
1075
|
//#region src/models/area/model.d.ts
|
|
1061
1076
|
type AreaId = `Area.${string}`;
|
|
1062
1077
|
type AreaAssignmentType = 'user' | 'team' | 'company' | 'draft';
|
|
1078
|
+
type AreaStateName = 'draft' | 'scheduled' | 'assigned' | 'expiring' | 'unassigned';
|
|
1063
1079
|
type AreaRunType = 'assign' | 'unassign' | 'reassign';
|
|
1064
1080
|
type AreaFilters = {
|
|
1065
1081
|
cities?: string[];
|
|
@@ -1130,6 +1146,12 @@ type AreaData = UnsavedArea & AuditProps & {
|
|
|
1130
1146
|
//#endregion
|
|
1131
1147
|
//#region src/models/area/api.d.ts
|
|
1132
1148
|
type AreaSortCursor = string | number | boolean | (string | number | boolean)[];
|
|
1149
|
+
type AreaListSortBy = 'order' | 'name' | 'status' | 'lastRunAt' | 'createdAt' | 'updatedAt' | 'areaId';
|
|
1150
|
+
type AreaListSortOrder = 'asc' | 'desc';
|
|
1151
|
+
type OptionalDateRange = {
|
|
1152
|
+
startTime?: string | number;
|
|
1153
|
+
endTime?: string | number;
|
|
1154
|
+
};
|
|
1133
1155
|
type AreaGetInput = {
|
|
1134
1156
|
areaId: AreaId;
|
|
1135
1157
|
};
|
|
@@ -1141,12 +1163,24 @@ type AreaListInput = {
|
|
|
1141
1163
|
teamId?: TeamId;
|
|
1142
1164
|
teamIds?: TeamId[];
|
|
1143
1165
|
downlineTeamIds?: TeamId[];
|
|
1144
|
-
|
|
1166
|
+
query?: string;
|
|
1167
|
+
boundingBox?: {
|
|
1168
|
+
top: LatLng;
|
|
1169
|
+
bottom: LatLng;
|
|
1170
|
+
};
|
|
1171
|
+
areaStates?: AreaStateName[];
|
|
1172
|
+
createdDate?: OptionalDateRange;
|
|
1173
|
+
lastAssignmentDate?: OptionalDateRange;
|
|
1174
|
+
expirationDate?: OptionalDateRange;
|
|
1175
|
+
sortBy?: AreaListSortBy;
|
|
1176
|
+
sortOrder?: AreaListSortOrder;
|
|
1177
|
+
sortTimestamp?: AreaSortCursor;
|
|
1145
1178
|
size?: number;
|
|
1146
1179
|
};
|
|
1147
1180
|
type AreaListSuccess = ApiSuccess<{
|
|
1148
1181
|
areas: AreaData[];
|
|
1149
|
-
|
|
1182
|
+
sortTimestamp?: AreaSortCursor;
|
|
1183
|
+
total?: number;
|
|
1150
1184
|
}>;
|
|
1151
1185
|
type AreaAddInput = UnsavedArea;
|
|
1152
1186
|
type AreaAddSuccess = ApiSuccess<{
|
|
@@ -1161,7 +1195,8 @@ type AreaRemoveInput = {
|
|
|
1161
1195
|
archive?: boolean;
|
|
1162
1196
|
};
|
|
1163
1197
|
type AreaAssignInput = {
|
|
1164
|
-
areas
|
|
1198
|
+
areas?: AreaData[];
|
|
1199
|
+
areaListInput?: AreaListInput;
|
|
1165
1200
|
runType: AreaRunType;
|
|
1166
1201
|
};
|
|
1167
1202
|
//#endregion
|
|
@@ -1424,6 +1459,7 @@ type ConnectExecutionConfig = {
|
|
|
1424
1459
|
scriptConfig: Record<string, string>;
|
|
1425
1460
|
secrets: Record<string, string>;
|
|
1426
1461
|
authorization?: string;
|
|
1462
|
+
authType?: 'ApiKey' | 'ConnectKey';
|
|
1427
1463
|
};
|
|
1428
1464
|
type ConnectExecutionContext<Payload> = {
|
|
1429
1465
|
payload: Payload;
|
|
@@ -1436,4 +1472,4 @@ type ConnectExecutionInput<Payload> = {
|
|
|
1436
1472
|
type WrappedHandler<Input, Result> = (input: ConnectExecutionInput<Input>) => Promise<Result>;
|
|
1437
1473
|
declare function wrapConnectHandler<Input, Result = void>(handler: ConnectHandlerFunction<Input, Result>): WrappedHandler<Input, Result>;
|
|
1438
1474
|
//#endregion
|
|
1439
|
-
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, AppData, AppGetInput, AppGetSuccess, 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, CompanyAddInput, CompanyAddSuccess, CompanyData, CompanyGetInput, CompanyGetSuccess, CompanyId, CompanyIndustry, CompanyKind, CompanyListInput, CompanyListSuccess, CompanyRemoveInput, CompanyRemoveSuccess, CompanySetupInput, CompanySetupSuccess, CompanySize, CompanyUpdateInput, CompanyUpdateSuccess, CompanyWebhook, CompanyWebhookData, ConfigSchemaField, ConnectHandlerFunction, ContactId, CustomFieldFilter, CustomFieldFilterValue, CustomFieldId, CustomFieldMap, CustomFieldType, DemoState, DispositionId, ElasticFilter, EntityId, EventOutcomeHistory, EventOutcomeId, EventType, IncomingScript, InterviewId, LatLng, LocationId, ManualAccessOverride, NoteId, NotificationPreference, OutgoingScript, PartialAddress, PartialCompanyData, PermissionMap, RangeFilter, RoleData, RoleId, ScheduledScript, ScriptAddInput, ScriptAddSuccess, ScriptBase, ScriptData, SmallAddress, SmallCloser, SmallUser, SortCursor, SpecialtyAttachments, StatusHistoryItem, SyncedCalendarEvent, TagId, TeamId, TerrosClient, TinyAccountStatus, TinyCloser, TinyCompany, TinyResidentData, TinyRole, TinyTeam, TinyUser, TinyWorkflowAccount, UnsavedAccount, UnsavedAccountContact, UnsavedAccountNote, UnsavedAccountStatus, UnsavedAppVersion, UnsavedArea, UnsavedCalendarEventData, UnsavedCompany, 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, VersionGetInput, VersionGetSuccess, VersionUpdateInput, VersionUpdateSuccess, WebhookAddUpdatePayload, WebhookAuditProps, WebhookPayload, WebhookRemovePayload, Weekday, WorkflowActionId, WorkflowHistoryItem, WorkflowId, WorkflowStageId, wrapConnectHandler };
|
|
1475
|
+
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, AppData, AppGetInput, AppGetSuccess, AppId, AppVersionData, AppVersionId, AreaAddInput, AreaAddSuccess, AreaAssignInput, AreaAssignmentConfig, AreaAssignmentType, AreaData, AreaFilters, AreaGetInput, AreaGetSuccess, AreaId, AreaJobInfo, AreaListInput, AreaListSortBy, AreaListSortOrder, AreaListSuccess, AreaRemoveInput, AreaRunHistoryEntry, AreaRunType, AreaScheduleEntry, AreaSortCursor, AreaStateName, 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, CompanyAddInput, CompanyAddSuccess, CompanyData, CompanyGetInput, CompanyGetSuccess, CompanyId, CompanyIndustry, CompanyKind, CompanyListInput, CompanyListSuccess, CompanyRemoveInput, CompanyRemoveSuccess, CompanySetupInput, CompanySetupSuccess, CompanySize, CompanyUpdateInput, CompanyUpdateSuccess, CompanyWebhook, CompanyWebhookData, ConfigSchemaField, ConnectHandlerFunction, ContactId, CustomFieldFilter, CustomFieldFilterValue, CustomFieldId, CustomFieldMap, CustomFieldType, DemoState, DispositionId, ElasticFilter, EntityId, EventOutcomeHistory, EventOutcomeId, EventType, IncomingScript, InterviewId, LatLng, LocationId, ManualAccessOverride, NoteId, NotificationPreference, OutgoingScript, PartialAddress, PartialCompanyData, PermissionMap, RangeFilter, RoleData, RoleId, ScheduledScript, ScriptAddInput, ScriptAddSuccess, ScriptBase, ScriptData, SmallAddress, SmallCloser, SmallUser, SortCursor, SpecialtyAttachments, StatusHistoryItem, SyncedCalendarEvent, TagId, TeamId, TerrosClient, TinyAccountStatus, TinyCloser, TinyCompany, TinyResidentData, TinyRole, TinyTeam, TinyUser, TinyWorkflowAccount, UnsavedAccount, UnsavedAccountContact, UnsavedAccountNote, UnsavedAccountStatus, UnsavedAppVersion, UnsavedArea, UnsavedCalendarEventData, UnsavedCompany, 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, VersionGetInput, VersionGetSuccess, VersionUpdateInput, VersionUpdateSuccess, WebhookAddUpdatePayload, WebhookAuditProps, WebhookPayload, WebhookRemovePayload, Weekday, WorkflowActionId, WorkflowHistoryItem, WorkflowId, WorkflowStageId, wrapConnectHandler };
|
package/dist/index.mjs
CHANGED
|
@@ -123,20 +123,23 @@ var TerrosApiClient = class {
|
|
|
123
123
|
return output;
|
|
124
124
|
}
|
|
125
125
|
async getAuthorizationHeader() {
|
|
126
|
-
if (this.authStrategy.type === "apikey") return
|
|
126
|
+
if (this.authStrategy.type === "apikey") return `${this.authStrategy.authType} ${this.authStrategy.apiKey}`;
|
|
127
127
|
const cliTokens = await getTokens();
|
|
128
128
|
if (cliTokens === null) throw new Error("No authorization found. Log in with Terros CLI or provide an API key via environment variables or client config.");
|
|
129
129
|
return `Bearer ${cliTokens.access_token}`;
|
|
130
130
|
}
|
|
131
131
|
determineAuthStrategy(config) {
|
|
132
|
+
const authType = config.authType ?? "ApiKey";
|
|
132
133
|
if (config.apiKey) return {
|
|
133
134
|
type: "apikey",
|
|
134
|
-
apiKey: config.apiKey
|
|
135
|
+
apiKey: config.apiKey,
|
|
136
|
+
authType
|
|
135
137
|
};
|
|
136
138
|
const apiKeyFromEnv = readProcessEnv("TERROS_API_KEY");
|
|
137
139
|
if (apiKeyFromEnv) return {
|
|
138
140
|
type: "apikey",
|
|
139
|
-
apiKey: apiKeyFromEnv
|
|
141
|
+
apiKey: apiKeyFromEnv,
|
|
142
|
+
authType
|
|
140
143
|
};
|
|
141
144
|
return { type: "oauth" };
|
|
142
145
|
}
|
|
@@ -153,7 +156,7 @@ function readProcessEnv(key) {
|
|
|
153
156
|
}
|
|
154
157
|
//#endregion
|
|
155
158
|
//#region package.json
|
|
156
|
-
var version = "1.0.
|
|
159
|
+
var version = "1.0.15";
|
|
157
160
|
//#endregion
|
|
158
161
|
//#region src/clients/account.ts
|
|
159
162
|
var AccountStatusClient = class {
|
|
@@ -424,9 +427,13 @@ var TerrosClient = class {
|
|
|
424
427
|
//#region src/connect/handler.ts
|
|
425
428
|
function wrapConnectHandler(handler) {
|
|
426
429
|
return async (input) => {
|
|
427
|
-
const
|
|
430
|
+
const auth = input.context.config.authorization;
|
|
431
|
+
const authType = input.context.config.authType;
|
|
428
432
|
delete input.context.config.authorization;
|
|
429
|
-
return await handler(input, new TerrosClient({
|
|
433
|
+
return await handler(input, new TerrosClient({
|
|
434
|
+
apiKey: auth?.replace(/^(ApiKey|ConnectKey) /, ""),
|
|
435
|
+
authType
|
|
436
|
+
}));
|
|
430
437
|
};
|
|
431
438
|
}
|
|
432
439
|
//#endregion
|