@land-catalyst/batch-data-sdk 1.2.11 → 1.3.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.
- package/dist/builders/builders.d.ts +79 -22
- package/dist/builders/builders.js +77 -104
- package/dist/client/client.d.ts +62 -1
- package/dist/client/client.js +97 -9
- package/dist/core/types.d.ts +57 -15
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* .build();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { StringFilter, NumericRangeFilter, DateRangeFilter, GeoLocationDistance, GeoLocationBoundingBox, GeoLocationPolygon, AddressSearchCriteria, AssessmentSearchCriteria, BuildingSearchCriteria, CompAddressSearchCriteria, DemographicsSearchCriteria, ForeclosureSearchCriteria, GeneralSearchCriteria, IdsSearchCriteria, IntelSearchCriteria, InvoluntaryLienSearchCriteria, LegalSearchCriteria, ListingSearchCriteria, LotSearchCriteria, OpenLienSearchCriteria, OwnerSearchCriteria, PermitSearchCriteria, PropertyOwnerProfileSearchCriteria, SaleSearchCriteria, TaxSearchCriteria, ValuationSearchCriteria, OrSearchCriteria, SearchCriteria, DeliveryConfig, EventHubConfig, PropertySubscriptionRequest, QuickListValueWithNot, PropertyLookupRequest, PropertyLookupRequestItem, PropertyLookupRequestAddress, PropertyLookupOptions, PropertyPermitRequest, PropertyCountRequest, PropertySearchRequest, PropertySearchAsyncRequest, PropertyLookupAsyncRequest, GeoPoint, AirConditioningSource, BasementType, BuildingClass, BuildingCondition, BuildingQuality, ConstructionType, Driveway, ExteriorWalls, FloorCover, Garage, HeatSource, HeatingFuelType, InteriorWalls, Patio, Pool, Porch, RoofCover, RoofType, Sewer, Style, WaterService, Features, HomeownerRenter, BusinessOwner, Gender, Investments, DemographicsValue, ReligiousAffiliation, ForeclosureStatus, PropertyTypeCategory, PropertyTypeDetail, LienType, LienTypeCode, LoanType, OwnerStatusType, LastSaleDocumentType, ZoningCode } from "../core/types";
|
|
19
|
+
import { StringFilter, NumericRangeFilter, DateRangeFilter, GeoLocationDistance, GeoLocationBoundingBox, GeoLocationPolygon, AddressSearchCriteria, AssessmentSearchCriteria, BuildingSearchCriteria, CompAddressSearchCriteria, DemographicsSearchCriteria, ForeclosureSearchCriteria, GeneralSearchCriteria, IdsSearchCriteria, IntelSearchCriteria, InvoluntaryLienSearchCriteria, LegalSearchCriteria, ListingSearchCriteria, LotSearchCriteria, OpenLienSearchCriteria, OwnerSearchCriteria, PermitSearchCriteria, PropertyOwnerProfileSearchCriteria, SaleSearchCriteria, TaxSearchCriteria, ValuationSearchCriteria, OrSearchCriteria, SearchCriteria, DeliveryConfig, EventHubConfig, PropertySubscriptionRequest, QuickListValueWithNot, PropertyLookupRequest, PropertyLookupRequestItem, PropertyLookupRequestAddress, PropertyLookupOptions, PropertyPermitRequest, PropertyCountRequest, PropertySearchRequest, PropertySearchAsyncRequest, PropertyLookupAsyncRequest, RequestWithLookupOptions, RequestWithSearchCriteria, GeoPoint, AirConditioningSource, BasementType, BuildingClass, BuildingCondition, BuildingQuality, ConstructionType, Driveway, ExteriorWalls, FloorCover, Garage, HeatSource, HeatingFuelType, InteriorWalls, Patio, Pool, Porch, RoofCover, RoofType, Sewer, Style, WaterService, Features, HomeownerRenter, BusinessOwner, Gender, Investments, DemographicsValue, ReligiousAffiliation, ForeclosureStatus, PropertyTypeCategory, PropertyTypeDetail, LienType, LienTypeCode, LoanType, OwnerStatusType, LastSaleDocumentType, ZoningCode } from "../core/types";
|
|
20
20
|
import type { PropertyFieldMetadata } from "../property-field/metadata";
|
|
21
21
|
/**
|
|
22
22
|
* Base interface for all builders
|
|
@@ -145,6 +145,79 @@ declare abstract class BaseBuilder<T> implements Builder<T> {
|
|
|
145
145
|
protected setPropertyWithBuilderClass<K extends keyof T, B extends Builder<T[K]>>(key: K, valueOrConfigurator: T[K] | ((builder: B) => void), BuilderClass: new () => B): this;
|
|
146
146
|
build(): T;
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Base class for builders that work with RequestWithLookupOptions types.
|
|
150
|
+
* Provides the common `options` method implementation.
|
|
151
|
+
*
|
|
152
|
+
* Builders that work with requests that have PropertyLookupOptions should extend
|
|
153
|
+
* this class instead of BaseBuilder directly.
|
|
154
|
+
*/
|
|
155
|
+
export declare abstract class RequestWithLookupOptionsBuilder<T extends RequestWithLookupOptions> extends BaseBuilder<T> {
|
|
156
|
+
/**
|
|
157
|
+
* Set PropertyLookupOptions either directly or via a builder configurator.
|
|
158
|
+
*
|
|
159
|
+
* @param optionsOrConfigurator - Either the direct options object or a configurator function
|
|
160
|
+
* @returns This builder instance for method chaining
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Direct value
|
|
165
|
+
* builder.options({ take: 10, skip: 0 });
|
|
166
|
+
*
|
|
167
|
+
* // Builder configurator
|
|
168
|
+
* builder.options((opts) => {
|
|
169
|
+
* opts.take(10).skip(0).skipTrace(true);
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
options(options: PropertyLookupOptions): this;
|
|
174
|
+
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
175
|
+
/**
|
|
176
|
+
* Helper method to build options into a request object.
|
|
177
|
+
* This is used by subclasses in their build() methods.
|
|
178
|
+
*
|
|
179
|
+
* @param request - The request object being built
|
|
180
|
+
* @returns The request object with options applied (if any)
|
|
181
|
+
*/
|
|
182
|
+
protected buildOptionsIntoRequest<R extends RequestWithLookupOptions>(request: R): R;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Base class for builders that work with RequestWithSearchCriteria types.
|
|
186
|
+
* Provides the common `searchCriteria` and `options` method implementations.
|
|
187
|
+
*
|
|
188
|
+
* Builders that work with requests that have both searchCriteria and options
|
|
189
|
+
* should extend this class instead of RequestWithLookupOptionsBuilder directly.
|
|
190
|
+
*/
|
|
191
|
+
export declare abstract class RequestWithSearchCriteriaBuilder<T extends RequestWithSearchCriteria> extends RequestWithLookupOptionsBuilder<T> {
|
|
192
|
+
/**
|
|
193
|
+
* Set SearchCriteria either directly or via a builder configurator.
|
|
194
|
+
*
|
|
195
|
+
* @param criteriaOrConfigurator - Either the direct SearchCriteria object or a configurator function
|
|
196
|
+
* @returns This builder instance for method chaining
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Direct value
|
|
201
|
+
* builder.searchCriteria({ query: "123 Main St" });
|
|
202
|
+
*
|
|
203
|
+
* // Builder configurator
|
|
204
|
+
* builder.searchCriteria((sc) => {
|
|
205
|
+
* sc.address((addr) => {
|
|
206
|
+
* addr.street("Main St").city("Phoenix").state("AZ");
|
|
207
|
+
* });
|
|
208
|
+
* });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
searchCriteria(criteria: SearchCriteria): this;
|
|
212
|
+
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
213
|
+
/**
|
|
214
|
+
* Helper method to validate that searchCriteria is present in build() methods.
|
|
215
|
+
* Throws an error if searchCriteria is missing.
|
|
216
|
+
*
|
|
217
|
+
* @throws Error if searchCriteria is not set
|
|
218
|
+
*/
|
|
219
|
+
protected validateSearchCriteria(): void;
|
|
220
|
+
}
|
|
148
221
|
/**
|
|
149
222
|
* Base builder for string filters
|
|
150
223
|
* @template T - Optional union type of allowed string values. Defaults to `string` for backward compatibility.
|
|
@@ -743,14 +816,10 @@ export declare class DeliveryConfigBuilder {
|
|
|
743
816
|
/**
|
|
744
817
|
* Main builder for property subscription requests
|
|
745
818
|
*/
|
|
746
|
-
export declare class PropertySubscriptionBuilder extends
|
|
819
|
+
export declare class PropertySubscriptionBuilder extends RequestWithSearchCriteriaBuilder<PropertySubscriptionRequest> {
|
|
747
820
|
static from(request: PropertySubscriptionRequest): PropertySubscriptionBuilder;
|
|
748
|
-
searchCriteria(criteria: SearchCriteria): this;
|
|
749
|
-
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
750
821
|
deliveryConfig(config: DeliveryConfig): this;
|
|
751
822
|
deliveryConfig(configurator: (builder: DeliveryConfigBuilder) => void): this;
|
|
752
|
-
options(options: PropertyLookupOptions): this;
|
|
753
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
754
823
|
build(): PropertySubscriptionRequest;
|
|
755
824
|
}
|
|
756
825
|
/**
|
|
@@ -807,14 +876,12 @@ export declare class AsyncPropertyLookupOptionsBuilder extends PropertyLookupOpt
|
|
|
807
876
|
/**
|
|
808
877
|
* Builder for property lookup requests
|
|
809
878
|
*/
|
|
810
|
-
export declare class PropertyLookupRequestBuilder extends
|
|
879
|
+
export declare class PropertyLookupRequestBuilder extends RequestWithLookupOptionsBuilder<PropertyLookupRequest> {
|
|
811
880
|
private requestItems;
|
|
812
881
|
static from(request: PropertyLookupRequest): PropertyLookupRequestBuilder;
|
|
813
882
|
items(items: PropertyLookupRequestItem[]): this;
|
|
814
883
|
addItem(item: PropertyLookupRequestItem): this;
|
|
815
884
|
addItemBuilder(builder: PropertyLookupRequestItemBuilder): this;
|
|
816
|
-
options(options: PropertyLookupOptions): this;
|
|
817
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
818
885
|
build(): PropertyLookupRequest;
|
|
819
886
|
}
|
|
820
887
|
/**
|
|
@@ -831,36 +898,26 @@ export declare class PropertyCountRequestBuilder extends BaseBuilder<PropertyCou
|
|
|
831
898
|
/**
|
|
832
899
|
* Builder for property search requests
|
|
833
900
|
*/
|
|
834
|
-
export declare class PropertySearchRequestBuilder extends
|
|
901
|
+
export declare class PropertySearchRequestBuilder extends RequestWithSearchCriteriaBuilder<PropertySearchRequest> {
|
|
835
902
|
static from(request: PropertySearchRequest): PropertySearchRequestBuilder;
|
|
836
|
-
searchCriteria(criteria: SearchCriteria): this;
|
|
837
|
-
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
838
|
-
options(options: PropertyLookupOptions): this;
|
|
839
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
840
903
|
build(): PropertySearchRequest;
|
|
841
904
|
}
|
|
842
905
|
/**
|
|
843
906
|
* Builder for property search async requests
|
|
844
907
|
*/
|
|
845
|
-
export declare class PropertySearchAsyncRequestBuilder extends
|
|
908
|
+
export declare class PropertySearchAsyncRequestBuilder extends RequestWithSearchCriteriaBuilder<PropertySearchAsyncRequest> {
|
|
846
909
|
static from(request: PropertySearchAsyncRequest): PropertySearchAsyncRequestBuilder;
|
|
847
|
-
searchCriteria(criteria: SearchCriteria): this;
|
|
848
|
-
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
849
|
-
options(options: PropertyLookupOptions): this;
|
|
850
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
851
910
|
build(): PropertySearchAsyncRequest;
|
|
852
911
|
}
|
|
853
912
|
/**
|
|
854
913
|
* Builder for property lookup async requests
|
|
855
914
|
*/
|
|
856
|
-
export declare class PropertyLookupAsyncRequestBuilder extends
|
|
915
|
+
export declare class PropertyLookupAsyncRequestBuilder extends RequestWithLookupOptionsBuilder<PropertyLookupAsyncRequest> {
|
|
857
916
|
private requestItems;
|
|
858
917
|
static from(request: PropertyLookupAsyncRequest): PropertyLookupAsyncRequestBuilder;
|
|
859
918
|
items(items: PropertyLookupRequestItem[]): this;
|
|
860
919
|
addItem(item: PropertyLookupRequestItem): this;
|
|
861
920
|
addItemBuilder(builder: PropertyLookupRequestItemBuilder): this;
|
|
862
|
-
options(options: PropertyLookupOptions): this;
|
|
863
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
864
921
|
build(): PropertyLookupAsyncRequest;
|
|
865
922
|
}
|
|
866
923
|
/**
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PropertyPermitRequestBuilder = exports.PropertyLookupAsyncRequestBuilder = exports.PropertySearchAsyncRequestBuilder = exports.PropertySearchRequestBuilder = exports.PropertyCountRequestBuilder = exports.PropertyLookupRequestBuilder = exports.AsyncPropertyLookupOptionsBuilder = exports.PropertyLookupOptionsBuilder = exports.PropertyLookupRequestItemBuilder = exports.PropertySubscriptionBuilder = exports.DeliveryConfigBuilder = exports.SearchCriteriaBuilder = exports.OrSearchCriteriaBuilder = exports.ValuationSearchCriteriaBuilder = exports.TaxSearchCriteriaBuilder = exports.SaleSearchCriteriaBuilder = exports.PropertyOwnerProfileSearchCriteriaBuilder = exports.PermitSearchCriteriaBuilder = exports.OwnerSearchCriteriaBuilder = exports.OpenLienSearchCriteriaBuilder = exports.LotSearchCriteriaBuilder = exports.ListingSearchCriteriaBuilder = exports.LegalSearchCriteriaBuilder = exports.InvoluntaryLienSearchCriteriaBuilder = exports.IntelSearchCriteriaBuilder = exports.IdsSearchCriteriaBuilder = exports.GeneralSearchCriteriaBuilder = exports.ForeclosureSearchCriteriaBuilder = exports.DemographicsSearchCriteriaBuilder = exports.CompAddressSearchCriteriaBuilder = exports.BuildingSearchCriteriaBuilder = exports.AssessmentSearchCriteriaBuilder = exports.AddressSearchCriteriaBuilder = exports.GeoLocationFactory = exports.DateRangeFilterBuilder = exports.NumericRangeFilterBuilder = exports.StringFilterBuilder = void 0;
|
|
21
|
+
exports.PropertyPermitRequestBuilder = exports.PropertyLookupAsyncRequestBuilder = exports.PropertySearchAsyncRequestBuilder = exports.PropertySearchRequestBuilder = exports.PropertyCountRequestBuilder = exports.PropertyLookupRequestBuilder = exports.AsyncPropertyLookupOptionsBuilder = exports.PropertyLookupOptionsBuilder = exports.PropertyLookupRequestItemBuilder = exports.PropertySubscriptionBuilder = exports.DeliveryConfigBuilder = exports.SearchCriteriaBuilder = exports.OrSearchCriteriaBuilder = exports.ValuationSearchCriteriaBuilder = exports.TaxSearchCriteriaBuilder = exports.SaleSearchCriteriaBuilder = exports.PropertyOwnerProfileSearchCriteriaBuilder = exports.PermitSearchCriteriaBuilder = exports.OwnerSearchCriteriaBuilder = exports.OpenLienSearchCriteriaBuilder = exports.LotSearchCriteriaBuilder = exports.ListingSearchCriteriaBuilder = exports.LegalSearchCriteriaBuilder = exports.InvoluntaryLienSearchCriteriaBuilder = exports.IntelSearchCriteriaBuilder = exports.IdsSearchCriteriaBuilder = exports.GeneralSearchCriteriaBuilder = exports.ForeclosureSearchCriteriaBuilder = exports.DemographicsSearchCriteriaBuilder = exports.CompAddressSearchCriteriaBuilder = exports.BuildingSearchCriteriaBuilder = exports.AssessmentSearchCriteriaBuilder = exports.AddressSearchCriteriaBuilder = exports.GeoLocationFactory = exports.DateRangeFilterBuilder = exports.NumericRangeFilterBuilder = exports.StringFilterBuilder = exports.RequestWithSearchCriteriaBuilder = exports.RequestWithLookupOptionsBuilder = void 0;
|
|
22
22
|
const metadata_1 = require("../property-field/metadata");
|
|
23
23
|
const utils_1 = require("../property-field/utils");
|
|
24
24
|
/**
|
|
@@ -164,6 +164,69 @@ class BaseBuilder {
|
|
|
164
164
|
return result;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Base class for builders that work with RequestWithLookupOptions types.
|
|
169
|
+
* Provides the common `options` method implementation.
|
|
170
|
+
*
|
|
171
|
+
* Builders that work with requests that have PropertyLookupOptions should extend
|
|
172
|
+
* this class instead of BaseBuilder directly.
|
|
173
|
+
*/
|
|
174
|
+
class RequestWithLookupOptionsBuilder extends BaseBuilder {
|
|
175
|
+
options(optionsOrConfigurator) {
|
|
176
|
+
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Helper method to build options into a request object.
|
|
180
|
+
* This is used by subclasses in their build() methods.
|
|
181
|
+
*
|
|
182
|
+
* @param request - The request object being built
|
|
183
|
+
* @returns The request object with options applied (if any)
|
|
184
|
+
*/
|
|
185
|
+
buildOptionsIntoRequest(request) {
|
|
186
|
+
if (this.builders.options) {
|
|
187
|
+
request.options = this.builders.options.build();
|
|
188
|
+
}
|
|
189
|
+
else if (this.criteria.options) {
|
|
190
|
+
request.options = this.criteria.options;
|
|
191
|
+
}
|
|
192
|
+
return request;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.RequestWithLookupOptionsBuilder = RequestWithLookupOptionsBuilder;
|
|
196
|
+
/**
|
|
197
|
+
* Base class for builders that work with RequestWithSearchCriteria types.
|
|
198
|
+
* Provides the common `searchCriteria` and `options` method implementations.
|
|
199
|
+
*
|
|
200
|
+
* Builders that work with requests that have both searchCriteria and options
|
|
201
|
+
* should extend this class instead of RequestWithLookupOptionsBuilder directly.
|
|
202
|
+
*/
|
|
203
|
+
class RequestWithSearchCriteriaBuilder extends RequestWithLookupOptionsBuilder {
|
|
204
|
+
searchCriteria(criteriaOrConfigurator) {
|
|
205
|
+
if (typeof criteriaOrConfigurator === "function") {
|
|
206
|
+
const builder = new SearchCriteriaBuilder("");
|
|
207
|
+
criteriaOrConfigurator(builder);
|
|
208
|
+
this.criteria.searchCriteria = builder.build();
|
|
209
|
+
this.builders.searchCriteria = undefined;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
213
|
+
this.builders.searchCriteria = undefined;
|
|
214
|
+
}
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Helper method to validate that searchCriteria is present in build() methods.
|
|
219
|
+
* Throws an error if searchCriteria is missing.
|
|
220
|
+
*
|
|
221
|
+
* @throws Error if searchCriteria is not set
|
|
222
|
+
*/
|
|
223
|
+
validateSearchCriteria() {
|
|
224
|
+
if (!this.criteria.searchCriteria) {
|
|
225
|
+
throw new Error("Search criteria is required");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.RequestWithSearchCriteriaBuilder = RequestWithSearchCriteriaBuilder;
|
|
167
230
|
/**
|
|
168
231
|
* Base builder for string filters
|
|
169
232
|
* @template T - Optional union type of allowed string values. Defaults to `string` for backward compatibility.
|
|
@@ -2209,7 +2272,7 @@ exports.DeliveryConfigBuilder = DeliveryConfigBuilder;
|
|
|
2209
2272
|
/**
|
|
2210
2273
|
* Main builder for property subscription requests
|
|
2211
2274
|
*/
|
|
2212
|
-
class PropertySubscriptionBuilder extends
|
|
2275
|
+
class PropertySubscriptionBuilder extends RequestWithSearchCriteriaBuilder {
|
|
2213
2276
|
static from(request) {
|
|
2214
2277
|
const builder = new PropertySubscriptionBuilder();
|
|
2215
2278
|
builder.searchCriteria(request.searchCriteria);
|
|
@@ -2219,19 +2282,6 @@ class PropertySubscriptionBuilder extends BaseBuilder {
|
|
|
2219
2282
|
}
|
|
2220
2283
|
return builder;
|
|
2221
2284
|
}
|
|
2222
|
-
searchCriteria(criteriaOrConfigurator) {
|
|
2223
|
-
if (typeof criteriaOrConfigurator === "function") {
|
|
2224
|
-
const builder = new SearchCriteriaBuilder("");
|
|
2225
|
-
criteriaOrConfigurator(builder);
|
|
2226
|
-
this.criteria.searchCriteria = builder.build();
|
|
2227
|
-
this.builders.searchCriteria = undefined;
|
|
2228
|
-
}
|
|
2229
|
-
else {
|
|
2230
|
-
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
2231
|
-
this.builders.searchCriteria = undefined;
|
|
2232
|
-
}
|
|
2233
|
-
return this;
|
|
2234
|
-
}
|
|
2235
2285
|
deliveryConfig(configOrConfigurator) {
|
|
2236
2286
|
if (typeof configOrConfigurator === "function") {
|
|
2237
2287
|
const builder = new DeliveryConfigBuilder();
|
|
@@ -2245,13 +2295,8 @@ class PropertySubscriptionBuilder extends BaseBuilder {
|
|
|
2245
2295
|
}
|
|
2246
2296
|
return this;
|
|
2247
2297
|
}
|
|
2248
|
-
options(optionsOrConfigurator) {
|
|
2249
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2250
|
-
}
|
|
2251
2298
|
build() {
|
|
2252
|
-
|
|
2253
|
-
throw new Error("Search criteria is required");
|
|
2254
|
-
}
|
|
2299
|
+
this.validateSearchCriteria();
|
|
2255
2300
|
if (!this.criteria.deliveryConfig) {
|
|
2256
2301
|
throw new Error("Delivery configuration is required");
|
|
2257
2302
|
}
|
|
@@ -2259,13 +2304,7 @@ class PropertySubscriptionBuilder extends BaseBuilder {
|
|
|
2259
2304
|
searchCriteria: this.criteria.searchCriteria,
|
|
2260
2305
|
deliveryConfig: this.criteria.deliveryConfig,
|
|
2261
2306
|
};
|
|
2262
|
-
|
|
2263
|
-
request.options = this.builders.options.build();
|
|
2264
|
-
}
|
|
2265
|
-
else if (this.criteria.options) {
|
|
2266
|
-
request.options = this.criteria.options;
|
|
2267
|
-
}
|
|
2268
|
-
return request;
|
|
2307
|
+
return this.buildOptionsIntoRequest(request);
|
|
2269
2308
|
}
|
|
2270
2309
|
}
|
|
2271
2310
|
exports.PropertySubscriptionBuilder = PropertySubscriptionBuilder;
|
|
@@ -2467,7 +2506,7 @@ exports.AsyncPropertyLookupOptionsBuilder = AsyncPropertyLookupOptionsBuilder;
|
|
|
2467
2506
|
/**
|
|
2468
2507
|
* Builder for property lookup requests
|
|
2469
2508
|
*/
|
|
2470
|
-
class PropertyLookupRequestBuilder extends
|
|
2509
|
+
class PropertyLookupRequestBuilder extends RequestWithLookupOptionsBuilder {
|
|
2471
2510
|
constructor() {
|
|
2472
2511
|
super(...arguments);
|
|
2473
2512
|
this.requestItems = [];
|
|
@@ -2492,20 +2531,11 @@ class PropertyLookupRequestBuilder extends BaseBuilder {
|
|
|
2492
2531
|
this.requestItems.push(builder.build());
|
|
2493
2532
|
return this;
|
|
2494
2533
|
}
|
|
2495
|
-
options(optionsOrConfigurator) {
|
|
2496
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2497
|
-
}
|
|
2498
2534
|
build() {
|
|
2499
2535
|
const request = {
|
|
2500
2536
|
requests: this.requestItems,
|
|
2501
2537
|
};
|
|
2502
|
-
|
|
2503
|
-
request.options = this.builders.options.build();
|
|
2504
|
-
}
|
|
2505
|
-
else if (this.criteria.options) {
|
|
2506
|
-
request.options = this.criteria.options;
|
|
2507
|
-
}
|
|
2508
|
-
return request;
|
|
2538
|
+
return this.buildOptionsIntoRequest(request);
|
|
2509
2539
|
}
|
|
2510
2540
|
}
|
|
2511
2541
|
exports.PropertyLookupRequestBuilder = PropertyLookupRequestBuilder;
|
|
@@ -2546,7 +2576,7 @@ exports.PropertyCountRequestBuilder = PropertyCountRequestBuilder;
|
|
|
2546
2576
|
/**
|
|
2547
2577
|
* Builder for property search requests
|
|
2548
2578
|
*/
|
|
2549
|
-
class PropertySearchRequestBuilder extends
|
|
2579
|
+
class PropertySearchRequestBuilder extends RequestWithSearchCriteriaBuilder {
|
|
2550
2580
|
static from(request) {
|
|
2551
2581
|
const builder = new PropertySearchRequestBuilder();
|
|
2552
2582
|
builder.searchCriteria(request.searchCriteria);
|
|
@@ -2555,43 +2585,19 @@ class PropertySearchRequestBuilder extends BaseBuilder {
|
|
|
2555
2585
|
}
|
|
2556
2586
|
return builder;
|
|
2557
2587
|
}
|
|
2558
|
-
searchCriteria(criteriaOrConfigurator) {
|
|
2559
|
-
if (typeof criteriaOrConfigurator === "function") {
|
|
2560
|
-
const builder = new SearchCriteriaBuilder("");
|
|
2561
|
-
criteriaOrConfigurator(builder);
|
|
2562
|
-
this.criteria.searchCriteria = builder.build();
|
|
2563
|
-
this.builders.searchCriteria = undefined;
|
|
2564
|
-
}
|
|
2565
|
-
else {
|
|
2566
|
-
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
2567
|
-
this.builders.searchCriteria = undefined;
|
|
2568
|
-
}
|
|
2569
|
-
return this;
|
|
2570
|
-
}
|
|
2571
|
-
options(optionsOrConfigurator) {
|
|
2572
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2573
|
-
}
|
|
2574
2588
|
build() {
|
|
2575
|
-
|
|
2576
|
-
throw new Error("Search criteria is required");
|
|
2577
|
-
}
|
|
2589
|
+
this.validateSearchCriteria();
|
|
2578
2590
|
const request = {
|
|
2579
2591
|
searchCriteria: this.criteria.searchCriteria,
|
|
2580
2592
|
};
|
|
2581
|
-
|
|
2582
|
-
request.options = this.builders.options.build();
|
|
2583
|
-
}
|
|
2584
|
-
else if (this.criteria.options) {
|
|
2585
|
-
request.options = this.criteria.options;
|
|
2586
|
-
}
|
|
2587
|
-
return request;
|
|
2593
|
+
return this.buildOptionsIntoRequest(request);
|
|
2588
2594
|
}
|
|
2589
2595
|
}
|
|
2590
2596
|
exports.PropertySearchRequestBuilder = PropertySearchRequestBuilder;
|
|
2591
2597
|
/**
|
|
2592
2598
|
* Builder for property search async requests
|
|
2593
2599
|
*/
|
|
2594
|
-
class PropertySearchAsyncRequestBuilder extends
|
|
2600
|
+
class PropertySearchAsyncRequestBuilder extends RequestWithSearchCriteriaBuilder {
|
|
2595
2601
|
static from(request) {
|
|
2596
2602
|
const builder = new PropertySearchAsyncRequestBuilder();
|
|
2597
2603
|
builder.searchCriteria(request.searchCriteria);
|
|
@@ -2600,43 +2606,19 @@ class PropertySearchAsyncRequestBuilder extends BaseBuilder {
|
|
|
2600
2606
|
}
|
|
2601
2607
|
return builder;
|
|
2602
2608
|
}
|
|
2603
|
-
searchCriteria(criteriaOrConfigurator) {
|
|
2604
|
-
if (typeof criteriaOrConfigurator === "function") {
|
|
2605
|
-
const builder = new SearchCriteriaBuilder("");
|
|
2606
|
-
criteriaOrConfigurator(builder);
|
|
2607
|
-
this.criteria.searchCriteria = builder.build();
|
|
2608
|
-
this.builders.searchCriteria = undefined;
|
|
2609
|
-
}
|
|
2610
|
-
else {
|
|
2611
|
-
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
2612
|
-
this.builders.searchCriteria = undefined;
|
|
2613
|
-
}
|
|
2614
|
-
return this;
|
|
2615
|
-
}
|
|
2616
|
-
options(optionsOrConfigurator) {
|
|
2617
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2618
|
-
}
|
|
2619
2609
|
build() {
|
|
2620
|
-
|
|
2621
|
-
throw new Error("Search criteria is required");
|
|
2622
|
-
}
|
|
2610
|
+
this.validateSearchCriteria();
|
|
2623
2611
|
const request = {
|
|
2624
2612
|
searchCriteria: this.criteria.searchCriteria,
|
|
2625
2613
|
};
|
|
2626
|
-
|
|
2627
|
-
request.options = this.builders.options.build();
|
|
2628
|
-
}
|
|
2629
|
-
else if (this.criteria.options) {
|
|
2630
|
-
request.options = this.criteria.options;
|
|
2631
|
-
}
|
|
2632
|
-
return request;
|
|
2614
|
+
return this.buildOptionsIntoRequest(request);
|
|
2633
2615
|
}
|
|
2634
2616
|
}
|
|
2635
2617
|
exports.PropertySearchAsyncRequestBuilder = PropertySearchAsyncRequestBuilder;
|
|
2636
2618
|
/**
|
|
2637
2619
|
* Builder for property lookup async requests
|
|
2638
2620
|
*/
|
|
2639
|
-
class PropertyLookupAsyncRequestBuilder extends
|
|
2621
|
+
class PropertyLookupAsyncRequestBuilder extends RequestWithLookupOptionsBuilder {
|
|
2640
2622
|
constructor() {
|
|
2641
2623
|
super(...arguments);
|
|
2642
2624
|
this.requestItems = [];
|
|
@@ -2661,20 +2643,11 @@ class PropertyLookupAsyncRequestBuilder extends BaseBuilder {
|
|
|
2661
2643
|
this.requestItems.push(builder.build());
|
|
2662
2644
|
return this;
|
|
2663
2645
|
}
|
|
2664
|
-
options(optionsOrConfigurator) {
|
|
2665
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2666
|
-
}
|
|
2667
2646
|
build() {
|
|
2668
2647
|
const request = {
|
|
2669
2648
|
requests: this.requestItems,
|
|
2670
2649
|
};
|
|
2671
|
-
|
|
2672
|
-
request.options = this.builders.options.build();
|
|
2673
|
-
}
|
|
2674
|
-
else if (this.criteria.options) {
|
|
2675
|
-
request.options = this.criteria.options;
|
|
2676
|
-
}
|
|
2677
|
-
return request;
|
|
2650
|
+
return this.buildOptionsIntoRequest(request);
|
|
2678
2651
|
}
|
|
2679
2652
|
}
|
|
2680
2653
|
exports.PropertyLookupAsyncRequestBuilder = PropertyLookupAsyncRequestBuilder;
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosResponse, AxiosError, InternalAxiosRequestConfig } from "axios";
|
|
2
2
|
import { IBatchDataClient } from "./client.interface";
|
|
3
3
|
import { ILogger } from "../core/logger.interface";
|
|
4
|
-
import { PropertySubscriptionRequest, PropertySubscriptionResponse, PropertyCountRequest, PropertySearchRequest, PropertySearchResponse, AddressVerifyRequest, AddressVerifyResponse, AddressAutocompleteRequest, AddressAutocompleteResponse, AddressGeocodeRequest, AddressGeocodeResponse, AddressReverseGeocodeRequest, AddressReverseGeocodeResponse, PropertyLookupRequest, PropertyLookupResponse, PropertyLookupAsyncRequest, PropertyLookupAsyncResponse, PropertySearchAsyncRequest, PropertySearchAsyncResponse, PropertySkipTraceRequest, PropertySkipTraceResponse, PropertySkipTraceAsyncRequest, PropertySkipTraceAsyncResponse, PhoneVerificationRequest, PhoneVerificationResponse, PhoneVerificationAsyncRequest, PhoneVerificationAsyncResponse, PhoneDNCRequest, PhoneDNCResponse, PhoneDNCAsyncRequest, PhoneDNCAsyncResponse, PhoneTCPARequest, PhoneTCPAResponse, PhoneTCPAAsyncRequest, PhoneTCPAAsyncResponse, GetPropertySubscriptionsResponse, GetPropertySubscriptionDetailResponse, DeletePropertySubscriptionResponse, PropertyPermitRequest, PropertyPermitResponse, PropertySkipTraceV3Request, PropertySkipTraceV3Response, PropertySkipTraceV3AsyncRequest, PropertySkipTraceV3AsyncResponse } from "../core/types";
|
|
4
|
+
import { PropertySubscriptionRequest, PropertySubscriptionResponse, PropertyCountRequest, PropertySearchRequest, PropertySearchResponse, PropertyLookupOptions, AddressVerifyRequest, AddressVerifyResponse, AddressAutocompleteRequest, AddressAutocompleteResponse, AddressGeocodeRequest, AddressGeocodeResponse, AddressReverseGeocodeRequest, AddressReverseGeocodeResponse, PropertyLookupRequest, PropertyLookupResponse, PropertyLookupAsyncRequest, PropertyLookupAsyncResponse, PropertySearchAsyncRequest, PropertySearchAsyncResponse, PropertySkipTraceRequest, PropertySkipTraceResponse, PropertySkipTraceAsyncRequest, PropertySkipTraceAsyncResponse, PhoneVerificationRequest, PhoneVerificationResponse, PhoneVerificationAsyncRequest, PhoneVerificationAsyncResponse, PhoneDNCRequest, PhoneDNCResponse, PhoneDNCAsyncRequest, PhoneDNCAsyncResponse, PhoneTCPARequest, PhoneTCPAResponse, PhoneTCPAAsyncRequest, PhoneTCPAAsyncResponse, GetPropertySubscriptionsResponse, GetPropertySubscriptionDetailResponse, DeletePropertySubscriptionResponse, PropertyPermitRequest, PropertyPermitResponse, PropertySkipTraceV3Request, PropertySkipTraceV3Response, PropertySkipTraceV3AsyncRequest, PropertySkipTraceV3AsyncResponse } from "../core/types";
|
|
5
5
|
/**
|
|
6
6
|
* Middleware function that executes before an HTTP request is sent.
|
|
7
7
|
* Can modify the request config or perform side effects (logging, metrics, etc.).
|
|
@@ -129,6 +129,41 @@ export interface BatchDataClientOptions {
|
|
|
129
129
|
* Allows specifying webhook URLs per endpoint type, with fallback to defaults
|
|
130
130
|
*/
|
|
131
131
|
webhooks?: AsyncWebhookConfiguration;
|
|
132
|
+
/**
|
|
133
|
+
* Optional default PropertyLookupOptions to apply to all requests
|
|
134
|
+
* These defaults are merged with request-specific options, with request options taking precedence
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const client = new BatchDataClient({
|
|
139
|
+
* apiKey: "...",
|
|
140
|
+
* defaultOptions: {
|
|
141
|
+
* take: 100, // Default to 100 properties if not specified
|
|
142
|
+
* }
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
defaultOptions?: PropertyLookupOptions;
|
|
147
|
+
/**
|
|
148
|
+
* Optional maximum `take` value to enforce on all requests
|
|
149
|
+
* If a request specifies a `take` value greater than this, it will be capped to this maximum
|
|
150
|
+
* This is useful for enforcing API limits or preventing accidental large requests
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const client = new BatchDataClient({
|
|
155
|
+
* apiKey: "...",
|
|
156
|
+
* maxTake: 100, // Cap all requests to max 100 properties
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* // Even if request specifies take: 500, it will be capped to 100
|
|
160
|
+
* await client.searchProperties({
|
|
161
|
+
* searchCriteria: { query: "AZ" },
|
|
162
|
+
* options: { take: 500 } // Will be capped to 100
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
maxTake?: number;
|
|
132
167
|
}
|
|
133
168
|
/**
|
|
134
169
|
* BatchData API Client
|
|
@@ -143,6 +178,8 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
143
178
|
protected readonly axiosInstance: AxiosInstance;
|
|
144
179
|
protected readonly logger: ILogger;
|
|
145
180
|
private readonly webhooks?;
|
|
181
|
+
private readonly defaultOptions?;
|
|
182
|
+
private readonly maxTake?;
|
|
146
183
|
constructor(options: BatchDataClientOptions);
|
|
147
184
|
/**
|
|
148
185
|
* Obfuscate sensitive headers (like Authorization) for logging
|
|
@@ -169,6 +206,30 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
169
206
|
* @returns The request with webhook URLs applied (if needed)
|
|
170
207
|
*/
|
|
171
208
|
private applyDefaultWebhookUrls;
|
|
209
|
+
/**
|
|
210
|
+
* Get the maximum take value for a request, applying maxTake limit if configured.
|
|
211
|
+
*
|
|
212
|
+
* @param originalRequest The original request
|
|
213
|
+
* @returns The take value to use (capped if necessary)
|
|
214
|
+
*/
|
|
215
|
+
private getMaxPropertyTake;
|
|
216
|
+
/**
|
|
217
|
+
* Apply defaults and limits to a request with search criteria.
|
|
218
|
+
* Uses the shared RequestWithSearchCriteria interface.
|
|
219
|
+
* Currently caps the take value based on maxTake config.
|
|
220
|
+
*
|
|
221
|
+
* @param request The request with search criteria to apply defaults to
|
|
222
|
+
* @returns A new request with defaults applied
|
|
223
|
+
*/
|
|
224
|
+
private applySearchRequestDefaultsAndLimits;
|
|
225
|
+
/**
|
|
226
|
+
* Apply default options to a request that supports PropertyLookupOptions.
|
|
227
|
+
* Defaults are merged with request-specific options, with request options taking precedence.
|
|
228
|
+
*
|
|
229
|
+
* @param request The request to apply defaults to
|
|
230
|
+
* @returns The request with defaults applied (if defaults are configured)
|
|
231
|
+
*/
|
|
232
|
+
private applyDefaultOptions;
|
|
172
233
|
/**
|
|
173
234
|
* Apply default webhook URLs to a property subscription request if they're not already set.
|
|
174
235
|
* This helper ensures that if webhook URLs are configured in the client,
|
package/dist/client/client.js
CHANGED
|
@@ -24,6 +24,8 @@ class BatchDataClient {
|
|
|
24
24
|
this.v3BaseUrl = options.v3BaseUrl || "https://api.batchdata.com/api/v3";
|
|
25
25
|
this.logger = options.logger || new logger_interface_1.ConsoleLogger();
|
|
26
26
|
this.webhooks = options.webhooks;
|
|
27
|
+
this.defaultOptions = options.defaultOptions;
|
|
28
|
+
this.maxTake = options.maxTake;
|
|
27
29
|
this.axiosInstance = axios_1.default.create({
|
|
28
30
|
timeout: options.timeout || 30000,
|
|
29
31
|
headers: {
|
|
@@ -211,6 +213,80 @@ class BatchDataClient {
|
|
|
211
213
|
},
|
|
212
214
|
};
|
|
213
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Get the maximum take value for a request, applying maxTake limit if configured.
|
|
218
|
+
*
|
|
219
|
+
* @param originalRequest The original request
|
|
220
|
+
* @returns The take value to use (capped if necessary)
|
|
221
|
+
*/
|
|
222
|
+
getMaxPropertyTake(originalRequest) {
|
|
223
|
+
if (this.maxTake === undefined) {
|
|
224
|
+
return originalRequest.options?.take;
|
|
225
|
+
}
|
|
226
|
+
const { take: originalTake } = originalRequest.options ?? {};
|
|
227
|
+
if (!originalTake)
|
|
228
|
+
return this.maxTake;
|
|
229
|
+
if (originalTake > this.maxTake) {
|
|
230
|
+
this.logger.warn(`Property search take value capped from ${originalTake} to ${this.maxTake} (maxTake limit)`);
|
|
231
|
+
return this.maxTake;
|
|
232
|
+
}
|
|
233
|
+
return originalTake;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Apply defaults and limits to a request with search criteria.
|
|
237
|
+
* Uses the shared RequestWithSearchCriteria interface.
|
|
238
|
+
* Currently caps the take value based on maxTake config.
|
|
239
|
+
*
|
|
240
|
+
* @param request The request with search criteria to apply defaults to
|
|
241
|
+
* @returns A new request with defaults applied
|
|
242
|
+
*/
|
|
243
|
+
applySearchRequestDefaultsAndLimits(request) {
|
|
244
|
+
// First merge defaults if configured
|
|
245
|
+
let requestWithDefaults = request;
|
|
246
|
+
if (this.defaultOptions) {
|
|
247
|
+
requestWithDefaults = this.applyDefaultOptions(request);
|
|
248
|
+
}
|
|
249
|
+
// Then apply maxTake limit
|
|
250
|
+
const maxTake = this.getMaxPropertyTake(requestWithDefaults);
|
|
251
|
+
if (maxTake !== undefined) {
|
|
252
|
+
return {
|
|
253
|
+
...requestWithDefaults,
|
|
254
|
+
options: {
|
|
255
|
+
...requestWithDefaults.options,
|
|
256
|
+
take: maxTake,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return requestWithDefaults;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Apply default options to a request that supports PropertyLookupOptions.
|
|
264
|
+
* Defaults are merged with request-specific options, with request options taking precedence.
|
|
265
|
+
*
|
|
266
|
+
* @param request The request to apply defaults to
|
|
267
|
+
* @returns The request with defaults applied (if defaults are configured)
|
|
268
|
+
*/
|
|
269
|
+
applyDefaultOptions(request) {
|
|
270
|
+
// If no defaults are configured, return original request
|
|
271
|
+
if (!this.defaultOptions) {
|
|
272
|
+
return request;
|
|
273
|
+
}
|
|
274
|
+
// Merge defaults with request options (request options take precedence)
|
|
275
|
+
const mergedOptions = {
|
|
276
|
+
...this.defaultOptions,
|
|
277
|
+
...request.options,
|
|
278
|
+
};
|
|
279
|
+
// If no options were actually merged (request had no options and defaults don't add anything),
|
|
280
|
+
// return original request
|
|
281
|
+
if (!request.options && Object.keys(mergedOptions).length === 0) {
|
|
282
|
+
return request;
|
|
283
|
+
}
|
|
284
|
+
// Return a new request object with merged options
|
|
285
|
+
return {
|
|
286
|
+
...request,
|
|
287
|
+
options: mergedOptions,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
214
290
|
/**
|
|
215
291
|
* Apply default webhook URLs to a property subscription request if they're not already set.
|
|
216
292
|
* This helper ensures that if webhook URLs are configured in the client,
|
|
@@ -374,7 +450,10 @@ class BatchDataClient {
|
|
|
374
450
|
async createPropertySubscription(request) {
|
|
375
451
|
const url = `${this.v2BaseUrl}/property-subscription`;
|
|
376
452
|
// Apply default webhook URLs if configured
|
|
377
|
-
|
|
453
|
+
let requestWithDefaults = this.applyPropertySubscriptionWebhooks(request);
|
|
454
|
+
// Apply defaults and limits (including maxTake)
|
|
455
|
+
requestWithDefaults =
|
|
456
|
+
this.applySearchRequestDefaultsAndLimits(requestWithDefaults);
|
|
378
457
|
this.logger.debug(`Creating property subscription: POST ${url}`, {
|
|
379
458
|
query: requestWithDefaults.searchCriteria.query,
|
|
380
459
|
});
|
|
@@ -403,12 +482,14 @@ class BatchDataClient {
|
|
|
403
482
|
*/
|
|
404
483
|
async searchProperties(request) {
|
|
405
484
|
const url = `${this.v1BaseUrl}/property/search`;
|
|
485
|
+
// Apply defaults and limits (including maxTake)
|
|
486
|
+
const requestWithDefaults = this.applySearchRequestDefaultsAndLimits(request);
|
|
406
487
|
this.logger.debug(`Searching properties: POST ${url}`, {
|
|
407
|
-
query:
|
|
408
|
-
take:
|
|
409
|
-
skip:
|
|
488
|
+
query: requestWithDefaults.searchCriteria.query,
|
|
489
|
+
take: requestWithDefaults.options?.take,
|
|
490
|
+
skip: requestWithDefaults.options?.skip,
|
|
410
491
|
});
|
|
411
|
-
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url,
|
|
492
|
+
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url, requestWithDefaults), "Failed to search properties", url);
|
|
412
493
|
this.logger.debug(`Property search completed`, {
|
|
413
494
|
status,
|
|
414
495
|
hasData: !!data,
|
|
@@ -530,10 +611,12 @@ class BatchDataClient {
|
|
|
530
611
|
*/
|
|
531
612
|
async lookupProperty(request) {
|
|
532
613
|
const url = `${this.v1BaseUrl}/property/lookup/all-attributes`;
|
|
614
|
+
// Apply default options if configured
|
|
615
|
+
const requestWithDefaults = this.applyDefaultOptions(request);
|
|
533
616
|
this.logger.debug(`Looking up property: POST ${url}`, {
|
|
534
|
-
requestCount:
|
|
617
|
+
requestCount: requestWithDefaults.requests.length,
|
|
535
618
|
});
|
|
536
|
-
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url,
|
|
619
|
+
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url, requestWithDefaults), "Failed to lookup property", url);
|
|
537
620
|
this.logger.debug(`Property lookup completed`, {
|
|
538
621
|
status,
|
|
539
622
|
propertyCount: data.results?.properties?.length,
|
|
@@ -550,7 +633,9 @@ class BatchDataClient {
|
|
|
550
633
|
async lookupPropertyAsync(request) {
|
|
551
634
|
const url = `${this.v1BaseUrl}/property/lookup/async`;
|
|
552
635
|
// Apply default webhook URLs if configured
|
|
553
|
-
|
|
636
|
+
let requestWithDefaults = this.applyDefaultWebhookUrls(request, "propertyLookup");
|
|
637
|
+
// Apply default options if configured
|
|
638
|
+
requestWithDefaults = this.applyDefaultOptions(requestWithDefaults);
|
|
554
639
|
this.logger.debug(`Looking up property async: POST ${url}`, {
|
|
555
640
|
requestCount: requestWithDefaults.requests.length,
|
|
556
641
|
});
|
|
@@ -571,7 +656,10 @@ class BatchDataClient {
|
|
|
571
656
|
async searchPropertiesAsync(request) {
|
|
572
657
|
const url = `${this.v1BaseUrl}/property/search/async`;
|
|
573
658
|
// Apply default webhook URLs if configured
|
|
574
|
-
|
|
659
|
+
let requestWithDefaults = this.applyDefaultWebhookUrls(request, "propertySearch");
|
|
660
|
+
// Apply defaults and limits (including maxTake)
|
|
661
|
+
requestWithDefaults =
|
|
662
|
+
this.applySearchRequestDefaultsAndLimits(requestWithDefaults);
|
|
575
663
|
this.logger.debug(`Searching properties async: POST ${url}`, {
|
|
576
664
|
query: requestWithDefaults.searchCriteria.query,
|
|
577
665
|
});
|
package/dist/core/types.d.ts
CHANGED
|
@@ -478,10 +478,8 @@ export interface DeliveryConfig {
|
|
|
478
478
|
/**
|
|
479
479
|
* Property subscription request payload
|
|
480
480
|
*/
|
|
481
|
-
export interface PropertySubscriptionRequest {
|
|
482
|
-
searchCriteria: SearchCriteria;
|
|
481
|
+
export interface PropertySubscriptionRequest extends RequestWithSearchCriteria {
|
|
483
482
|
deliveryConfig: DeliveryConfig;
|
|
484
|
-
options?: PropertyLookupOptions;
|
|
485
483
|
}
|
|
486
484
|
/**
|
|
487
485
|
* Property subscription response
|
|
@@ -1713,6 +1711,58 @@ export interface PropertyLookupRequestItem {
|
|
|
1713
1711
|
countyFipsCode?: string;
|
|
1714
1712
|
requestId?: string;
|
|
1715
1713
|
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Base interface for requests that support PropertyLookupOptions
|
|
1716
|
+
* This allows for type-safe application of defaults and limits across request types
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* ```typescript
|
|
1720
|
+
* // Apply defaults to any request with lookup options
|
|
1721
|
+
* function applyDefaults<T extends RequestWithLookupOptions>(
|
|
1722
|
+
* request: T,
|
|
1723
|
+
* defaults: PropertyLookupOptions
|
|
1724
|
+
* ): T {
|
|
1725
|
+
* return {
|
|
1726
|
+
* ...request,
|
|
1727
|
+
* options: { ...defaults, ...request.options },
|
|
1728
|
+
* };
|
|
1729
|
+
* }
|
|
1730
|
+
* ```
|
|
1731
|
+
*/
|
|
1732
|
+
export interface RequestWithLookupOptions {
|
|
1733
|
+
options?: PropertyLookupOptions;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Base interface for requests that have both searchCriteria and PropertyLookupOptions
|
|
1737
|
+
* Most search-based requests extend this interface
|
|
1738
|
+
*
|
|
1739
|
+
* @example
|
|
1740
|
+
* ```typescript
|
|
1741
|
+
* // Apply defaults to any request with search criteria and options
|
|
1742
|
+
* function applySearchDefaults<T extends RequestWithSearchCriteria>(
|
|
1743
|
+
* request: T,
|
|
1744
|
+
* defaults: PropertyLookupOptions
|
|
1745
|
+
* ): T {
|
|
1746
|
+
* return {
|
|
1747
|
+
* ...request,
|
|
1748
|
+
* options: { ...defaults, ...request.options },
|
|
1749
|
+
* };
|
|
1750
|
+
* }
|
|
1751
|
+
* ```
|
|
1752
|
+
*/
|
|
1753
|
+
export interface RequestWithSearchCriteria extends RequestWithLookupOptions {
|
|
1754
|
+
searchCriteria: SearchCriteria;
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Type helper to extract request types that support PropertyLookupOptions
|
|
1758
|
+
* Useful for writing generic functions that work with any request type
|
|
1759
|
+
*/
|
|
1760
|
+
export type RequestWithLookupOptionsType = PropertySearchRequest | PropertySearchAsyncRequest | PropertyLookupRequest | PropertyLookupAsyncRequest | PropertySubscriptionRequest;
|
|
1761
|
+
/**
|
|
1762
|
+
* Type helper to extract request types that have both searchCriteria and options
|
|
1763
|
+
* Useful for writing generic functions that work with search-based requests
|
|
1764
|
+
*/
|
|
1765
|
+
export type RequestWithSearchCriteriaType = PropertySearchRequest | PropertySearchAsyncRequest | PropertySubscriptionRequest;
|
|
1716
1766
|
/**
|
|
1717
1767
|
* Property lookup options (shared with property search)
|
|
1718
1768
|
*/
|
|
@@ -1765,10 +1815,7 @@ export interface PropertyLookupOptions {
|
|
|
1765
1815
|
/**
|
|
1766
1816
|
* Property search request (synchronous)
|
|
1767
1817
|
*/
|
|
1768
|
-
export
|
|
1769
|
-
searchCriteria: SearchCriteria;
|
|
1770
|
-
options?: PropertyLookupOptions;
|
|
1771
|
-
}
|
|
1818
|
+
export type PropertySearchRequest = RequestWithSearchCriteria;
|
|
1772
1819
|
/**
|
|
1773
1820
|
* Property count request
|
|
1774
1821
|
*
|
|
@@ -1788,9 +1835,8 @@ export interface PropertyCountRequest {
|
|
|
1788
1835
|
/**
|
|
1789
1836
|
* Property lookup request
|
|
1790
1837
|
*/
|
|
1791
|
-
export interface PropertyLookupRequest {
|
|
1838
|
+
export interface PropertyLookupRequest extends RequestWithLookupOptions {
|
|
1792
1839
|
requests: PropertyLookupRequestItem[];
|
|
1793
|
-
options?: PropertyLookupOptions;
|
|
1794
1840
|
}
|
|
1795
1841
|
/**
|
|
1796
1842
|
* Property lookup API response (same structure as PropertySearchResponse)
|
|
@@ -1805,9 +1851,8 @@ export interface PropertyLookupResponse {
|
|
|
1805
1851
|
/**
|
|
1806
1852
|
* Property lookup async request
|
|
1807
1853
|
*/
|
|
1808
|
-
export interface PropertyLookupAsyncRequest {
|
|
1854
|
+
export interface PropertyLookupAsyncRequest extends RequestWithLookupOptions {
|
|
1809
1855
|
requests: PropertyLookupRequestItem[];
|
|
1810
|
-
options?: PropertyLookupOptions;
|
|
1811
1856
|
}
|
|
1812
1857
|
/**
|
|
1813
1858
|
* Property lookup async API response
|
|
@@ -1824,10 +1869,7 @@ export type PropertyLookupAsyncWebhookPayload = PropertyLookupResponse;
|
|
|
1824
1869
|
/**
|
|
1825
1870
|
* Property search async request
|
|
1826
1871
|
*/
|
|
1827
|
-
export
|
|
1828
|
-
searchCriteria: SearchCriteria;
|
|
1829
|
-
options?: PropertyLookupOptions;
|
|
1830
|
-
}
|
|
1872
|
+
export type PropertySearchAsyncRequest = RequestWithSearchCriteria;
|
|
1831
1873
|
/**
|
|
1832
1874
|
* Property search async API response
|
|
1833
1875
|
* Async endpoints return only a status object. Full results are delivered to the webhook URL.
|
package/package.json
CHANGED