@pulseindex/sdk 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,324 @@
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import { ServiceError } from '@grpc/grpc-js';
3
+
4
+ declare const FilterOperation: {
5
+ readonly MUST: 0;
6
+ readonly SHOULD: 1;
7
+ readonly MUST_NOT: 2;
8
+ };
9
+ type FilterOperationCode = (typeof FilterOperation)[keyof typeof FilterOperation];
10
+ type EntityId = string | number | bigint;
11
+ interface FilterPredicate {
12
+ op: FilterOperationCode;
13
+ attribute: string;
14
+ }
15
+ interface RangePredicate {
16
+ field: string;
17
+ minVal: number;
18
+ maxVal: number;
19
+ }
20
+ interface SearchQueryRequest {
21
+ locationPrefix: string;
22
+ filters: FilterPredicate[];
23
+ ranges: RangePredicate[];
24
+ limit: number;
25
+ offset: number;
26
+ tenantId: string;
27
+ }
28
+ interface SearchResponse {
29
+ matchedEntityIds: string[];
30
+ totalMatches: number;
31
+ executionTimeUs: number;
32
+ }
33
+ interface IndexEntityRequest {
34
+ entityId: string;
35
+ locationPrefix: string;
36
+ price: number;
37
+ categories: string[];
38
+ tenantId: string;
39
+ }
40
+ interface IndexEntityResponse {
41
+ success: boolean;
42
+ }
43
+ interface BatchIndexResponse {
44
+ indexedCount: number;
45
+ }
46
+ interface DeleteResponse {
47
+ success: boolean;
48
+ }
49
+ interface RadiusOptions {
50
+ lat: number;
51
+ lng?: number;
52
+ lon?: number;
53
+ radiusKm: number;
54
+ precision?: number;
55
+ }
56
+ interface SearchRequestOptions {
57
+ tenantId?: string;
58
+ locationPrefix?: EntityId;
59
+ must?: string | string[];
60
+ should?: string | string[];
61
+ mustNot?: string | string[];
62
+ ranges?: Array<{
63
+ field: string;
64
+ min: number;
65
+ max: number;
66
+ }>;
67
+ limit?: number;
68
+ offset?: number;
69
+ withinRadius?: RadiusOptions;
70
+ geoHash?: string;
71
+ }
72
+ interface EntityAttributes {
73
+ categories?: unknown;
74
+ tags?: unknown;
75
+ price?: unknown;
76
+ locationPrefix?: unknown;
77
+ location_prefix?: unknown;
78
+ tenantId?: unknown;
79
+ tenant_id?: unknown;
80
+ latitude?: unknown;
81
+ longitude?: unknown;
82
+ lat?: unknown;
83
+ lng?: unknown;
84
+ lon?: unknown;
85
+ [key: string]: unknown;
86
+ }
87
+ interface EntityInput {
88
+ id?: EntityId;
89
+ entityId?: EntityId;
90
+ entity_id?: EntityId;
91
+ attributes?: EntityAttributes;
92
+ categories?: unknown;
93
+ tags?: unknown;
94
+ price?: unknown;
95
+ locationPrefix?: unknown;
96
+ location_prefix?: unknown;
97
+ tenantId?: unknown;
98
+ tenant_id?: unknown;
99
+ latitude?: unknown;
100
+ longitude?: unknown;
101
+ lat?: unknown;
102
+ lng?: unknown;
103
+ lon?: unknown;
104
+ [key: string]: unknown;
105
+ }
106
+ interface BatchEntityInput {
107
+ id?: EntityId;
108
+ entityId?: EntityId;
109
+ entity_id?: EntityId;
110
+ attributes?: EntityAttributes;
111
+ [key: string]: unknown;
112
+ }
113
+ interface EncodedEntity {
114
+ entityId: string;
115
+ categories: string[];
116
+ price: number;
117
+ locationPrefix: string;
118
+ tenantId: string;
119
+ }
120
+ interface PulseIndexClientConfig {
121
+ endpoint?: string;
122
+ host?: string;
123
+ apiKey?: string;
124
+ authorization?: string;
125
+ tenantId?: string;
126
+ timeoutMs?: number;
127
+ ssl?: boolean | string | number;
128
+ rootCerts?: Buffer;
129
+ privateKey?: Buffer;
130
+ certChain?: Buffer;
131
+ protoPath?: string;
132
+ /** Override the bundled `health.proto`. Only needed if the package layout is rewritten. */
133
+ healthProtoPath?: string;
134
+ poolSize?: number;
135
+ channelOptions?: Record<string, unknown>;
136
+ }
137
+
138
+ interface QueryExecutor {
139
+ search(query: QueryBuilder): Promise<SearchResponse>;
140
+ }
141
+ declare class QueryBuilder {
142
+ private readonly executor;
143
+ private state;
144
+ constructor(executor?: QueryExecutor | null);
145
+ tenant(tenantId: string): QueryBuilder;
146
+ location(locationPrefix: string | number | bigint): QueryBuilder;
147
+ must(attribute: string | string[]): QueryBuilder;
148
+ should(attribute: string | string[]): QueryBuilder;
149
+ mustNot(attribute: string | string[]): QueryBuilder;
150
+ whereGeoHash(geohash: string): QueryBuilder;
151
+ inGeoHash(geohash: string): QueryBuilder;
152
+ withinRadius(lat: number, lon: number, radiusKm: number, precision?: number): QueryBuilder;
153
+ withinRadius(options: RadiusOptions): QueryBuilder;
154
+ range(field: string, min: number, max: number): QueryBuilder;
155
+ limit(limit: number): QueryBuilder;
156
+ offset(offset: number): QueryBuilder;
157
+ toRequest(defaultTenantId?: string): SearchQueryRequest;
158
+ toArray(defaultTenantId?: string): SearchQueryRequest;
159
+ execute(): Promise<SearchResponse>;
160
+ static fromOptions(options: SearchRequestOptions, executor?: QueryExecutor | null): QueryBuilder;
161
+ private addFilters;
162
+ private fork;
163
+ }
164
+
165
+ interface SearchEngineServiceClient extends grpc.Client {
166
+ indexEntity(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
167
+ batchIndexEntities(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
168
+ deleteEntity(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
169
+ search(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
170
+ }
171
+ /** `grpc.health.v1.Health` — the readiness check that needs no scope. */
172
+ interface HealthClient extends grpc.Client {
173
+ check(request: {
174
+ service: string;
175
+ }, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<{
176
+ status?: number;
177
+ }>): grpc.ClientUnaryCall;
178
+ }
179
+ /** Values of `grpc.health.v1.HealthCheckResponse.ServingStatus`. */
180
+ declare const SERVING_STATUS: {
181
+ readonly UNKNOWN: 0;
182
+ readonly SERVING: 1;
183
+ readonly NOT_SERVING: 2;
184
+ readonly SERVICE_UNKNOWN: 3;
185
+ };
186
+
187
+ declare function sslEnabled(config: PulseIndexClientConfig): boolean;
188
+ declare class ConnectionManager {
189
+ readonly endpoint: string;
190
+ readonly tenantId: string;
191
+ readonly timeoutMs: number;
192
+ readonly ssl: boolean;
193
+ private readonly apiKey?;
194
+ private readonly authorization?;
195
+ private readonly clients;
196
+ private cursor;
197
+ private closed;
198
+ private readonly credentials;
199
+ private readonly channelOptions;
200
+ private readonly healthProtoPath?;
201
+ private healthStub?;
202
+ constructor(config?: PulseIndexClientConfig);
203
+ /**
204
+ * `grpc.health.v1.Health` stub, created on first use.
205
+ *
206
+ * A separate service from the query API, and unauthenticated: the health
207
+ * protocol needs no scope, so it works with any key or none.
208
+ */
209
+ getHealthStub(): HealthClient;
210
+ getStub(): SearchEngineServiceClient;
211
+ createMetadata(): grpc.Metadata;
212
+ createCallOptions(): grpc.CallOptions;
213
+ waitForReady(timeoutMs?: number): Promise<void>;
214
+ close(): void;
215
+ private assertOpen;
216
+ private createCredentials;
217
+ }
218
+
219
+ declare class PulseIndexClient implements QueryExecutor {
220
+ readonly connection: ConnectionManager;
221
+ constructor(config?: PulseIndexClientConfig);
222
+ static create(endpoint: string, apiKey?: string, ssl?: boolean, extra?: Omit<PulseIndexClientConfig, 'endpoint' | 'apiKey' | 'ssl'>): PulseIndexClient;
223
+ static query(): QueryBuilder;
224
+ query(): QueryBuilder;
225
+ search(query: QueryBuilder | SearchRequestOptions): Promise<SearchResponse>;
226
+ index(entityIdOrInput: EntityId | EntityInput, attributes?: EntityAttributes): Promise<IndexEntityResponse>;
227
+ indexEntity(entityId: EntityId, categories?: string[], price?: number, locationPrefix?: EntityId, tenantId?: string): Promise<boolean>;
228
+ batchIndex(entities: Array<EntityInput | BatchEntityInput>): Promise<BatchIndexResponse>;
229
+ delete(entityId: EntityId, tenantId?: string): Promise<DeleteResponse>;
230
+ deleteEntity(entityId: EntityId, tenantId?: string): Promise<boolean>;
231
+ /**
232
+ * True only when the engine can serve reads.
233
+ *
234
+ * Asks `grpc.health.v1.Health`, which needs no particular scope and tracks
235
+ * whether the service can currently answer queries. So this distinguishes a
236
+ * reachable-but-unavailable service from a healthy one.
237
+ *
238
+ * Returns `false` rather than throwing, so unreachable and unavailable look
239
+ * the same here. Use {@link servingStatus} to tell them apart.
240
+ */
241
+ health(): Promise<boolean>;
242
+ /**
243
+ * Raw `grpc.health.v1` serving status for a service name.
244
+ *
245
+ * Defaults to `''`, the overall-server key defined by the health spec. The
246
+ * service answers for both that and its named service.
247
+ */
248
+ servingStatus(service?: string): Promise<number>;
249
+ close(): void;
250
+ private unary;
251
+ }
252
+ declare class PulseIndex extends PulseIndexClient {
253
+ }
254
+
255
+ declare class GeoHash {
256
+ static readonly TAG_PREFIX = "geo:";
257
+ static readonly MIN_PRECISION = 1;
258
+ static readonly MAX_PRECISION = 12;
259
+ static readonly INDEX_PRECISIONS: readonly [5, 6];
260
+ private static readonly BASE32;
261
+ private static readonly EARTH_RADIUS_KM;
262
+ private static readonly MAX_COVERING_CELLS;
263
+ private static readonly NEIGHBORS;
264
+ private static readonly BORDERS;
265
+ static encode(lat: number, lon: number, precision?: number): string;
266
+ static decode(hash: string): {
267
+ lat: number;
268
+ lon: number;
269
+ };
270
+ static decodeBounds(hash: string): {
271
+ latMin: number;
272
+ latMax: number;
273
+ lonMin: number;
274
+ lonMax: number;
275
+ };
276
+ static neighbor(hash: string, direction: string): string;
277
+ static neighbors(hash: string): string[];
278
+ static neighborhood3x3(hash: string): string[];
279
+ static neighborhoodTags(lat: number, lon: number, precision?: number): string[];
280
+ static optimalPrecisionForRadius(radiusKm: number): number;
281
+ static precisionForRadius(radiusKm: number): number;
282
+ static getCoveringHashes(lat: number, lon: number, radiusKm: number, precision?: number): string[];
283
+ static tag(geohash: string): string;
284
+ static encodeTag(lat: number, lon: number, precision?: number): string;
285
+ static encodeMultiTags(lat: number, lon: number): string[];
286
+ static haversineKm(lat1: number, lon1: number, lat2: number, lon2: number): number;
287
+ private static cellIntersectsCircle;
288
+ private static adjacent;
289
+ private static normalizeHash;
290
+ private static assertLatitude;
291
+ private static assertLongitude;
292
+ private static assertPrecision;
293
+ private static isCardinal;
294
+ private static toRadians;
295
+ }
296
+
297
+ declare function toUint64String(value: EntityId, field?: string): string;
298
+ declare function encodeEntity(entityIdOrInput: EntityId | EntityInput, attributes?: EntityAttributes, defaults?: {
299
+ tenantId?: string;
300
+ }): EncodedEntity;
301
+
302
+ declare class PulseIndexError extends Error {
303
+ readonly code: string;
304
+ readonly grpcStatusCode?: number;
305
+ readonly grpcDetails?: string;
306
+ constructor(message: string, options?: {
307
+ code?: string;
308
+ grpcStatusCode?: number;
309
+ grpcDetails?: string;
310
+ cause?: unknown;
311
+ });
312
+ static fromGrpc(error: ServiceError | Error): PulseIndexError;
313
+ }
314
+ declare class PulseIndexConnectionError extends PulseIndexError {
315
+ constructor(message: string, options?: ConstructorParameters<typeof PulseIndexError>[1]);
316
+ }
317
+ declare class PulseIndexAuthError extends PulseIndexError {
318
+ constructor(message: string, options?: ConstructorParameters<typeof PulseIndexError>[1]);
319
+ }
320
+ declare class PulseIndexQueryError extends PulseIndexError {
321
+ constructor(message: string, options?: ConstructorParameters<typeof PulseIndexError>[1]);
322
+ }
323
+
324
+ export { type BatchEntityInput, type BatchIndexResponse, ConnectionManager, type DeleteResponse, type EncodedEntity, type EntityAttributes, type EntityId, type EntityInput, FilterOperation, type FilterPredicate, GeoHash, type IndexEntityRequest, type IndexEntityResponse, PulseIndex, PulseIndexAuthError, PulseIndexClient, type PulseIndexClientConfig, PulseIndexConnectionError, PulseIndexError, PulseIndexQueryError, QueryBuilder, type RadiusOptions, type RangePredicate, SERVING_STATUS, type SearchQueryRequest, type SearchRequestOptions, type SearchResponse, PulseIndex as default, encodeEntity, sslEnabled, toUint64String };
@@ -0,0 +1,324 @@
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import { ServiceError } from '@grpc/grpc-js';
3
+
4
+ declare const FilterOperation: {
5
+ readonly MUST: 0;
6
+ readonly SHOULD: 1;
7
+ readonly MUST_NOT: 2;
8
+ };
9
+ type FilterOperationCode = (typeof FilterOperation)[keyof typeof FilterOperation];
10
+ type EntityId = string | number | bigint;
11
+ interface FilterPredicate {
12
+ op: FilterOperationCode;
13
+ attribute: string;
14
+ }
15
+ interface RangePredicate {
16
+ field: string;
17
+ minVal: number;
18
+ maxVal: number;
19
+ }
20
+ interface SearchQueryRequest {
21
+ locationPrefix: string;
22
+ filters: FilterPredicate[];
23
+ ranges: RangePredicate[];
24
+ limit: number;
25
+ offset: number;
26
+ tenantId: string;
27
+ }
28
+ interface SearchResponse {
29
+ matchedEntityIds: string[];
30
+ totalMatches: number;
31
+ executionTimeUs: number;
32
+ }
33
+ interface IndexEntityRequest {
34
+ entityId: string;
35
+ locationPrefix: string;
36
+ price: number;
37
+ categories: string[];
38
+ tenantId: string;
39
+ }
40
+ interface IndexEntityResponse {
41
+ success: boolean;
42
+ }
43
+ interface BatchIndexResponse {
44
+ indexedCount: number;
45
+ }
46
+ interface DeleteResponse {
47
+ success: boolean;
48
+ }
49
+ interface RadiusOptions {
50
+ lat: number;
51
+ lng?: number;
52
+ lon?: number;
53
+ radiusKm: number;
54
+ precision?: number;
55
+ }
56
+ interface SearchRequestOptions {
57
+ tenantId?: string;
58
+ locationPrefix?: EntityId;
59
+ must?: string | string[];
60
+ should?: string | string[];
61
+ mustNot?: string | string[];
62
+ ranges?: Array<{
63
+ field: string;
64
+ min: number;
65
+ max: number;
66
+ }>;
67
+ limit?: number;
68
+ offset?: number;
69
+ withinRadius?: RadiusOptions;
70
+ geoHash?: string;
71
+ }
72
+ interface EntityAttributes {
73
+ categories?: unknown;
74
+ tags?: unknown;
75
+ price?: unknown;
76
+ locationPrefix?: unknown;
77
+ location_prefix?: unknown;
78
+ tenantId?: unknown;
79
+ tenant_id?: unknown;
80
+ latitude?: unknown;
81
+ longitude?: unknown;
82
+ lat?: unknown;
83
+ lng?: unknown;
84
+ lon?: unknown;
85
+ [key: string]: unknown;
86
+ }
87
+ interface EntityInput {
88
+ id?: EntityId;
89
+ entityId?: EntityId;
90
+ entity_id?: EntityId;
91
+ attributes?: EntityAttributes;
92
+ categories?: unknown;
93
+ tags?: unknown;
94
+ price?: unknown;
95
+ locationPrefix?: unknown;
96
+ location_prefix?: unknown;
97
+ tenantId?: unknown;
98
+ tenant_id?: unknown;
99
+ latitude?: unknown;
100
+ longitude?: unknown;
101
+ lat?: unknown;
102
+ lng?: unknown;
103
+ lon?: unknown;
104
+ [key: string]: unknown;
105
+ }
106
+ interface BatchEntityInput {
107
+ id?: EntityId;
108
+ entityId?: EntityId;
109
+ entity_id?: EntityId;
110
+ attributes?: EntityAttributes;
111
+ [key: string]: unknown;
112
+ }
113
+ interface EncodedEntity {
114
+ entityId: string;
115
+ categories: string[];
116
+ price: number;
117
+ locationPrefix: string;
118
+ tenantId: string;
119
+ }
120
+ interface PulseIndexClientConfig {
121
+ endpoint?: string;
122
+ host?: string;
123
+ apiKey?: string;
124
+ authorization?: string;
125
+ tenantId?: string;
126
+ timeoutMs?: number;
127
+ ssl?: boolean | string | number;
128
+ rootCerts?: Buffer;
129
+ privateKey?: Buffer;
130
+ certChain?: Buffer;
131
+ protoPath?: string;
132
+ /** Override the bundled `health.proto`. Only needed if the package layout is rewritten. */
133
+ healthProtoPath?: string;
134
+ poolSize?: number;
135
+ channelOptions?: Record<string, unknown>;
136
+ }
137
+
138
+ interface QueryExecutor {
139
+ search(query: QueryBuilder): Promise<SearchResponse>;
140
+ }
141
+ declare class QueryBuilder {
142
+ private readonly executor;
143
+ private state;
144
+ constructor(executor?: QueryExecutor | null);
145
+ tenant(tenantId: string): QueryBuilder;
146
+ location(locationPrefix: string | number | bigint): QueryBuilder;
147
+ must(attribute: string | string[]): QueryBuilder;
148
+ should(attribute: string | string[]): QueryBuilder;
149
+ mustNot(attribute: string | string[]): QueryBuilder;
150
+ whereGeoHash(geohash: string): QueryBuilder;
151
+ inGeoHash(geohash: string): QueryBuilder;
152
+ withinRadius(lat: number, lon: number, radiusKm: number, precision?: number): QueryBuilder;
153
+ withinRadius(options: RadiusOptions): QueryBuilder;
154
+ range(field: string, min: number, max: number): QueryBuilder;
155
+ limit(limit: number): QueryBuilder;
156
+ offset(offset: number): QueryBuilder;
157
+ toRequest(defaultTenantId?: string): SearchQueryRequest;
158
+ toArray(defaultTenantId?: string): SearchQueryRequest;
159
+ execute(): Promise<SearchResponse>;
160
+ static fromOptions(options: SearchRequestOptions, executor?: QueryExecutor | null): QueryBuilder;
161
+ private addFilters;
162
+ private fork;
163
+ }
164
+
165
+ interface SearchEngineServiceClient extends grpc.Client {
166
+ indexEntity(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
167
+ batchIndexEntities(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
168
+ deleteEntity(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
169
+ search(request: unknown, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<unknown>): grpc.ClientUnaryCall;
170
+ }
171
+ /** `grpc.health.v1.Health` — the readiness check that needs no scope. */
172
+ interface HealthClient extends grpc.Client {
173
+ check(request: {
174
+ service: string;
175
+ }, metadata: grpc.Metadata, options: grpc.CallOptions, callback: grpc.requestCallback<{
176
+ status?: number;
177
+ }>): grpc.ClientUnaryCall;
178
+ }
179
+ /** Values of `grpc.health.v1.HealthCheckResponse.ServingStatus`. */
180
+ declare const SERVING_STATUS: {
181
+ readonly UNKNOWN: 0;
182
+ readonly SERVING: 1;
183
+ readonly NOT_SERVING: 2;
184
+ readonly SERVICE_UNKNOWN: 3;
185
+ };
186
+
187
+ declare function sslEnabled(config: PulseIndexClientConfig): boolean;
188
+ declare class ConnectionManager {
189
+ readonly endpoint: string;
190
+ readonly tenantId: string;
191
+ readonly timeoutMs: number;
192
+ readonly ssl: boolean;
193
+ private readonly apiKey?;
194
+ private readonly authorization?;
195
+ private readonly clients;
196
+ private cursor;
197
+ private closed;
198
+ private readonly credentials;
199
+ private readonly channelOptions;
200
+ private readonly healthProtoPath?;
201
+ private healthStub?;
202
+ constructor(config?: PulseIndexClientConfig);
203
+ /**
204
+ * `grpc.health.v1.Health` stub, created on first use.
205
+ *
206
+ * A separate service from the query API, and unauthenticated: the health
207
+ * protocol needs no scope, so it works with any key or none.
208
+ */
209
+ getHealthStub(): HealthClient;
210
+ getStub(): SearchEngineServiceClient;
211
+ createMetadata(): grpc.Metadata;
212
+ createCallOptions(): grpc.CallOptions;
213
+ waitForReady(timeoutMs?: number): Promise<void>;
214
+ close(): void;
215
+ private assertOpen;
216
+ private createCredentials;
217
+ }
218
+
219
+ declare class PulseIndexClient implements QueryExecutor {
220
+ readonly connection: ConnectionManager;
221
+ constructor(config?: PulseIndexClientConfig);
222
+ static create(endpoint: string, apiKey?: string, ssl?: boolean, extra?: Omit<PulseIndexClientConfig, 'endpoint' | 'apiKey' | 'ssl'>): PulseIndexClient;
223
+ static query(): QueryBuilder;
224
+ query(): QueryBuilder;
225
+ search(query: QueryBuilder | SearchRequestOptions): Promise<SearchResponse>;
226
+ index(entityIdOrInput: EntityId | EntityInput, attributes?: EntityAttributes): Promise<IndexEntityResponse>;
227
+ indexEntity(entityId: EntityId, categories?: string[], price?: number, locationPrefix?: EntityId, tenantId?: string): Promise<boolean>;
228
+ batchIndex(entities: Array<EntityInput | BatchEntityInput>): Promise<BatchIndexResponse>;
229
+ delete(entityId: EntityId, tenantId?: string): Promise<DeleteResponse>;
230
+ deleteEntity(entityId: EntityId, tenantId?: string): Promise<boolean>;
231
+ /**
232
+ * True only when the engine can serve reads.
233
+ *
234
+ * Asks `grpc.health.v1.Health`, which needs no particular scope and tracks
235
+ * whether the service can currently answer queries. So this distinguishes a
236
+ * reachable-but-unavailable service from a healthy one.
237
+ *
238
+ * Returns `false` rather than throwing, so unreachable and unavailable look
239
+ * the same here. Use {@link servingStatus} to tell them apart.
240
+ */
241
+ health(): Promise<boolean>;
242
+ /**
243
+ * Raw `grpc.health.v1` serving status for a service name.
244
+ *
245
+ * Defaults to `''`, the overall-server key defined by the health spec. The
246
+ * service answers for both that and its named service.
247
+ */
248
+ servingStatus(service?: string): Promise<number>;
249
+ close(): void;
250
+ private unary;
251
+ }
252
+ declare class PulseIndex extends PulseIndexClient {
253
+ }
254
+
255
+ declare class GeoHash {
256
+ static readonly TAG_PREFIX = "geo:";
257
+ static readonly MIN_PRECISION = 1;
258
+ static readonly MAX_PRECISION = 12;
259
+ static readonly INDEX_PRECISIONS: readonly [5, 6];
260
+ private static readonly BASE32;
261
+ private static readonly EARTH_RADIUS_KM;
262
+ private static readonly MAX_COVERING_CELLS;
263
+ private static readonly NEIGHBORS;
264
+ private static readonly BORDERS;
265
+ static encode(lat: number, lon: number, precision?: number): string;
266
+ static decode(hash: string): {
267
+ lat: number;
268
+ lon: number;
269
+ };
270
+ static decodeBounds(hash: string): {
271
+ latMin: number;
272
+ latMax: number;
273
+ lonMin: number;
274
+ lonMax: number;
275
+ };
276
+ static neighbor(hash: string, direction: string): string;
277
+ static neighbors(hash: string): string[];
278
+ static neighborhood3x3(hash: string): string[];
279
+ static neighborhoodTags(lat: number, lon: number, precision?: number): string[];
280
+ static optimalPrecisionForRadius(radiusKm: number): number;
281
+ static precisionForRadius(radiusKm: number): number;
282
+ static getCoveringHashes(lat: number, lon: number, radiusKm: number, precision?: number): string[];
283
+ static tag(geohash: string): string;
284
+ static encodeTag(lat: number, lon: number, precision?: number): string;
285
+ static encodeMultiTags(lat: number, lon: number): string[];
286
+ static haversineKm(lat1: number, lon1: number, lat2: number, lon2: number): number;
287
+ private static cellIntersectsCircle;
288
+ private static adjacent;
289
+ private static normalizeHash;
290
+ private static assertLatitude;
291
+ private static assertLongitude;
292
+ private static assertPrecision;
293
+ private static isCardinal;
294
+ private static toRadians;
295
+ }
296
+
297
+ declare function toUint64String(value: EntityId, field?: string): string;
298
+ declare function encodeEntity(entityIdOrInput: EntityId | EntityInput, attributes?: EntityAttributes, defaults?: {
299
+ tenantId?: string;
300
+ }): EncodedEntity;
301
+
302
+ declare class PulseIndexError extends Error {
303
+ readonly code: string;
304
+ readonly grpcStatusCode?: number;
305
+ readonly grpcDetails?: string;
306
+ constructor(message: string, options?: {
307
+ code?: string;
308
+ grpcStatusCode?: number;
309
+ grpcDetails?: string;
310
+ cause?: unknown;
311
+ });
312
+ static fromGrpc(error: ServiceError | Error): PulseIndexError;
313
+ }
314
+ declare class PulseIndexConnectionError extends PulseIndexError {
315
+ constructor(message: string, options?: ConstructorParameters<typeof PulseIndexError>[1]);
316
+ }
317
+ declare class PulseIndexAuthError extends PulseIndexError {
318
+ constructor(message: string, options?: ConstructorParameters<typeof PulseIndexError>[1]);
319
+ }
320
+ declare class PulseIndexQueryError extends PulseIndexError {
321
+ constructor(message: string, options?: ConstructorParameters<typeof PulseIndexError>[1]);
322
+ }
323
+
324
+ export { type BatchEntityInput, type BatchIndexResponse, ConnectionManager, type DeleteResponse, type EncodedEntity, type EntityAttributes, type EntityId, type EntityInput, FilterOperation, type FilterPredicate, GeoHash, type IndexEntityRequest, type IndexEntityResponse, PulseIndex, PulseIndexAuthError, PulseIndexClient, type PulseIndexClientConfig, PulseIndexConnectionError, PulseIndexError, PulseIndexQueryError, QueryBuilder, type RadiusOptions, type RangePredicate, SERVING_STATUS, type SearchQueryRequest, type SearchRequestOptions, type SearchResponse, PulseIndex as default, encodeEntity, sslEnabled, toUint64String };