@land-catalyst/batch-data-sdk 1.1.12 → 1.1.19

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.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Property Field Type Utilities
3
+ *
4
+ * Type-level utilities for working with property field paths
5
+ */
6
+ import type { Property } from "../core/types";
7
+ import type { PropertyFieldMetadata } from "./metadata";
8
+ /**
9
+ * Extract all possible field paths from Property type
10
+ * This is a helper type for type-safe field path access
11
+ */
12
+ export type PropertyFieldPathType = {
13
+ [K in keyof Property]: K extends string ? Property[K] extends object | undefined ? K | `${K}.${NestedFieldPath<NonNullable<Property[K]>>}` : K : never;
14
+ }[keyof Property];
15
+ type NestedFieldPath<T> = T extends (infer U)[] ? U extends object ? `[n].${NestedFieldPath<U>}` : never : T extends object ? {
16
+ [K in keyof T]: K extends string ? T[K] extends object | undefined ? K | `${K}.${NestedFieldPath<NonNullable<T[K]>>}` : K : never;
17
+ }[keyof T] : never;
18
+ /**
19
+ * Get the TypeScript type for a property field path
20
+ * @template TPath The field path type
21
+ * @example
22
+ * ```typescript
23
+ * type CityType = PropertyFieldValueType<"address.city">; // string | undefined
24
+ * ```
25
+ */
26
+ export type PropertyFieldValueType<TPath extends string> = TPath extends `${infer K}.${infer Rest}` ? K extends keyof Property ? Property[K] extends object | undefined ? Rest extends string ? NestedFieldType<NonNullable<Property[K]>, Rest> : never : never : never : TPath extends keyof Property ? Property[TPath] : unknown;
27
+ type NestedFieldType<T, Path extends string> = Path extends `[n].${infer Rest}` ? T extends (infer U)[] ? U extends object ? Rest extends string ? NestedFieldType<U, Rest> : U : U : never : Path extends `${infer K}.${infer Rest}` ? K extends keyof T ? T[K] extends object | undefined ? Rest extends string ? NestedFieldType<NonNullable<T[K]>, Rest> : T[K] : T[K] : never : Path extends keyof T ? T[Path] : unknown;
28
+ /**
29
+ * Type-safe field metadata lookup
30
+ * @template TPath The field path
31
+ */
32
+ export type FieldMetadataForPath<TPath extends string> = TPath extends keyof typeof import("./metadata").PROPERTY_FIELD_METADATA ? (typeof import("./metadata").PROPERTY_FIELD_METADATA)[TPath] : PropertyFieldMetadata | undefined;
33
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Property Field Type Utilities
4
+ *
5
+ * Type-level utilities for working with property field paths
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ // Note: PropertyFieldPathType is the main type-safe field path type
9
+ // SimplePropertyFieldPath from property-field-utils provides a simpler alternative
@@ -0,0 +1,306 @@
1
+ /**
2
+ * Property Field Utilities
3
+ *
4
+ * Utilities for working with property field paths and metadata
5
+ */
6
+ import type { Property } from "../core/types";
7
+ import { type PropertyFieldMetadata } from "./metadata";
8
+ /**
9
+ * Simple property field path type (string union)
10
+ * For more advanced type-safe paths, use PropertyFieldPathType from property-field-types
11
+ */
12
+ export type SimplePropertyFieldPath = keyof Property | string;
13
+ /**
14
+ * Get metadata for a property field by its path
15
+ * @param fieldPath The field path (e.g., "address.city", "owner.fullName")
16
+ * @returns The field metadata, or undefined if not found
17
+ * @example
18
+ * ```typescript
19
+ * const cityMeta = getPropertyFieldMetadata("address.city");
20
+ * console.log(cityMeta?.description); // "The city (e.g. Chicago)"
21
+ * ```
22
+ */
23
+ export declare function getPropertyFieldMetadata(fieldPath: string): PropertyFieldMetadata | undefined;
24
+ /**
25
+ * Get the value at a field path from a property object
26
+ * @param property The property object
27
+ * @param fieldPath The field path (e.g., "address.city", "owner.fullName")
28
+ * @returns The value at the path, or undefined if not found
29
+ * @example
30
+ * ```typescript
31
+ * const city = getPropertyFieldValue(property, "address.city");
32
+ * ```
33
+ */
34
+ export declare function getPropertyFieldValue(property: Property, fieldPath: string): unknown;
35
+ /**
36
+ * Get metadata for all fields in a response group
37
+ * @param groupName The response group name (e.g., "address", "owner", "building")
38
+ * @returns Array of field metadata for that group
39
+ * @example
40
+ * ```typescript
41
+ * const addressFields = getPropertyGroupFields("address");
42
+ * // Returns all fields under address.*
43
+ * ```
44
+ */
45
+ export declare function getPropertyGroupFields(groupName: string): PropertyFieldMetadata[];
46
+ /**
47
+ * Get metadata for a nested field path
48
+ * Handles nested paths like "owner.mailingAddress.city"
49
+ * @param fieldPath The full field path
50
+ * @returns The field metadata, or undefined if not found
51
+ */
52
+ export declare function getNestedFieldMetadata(fieldPath: string): PropertyFieldMetadata | undefined;
53
+ /**
54
+ * Type guard to check if a field path exists in metadata
55
+ * @param fieldPath The field path to check
56
+ * @returns True if the field exists in metadata
57
+ */
58
+ export declare function isValidPropertyField(fieldPath: string): boolean;
59
+ /**
60
+ * Get all field paths for a specific property group
61
+ * @param groupName The response group name
62
+ * @returns Array of field paths
63
+ */
64
+ export declare function getPropertyGroupFieldPaths(groupName: string): string[];
65
+ /**
66
+ * Get field description for a property field
67
+ * @param fieldPath The field path
68
+ * @returns The description, or undefined if not found
69
+ */
70
+ export declare function getPropertyFieldDescription(fieldPath: string): string | undefined;
71
+ /**
72
+ * Get field data type for a property field
73
+ * @param fieldPath The field path
74
+ * @returns The data type, or undefined if not found
75
+ */
76
+ export declare function getPropertyFieldType(fieldPath: string): PropertyFieldMetadata["dataType"] | undefined;
77
+ /**
78
+ * SearchCriteria field metadata inferred from Property field metadata
79
+ * This helps users understand what Property field they're filtering on
80
+ */
81
+ export interface SearchCriteriaFieldMetadata {
82
+ /**
83
+ * The SearchCriteria field path (e.g., "address.city", "building.yearBuilt")
84
+ */
85
+ searchCriteriaPath: string;
86
+ /**
87
+ * The corresponding Property field path, if found
88
+ */
89
+ propertyPath: string | undefined;
90
+ /**
91
+ * The Property field metadata, if found
92
+ */
93
+ propertyMetadata: PropertyFieldMetadata | undefined;
94
+ /**
95
+ * Whether this SearchCriteria field has a corresponding Property field
96
+ */
97
+ hasPropertyMapping: boolean;
98
+ /**
99
+ * Description for the SearchCriteria field (inferred from Property metadata)
100
+ * Explains what Property field is being filtered on
101
+ */
102
+ description: string;
103
+ /**
104
+ * The data type of the Property field being filtered (e.g., "string", "number")
105
+ */
106
+ propertyDataType: string | undefined;
107
+ /**
108
+ * The dataset the Property field belongs to
109
+ */
110
+ dataset: string | undefined;
111
+ }
112
+ /**
113
+ * Map a SearchCriteria field path to its corresponding Property field path
114
+ * Most SearchCriteria fields map directly to Property fields (e.g., "address.city" -> "address.city")
115
+ * @param searchCriteriaPath The field path in SearchCriteria (e.g., "address.city", "building.yearBuilt")
116
+ * @returns The corresponding Property field path, or undefined if no mapping exists
117
+ * @example
118
+ * ```typescript
119
+ * const propertyPath = mapSearchCriteriaToPropertyPath("address.city");
120
+ * // Returns "address.city"
121
+ *
122
+ * const propertyPath = mapSearchCriteriaToPropertyPath("building.yearBuilt");
123
+ * // Returns "building.yearBuilt"
124
+ * ```
125
+ */
126
+ export declare function mapSearchCriteriaToPropertyPath(searchCriteriaPath: string): string | undefined;
127
+ /**
128
+ * Get Property field metadata for a SearchCriteria field path
129
+ * This helps users understand what Property field they're filtering on
130
+ * @param searchCriteriaPath The field path in SearchCriteria (e.g., "address.city", "building.yearBuilt")
131
+ * @returns The Property field metadata, or undefined if not found
132
+ * @example
133
+ * ```typescript
134
+ * // When building a search criteria, see what Property field you're filtering on
135
+ * const metadata = getSearchCriteriaFieldMetadata("address.city");
136
+ * console.log(metadata?.description); // "The city (e.g. Chicago)"
137
+ * console.log(metadata?.dataType); // "string"
138
+ *
139
+ * const builder = new AddressSearchCriteriaBuilder();
140
+ * builder.city((c) => {
141
+ * // You're filtering on Property.address.city
142
+ * const meta = getSearchCriteriaFieldMetadata("address.city");
143
+ * console.log(`Filtering on: ${meta?.description}`);
144
+ * c.equals("Phoenix");
145
+ * });
146
+ * ```
147
+ */
148
+ export declare function getSearchCriteriaFieldMetadata(searchCriteriaPath: string): PropertyFieldMetadata | undefined;
149
+ /**
150
+ * Get SearchCriteria field metadata inferred from Property field metadata
151
+ * This creates a SearchCriteria-specific metadata object that references the Property field
152
+ * @param searchCriteriaPath The field path in SearchCriteria (e.g., "address.city", "building.yearBuilt")
153
+ * @returns SearchCriteria field metadata with Property field information
154
+ * @example
155
+ * ```typescript
156
+ * // Get metadata for a SearchCriteria field, even if it doesn't map exactly
157
+ * const scMetadata = getSearchCriteriaMetadata("address.city");
158
+ * console.log(scMetadata.description); // "Filter on: The city (e.g. Chicago)"
159
+ * console.log(scMetadata.propertyPath); // "address.city"
160
+ * console.log(scMetadata.hasPropertyMapping); // true
161
+ *
162
+ * // Works even for fields that might not have exact Property mappings
163
+ * const scMetadata2 = getSearchCriteriaMetadata("assessment.assessmentYear");
164
+ * if (scMetadata2.hasPropertyMapping) {
165
+ * console.log(`Filtering on: ${scMetadata2.propertyMetadata?.description}`);
166
+ * }
167
+ * ```
168
+ */
169
+ export declare function getSearchCriteriaMetadata(searchCriteriaPath: string): SearchCriteriaFieldMetadata;
170
+ /**
171
+ * Get all SearchCriteria field paths that map to a specific Property response group
172
+ * @param propertyGroupName The Property response group name (e.g., "address", "owner", "building")
173
+ * @returns Array of SearchCriteria field paths that filter on fields in that group
174
+ * @example
175
+ * ```typescript
176
+ * // Get all SearchCriteria fields that filter on address fields
177
+ * const addressSearchFields = getSearchCriteriaFieldsForPropertyGroup("address");
178
+ * // Returns: ["address.street", "address.city", "address.state", ...]
179
+ * ```
180
+ */
181
+ export declare function getSearchCriteriaFieldsForPropertyGroup(propertyGroupName: string): string[];
182
+ /**
183
+ * Get metadata for all SearchCriteria fields that correspond to a Property response group
184
+ * @param propertyGroupName The Property response group name (e.g., "address", "owner", "building")
185
+ * @returns Array of objects containing both the SearchCriteria path and its Property metadata
186
+ * @example
187
+ * ```typescript
188
+ * // Get all address-related SearchCriteria fields with their metadata
189
+ * const addressFields = getSearchCriteriaFieldsWithMetadata("address");
190
+ * // Returns: [
191
+ * // { searchCriteriaPath: "address.city", metadata: {...}, propertyPath: "address.city" },
192
+ * // { searchCriteriaPath: "address.street", metadata: {...}, propertyPath: "address.street" },
193
+ * // ...
194
+ * // ]
195
+ * ```
196
+ */
197
+ export interface SearchCriteriaFieldMapping {
198
+ /**
199
+ * The field path in SearchCriteria
200
+ */
201
+ searchCriteriaPath: string;
202
+ /**
203
+ * The corresponding Property field path
204
+ */
205
+ propertyPath: string;
206
+ /**
207
+ * The Property field metadata
208
+ */
209
+ metadata: PropertyFieldMetadata;
210
+ }
211
+ export declare function getSearchCriteriaFieldsWithMetadata(propertyGroupName: string): SearchCriteriaFieldMapping[];
212
+ /**
213
+ * Get SearchCriteria metadata for all fields in a Property response group
214
+ * @param propertyGroupName The Property response group name (e.g., "address", "owner", "building")
215
+ * @returns Array of SearchCriteria field metadata objects
216
+ * @example
217
+ * ```typescript
218
+ * // Get all address-related SearchCriteria fields with inferred metadata
219
+ * const addressFields = getSearchCriteriaMetadataForGroup("address");
220
+ * // Returns SearchCriteriaFieldMetadata[] with descriptions like
221
+ * // "Filter on: The city (e.g. Chicago)"
222
+ * ```
223
+ */
224
+ export declare function getSearchCriteriaMetadataForGroup(propertyGroupName: string): SearchCriteriaFieldMetadata[];
225
+ /**
226
+ * Extract all field paths from a SearchCriteria object
227
+ * Recursively walks through the SearchCriteria structure and collects all field paths
228
+ * @param searchCriteria The SearchCriteria object to analyze
229
+ * @param prefix Optional prefix for nested paths (used internally for recursion)
230
+ * @returns Array of field paths found in the SearchCriteria
231
+ * @example
232
+ * ```typescript
233
+ * const criteria = {
234
+ * address: { city: { equals: "Phoenix" }, state: { equals: "AZ" } },
235
+ * building: { yearBuilt: { min: 1990, max: 2020 } }
236
+ * };
237
+ * const paths = extractSearchCriteriaFieldPaths(criteria);
238
+ * // Returns: ["address.city", "address.state", "building.yearBuilt"]
239
+ * ```
240
+ */
241
+ export declare function extractSearchCriteriaFieldPaths(searchCriteria: Record<string, unknown>, prefix?: string): string[];
242
+ /**
243
+ * Get metadata for all fields present in a SearchCriteria object
244
+ * Extracts all field paths and generates metadata for each one
245
+ * @param searchCriteria The SearchCriteria object to analyze
246
+ * @returns Array of SearchCriteria field metadata for all fields found
247
+ * @example
248
+ * ```typescript
249
+ * const criteria = new SearchCriteriaBuilder("US")
250
+ * .address((a) => {
251
+ * a.city((c) => c.equals("Phoenix"))
252
+ * .state((s) => s.equals("AZ"));
253
+ * })
254
+ * .building((b) => {
255
+ * b.yearBuilt((y) => y.min(1990).max(2020));
256
+ * })
257
+ * .build();
258
+ *
259
+ * const metadata = getSearchCriteriaFieldsMetadata(criteria);
260
+ * // Returns metadata for address.city, address.state, building.yearBuilt
261
+ * ```
262
+ */
263
+ export declare function getSearchCriteriaFieldsMetadata(searchCriteria: Record<string, unknown>): SearchCriteriaFieldMetadata[];
264
+ /**
265
+ * Field metadata entry for a property object
266
+ */
267
+ export interface PropertyFieldMetadataEntry {
268
+ /**
269
+ * The field path (e.g., "address.city", "owner.fullName")
270
+ */
271
+ fieldPath: string;
272
+ /**
273
+ * The actual value at this path in the property object
274
+ */
275
+ value: unknown;
276
+ /**
277
+ * The metadata for this field, if available
278
+ */
279
+ metadata: PropertyFieldMetadata | undefined;
280
+ /**
281
+ * Whether this field has metadata available
282
+ */
283
+ hasMetadata: boolean;
284
+ }
285
+ /**
286
+ * Get metadata for all fields present in a property object
287
+ * Recursively iterates through the property object and collects metadata for each field.
288
+ *
289
+ * Note: This function is designed for Property response objects, not SearchCriteria.
290
+ * The metadata describes Property response fields (their types, descriptions, datasets),
291
+ * which are different from SearchCriteria filter objects.
292
+ *
293
+ * @param property The property object to analyze
294
+ * @param prefix Optional prefix for nested paths (used internally for recursion)
295
+ * @returns Array of field metadata entries
296
+ * @example
297
+ * ```typescript
298
+ * const property = {
299
+ * address: { city: "Phoenix", state: "AZ" },
300
+ * owner: { fullName: "John Doe" }
301
+ * };
302
+ * const metadata = getPropertyFieldsMetadata(property);
303
+ * // Returns metadata for address.city, address.state, owner.fullName
304
+ * ```
305
+ */
306
+ export declare function getPropertyFieldsMetadata(property: Property | Partial<Property>, prefix?: string): PropertyFieldMetadataEntry[];