@autolink/sdk 0.2.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/index.cjs +466 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +304 -0
- package/dist/index.d.ts +304 -0
- package/dist/index.js +426 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
interface RetryConfig {
|
|
2
|
+
attempts: number;
|
|
3
|
+
backoff: "exponential" | "linear";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface FetcherConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
timeout: number;
|
|
9
|
+
retry: RetryConfig;
|
|
10
|
+
debug: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface GatewayPagination {
|
|
14
|
+
total: number;
|
|
15
|
+
page: number;
|
|
16
|
+
page_size: number;
|
|
17
|
+
pages: number;
|
|
18
|
+
}
|
|
19
|
+
interface GatewayMeta {
|
|
20
|
+
request_id: string;
|
|
21
|
+
pagination?: GatewayPagination;
|
|
22
|
+
}
|
|
23
|
+
interface GatewayEnvelope<T> {
|
|
24
|
+
data: T;
|
|
25
|
+
meta: GatewayMeta;
|
|
26
|
+
}
|
|
27
|
+
type StockStatus = "available" | "reserved" | "sold" | "in_transit";
|
|
28
|
+
type VehicleCondition = "new" | "locally_used" | "foreign_used";
|
|
29
|
+
/** @deprecated Use cover_image / cover_image_variants instead */
|
|
30
|
+
interface VehiclePhoto {
|
|
31
|
+
url: string;
|
|
32
|
+
is_primary: boolean;
|
|
33
|
+
caption?: string;
|
|
34
|
+
}
|
|
35
|
+
interface CoverImageVariants {
|
|
36
|
+
thumb: string;
|
|
37
|
+
medium: string;
|
|
38
|
+
large: string;
|
|
39
|
+
master: string;
|
|
40
|
+
}
|
|
41
|
+
interface VehicleDealer {
|
|
42
|
+
name: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
logo?: string;
|
|
45
|
+
city?: string;
|
|
46
|
+
whatsapp_number?: string;
|
|
47
|
+
public_url?: string;
|
|
48
|
+
}
|
|
49
|
+
interface AutolinkVehicle {
|
|
50
|
+
/** UUID — internal identifier */
|
|
51
|
+
id: string;
|
|
52
|
+
/** URL-safe slug — use this for routes and API calls */
|
|
53
|
+
slug: string;
|
|
54
|
+
title: string;
|
|
55
|
+
make: string;
|
|
56
|
+
make_id?: string;
|
|
57
|
+
model: string;
|
|
58
|
+
model_id?: string;
|
|
59
|
+
year: number;
|
|
60
|
+
body_type: string;
|
|
61
|
+
body_type_display?: string;
|
|
62
|
+
colour?: string;
|
|
63
|
+
condition: VehicleCondition;
|
|
64
|
+
mileage_km?: number;
|
|
65
|
+
engine_size?: number;
|
|
66
|
+
fuel_type?: string;
|
|
67
|
+
fuel_type_display?: string;
|
|
68
|
+
transmission?: string;
|
|
69
|
+
transmission_display?: string;
|
|
70
|
+
drive_type?: string;
|
|
71
|
+
price_kes: number;
|
|
72
|
+
is_negotiable?: boolean;
|
|
73
|
+
has_discount?: boolean;
|
|
74
|
+
active_discount_price_kes?: number | null;
|
|
75
|
+
location?: string;
|
|
76
|
+
stock_status: StockStatus;
|
|
77
|
+
stock_status_display?: string;
|
|
78
|
+
is_featured?: boolean;
|
|
79
|
+
description?: string;
|
|
80
|
+
features?: string[];
|
|
81
|
+
/** Primary image URL */
|
|
82
|
+
cover_image?: string;
|
|
83
|
+
cover_image_variants?: CoverImageVariants;
|
|
84
|
+
/** @deprecated Use cover_image instead */
|
|
85
|
+
photos?: VehiclePhoto[];
|
|
86
|
+
listing_status?: "published";
|
|
87
|
+
published_at: string;
|
|
88
|
+
dealer?: VehicleDealer;
|
|
89
|
+
salesperson?: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface InventoryListFilters {
|
|
92
|
+
make?: string;
|
|
93
|
+
model?: string;
|
|
94
|
+
year?: number;
|
|
95
|
+
min_year?: number;
|
|
96
|
+
max_year?: number;
|
|
97
|
+
condition?: VehicleCondition;
|
|
98
|
+
stock_status?: StockStatus;
|
|
99
|
+
min_price?: number;
|
|
100
|
+
max_price?: number;
|
|
101
|
+
min_mileage?: number;
|
|
102
|
+
max_mileage?: number;
|
|
103
|
+
transmission?: string;
|
|
104
|
+
fuel_type?: string;
|
|
105
|
+
body_type?: string;
|
|
106
|
+
search?: string;
|
|
107
|
+
ordering?: string;
|
|
108
|
+
page?: number;
|
|
109
|
+
page_size?: number;
|
|
110
|
+
feature_ids?: string;
|
|
111
|
+
}
|
|
112
|
+
interface FilterOptions {
|
|
113
|
+
makes: string[];
|
|
114
|
+
models: string[];
|
|
115
|
+
years: number[];
|
|
116
|
+
conditions: string[];
|
|
117
|
+
transmissions: string[];
|
|
118
|
+
fuel_types: string[];
|
|
119
|
+
body_types: string[];
|
|
120
|
+
stock_statuses?: string[];
|
|
121
|
+
colours?: string[];
|
|
122
|
+
price_range: {
|
|
123
|
+
min: number;
|
|
124
|
+
max: number;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface AutolinkInquiryPayload {
|
|
128
|
+
type: "vehicle" | "general";
|
|
129
|
+
customer_name: string;
|
|
130
|
+
customer_email: string;
|
|
131
|
+
customer_phone?: string;
|
|
132
|
+
subject?: string;
|
|
133
|
+
message: string;
|
|
134
|
+
vehicle_slug?: string;
|
|
135
|
+
}
|
|
136
|
+
interface AutolinkInquiry {
|
|
137
|
+
id: string;
|
|
138
|
+
type: string;
|
|
139
|
+
customer_name: string;
|
|
140
|
+
customer_email: string;
|
|
141
|
+
message: string;
|
|
142
|
+
vehicle_slug?: string;
|
|
143
|
+
lead_id?: string;
|
|
144
|
+
test_mode: boolean;
|
|
145
|
+
created_at: string;
|
|
146
|
+
}
|
|
147
|
+
interface AutolinkProfile {
|
|
148
|
+
name: string;
|
|
149
|
+
slug: string;
|
|
150
|
+
tagline?: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
phone?: string;
|
|
153
|
+
email?: string;
|
|
154
|
+
address?: string;
|
|
155
|
+
city?: string;
|
|
156
|
+
country?: string;
|
|
157
|
+
logo_url?: string;
|
|
158
|
+
cover_url?: string;
|
|
159
|
+
is_publicly_visible: boolean;
|
|
160
|
+
}
|
|
161
|
+
interface ArticleListFilters {
|
|
162
|
+
page?: number;
|
|
163
|
+
page_size?: number;
|
|
164
|
+
search?: string;
|
|
165
|
+
ordering?: string;
|
|
166
|
+
}
|
|
167
|
+
interface AutolinkArticle {
|
|
168
|
+
slug: string;
|
|
169
|
+
title: string;
|
|
170
|
+
excerpt?: string;
|
|
171
|
+
/** Raw HTML from the CMS — sanitize before rendering */
|
|
172
|
+
body: string;
|
|
173
|
+
cover_image_url?: string;
|
|
174
|
+
status: "published";
|
|
175
|
+
published_at: string;
|
|
176
|
+
author?: string;
|
|
177
|
+
}
|
|
178
|
+
interface IntegrationStatus {
|
|
179
|
+
ok: boolean;
|
|
180
|
+
environment: "test" | "live";
|
|
181
|
+
tenant: {
|
|
182
|
+
slug: string;
|
|
183
|
+
name: string;
|
|
184
|
+
};
|
|
185
|
+
scopes: string[];
|
|
186
|
+
api_version: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface AutolinkCache {
|
|
190
|
+
get(key: string): Promise<unknown> | unknown;
|
|
191
|
+
set(key: string, value: unknown, ttlSeconds?: number): Promise<void> | void;
|
|
192
|
+
delete(key: string): Promise<void> | void;
|
|
193
|
+
}
|
|
194
|
+
declare class MemoryCache implements AutolinkCache {
|
|
195
|
+
private store;
|
|
196
|
+
get(key: string): unknown;
|
|
197
|
+
set(key: string, value: unknown, ttlSeconds?: number): void;
|
|
198
|
+
delete(key: string): void;
|
|
199
|
+
/** Remove all expired entries. Optional maintenance call. */
|
|
200
|
+
purgeExpired(): void;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
declare class InventoryResource {
|
|
204
|
+
private config;
|
|
205
|
+
private cache?;
|
|
206
|
+
constructor(config: FetcherConfig, cache?: AutolinkCache | undefined);
|
|
207
|
+
list(filters?: InventoryListFilters, options?: {
|
|
208
|
+
ttl?: number;
|
|
209
|
+
}): Promise<GatewayEnvelope<AutolinkVehicle[]>>;
|
|
210
|
+
get(slug: string, options?: {
|
|
211
|
+
ttl?: number;
|
|
212
|
+
}): Promise<GatewayEnvelope<AutolinkVehicle>>;
|
|
213
|
+
filterOptions(options?: {
|
|
214
|
+
ttl?: number;
|
|
215
|
+
}): Promise<GatewayEnvelope<FilterOptions>>;
|
|
216
|
+
pages(filters?: Omit<InventoryListFilters, "page">): AsyncGenerator<GatewayEnvelope<AutolinkVehicle[]>>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface InquiryCreateOptions {
|
|
220
|
+
idempotencyKey?: string;
|
|
221
|
+
}
|
|
222
|
+
declare class InquiriesResource {
|
|
223
|
+
private config;
|
|
224
|
+
constructor(config: FetcherConfig);
|
|
225
|
+
create(payload: AutolinkInquiryPayload, options?: InquiryCreateOptions): Promise<GatewayEnvelope<AutolinkInquiry>>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare class ProfileResource {
|
|
229
|
+
private config;
|
|
230
|
+
constructor(config: FetcherConfig);
|
|
231
|
+
get(): Promise<GatewayEnvelope<AutolinkProfile>>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare class ArticlesResource {
|
|
235
|
+
private config;
|
|
236
|
+
private cache?;
|
|
237
|
+
constructor(config: FetcherConfig, cache?: AutolinkCache | undefined);
|
|
238
|
+
list(filters?: ArticleListFilters, options?: {
|
|
239
|
+
ttl?: number;
|
|
240
|
+
}): Promise<GatewayEnvelope<AutolinkArticle[]>>;
|
|
241
|
+
get(slug: string, options?: {
|
|
242
|
+
ttl?: number;
|
|
243
|
+
}): Promise<GatewayEnvelope<AutolinkArticle>>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare class IntegrationResource {
|
|
247
|
+
private config;
|
|
248
|
+
constructor(config: FetcherConfig);
|
|
249
|
+
check(): Promise<GatewayEnvelope<IntegrationStatus>>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface AutolinkClientConfig {
|
|
253
|
+
apiKey: string;
|
|
254
|
+
timeout?: number;
|
|
255
|
+
retry?: Partial<RetryConfig>;
|
|
256
|
+
debug?: boolean;
|
|
257
|
+
cache?: AutolinkCache;
|
|
258
|
+
}
|
|
259
|
+
declare class AutolinkClient {
|
|
260
|
+
readonly inventory: InventoryResource;
|
|
261
|
+
readonly inquiries: InquiriesResource;
|
|
262
|
+
readonly profile: ProfileResource;
|
|
263
|
+
readonly articles: ArticlesResource;
|
|
264
|
+
readonly integration: IntegrationResource;
|
|
265
|
+
constructor(config: AutolinkClientConfig);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
declare class AutolinkError extends Error {
|
|
269
|
+
readonly requestId: string;
|
|
270
|
+
readonly code: string;
|
|
271
|
+
constructor(message: string, code: string, requestId: string);
|
|
272
|
+
}
|
|
273
|
+
declare class AutolinkAuthError extends AutolinkError {
|
|
274
|
+
constructor(message: string, requestId: string);
|
|
275
|
+
}
|
|
276
|
+
declare class AutolinkForbiddenError extends AutolinkError {
|
|
277
|
+
constructor(message: string, requestId: string);
|
|
278
|
+
}
|
|
279
|
+
declare class AutolinkNotFoundError extends AutolinkError {
|
|
280
|
+
constructor(message: string, requestId: string);
|
|
281
|
+
}
|
|
282
|
+
declare class AutolinkValidationError extends AutolinkError {
|
|
283
|
+
readonly fields: Record<string, string[]>;
|
|
284
|
+
constructor(message: string, requestId: string, fields?: Record<string, string[]>);
|
|
285
|
+
}
|
|
286
|
+
declare class AutolinkRateLimitError extends AutolinkError {
|
|
287
|
+
readonly retryAfter: number;
|
|
288
|
+
constructor(message: string, requestId: string, retryAfter: number);
|
|
289
|
+
}
|
|
290
|
+
declare class AutolinkNetworkError extends AutolinkError {
|
|
291
|
+
readonly cause: Error;
|
|
292
|
+
constructor(message: string, cause: Error);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare const GATEWAY_BASE_URL = "https://gateway.autolink.ke";
|
|
296
|
+
declare const GATEWAY_URL = "https://gateway.autolink.ke/sdk/v1";
|
|
297
|
+
declare const SDK_VERSION = "0.1.0";
|
|
298
|
+
|
|
299
|
+
/** Unwraps a GatewayEnvelope and returns the data directly */
|
|
300
|
+
declare function unwrap<T>(envelope: GatewayEnvelope<T>): T;
|
|
301
|
+
/** Returns field-level validation errors for a given field name */
|
|
302
|
+
declare function getFieldErrors(error: AutolinkValidationError, field: string): string[];
|
|
303
|
+
|
|
304
|
+
export { type ArticleListFilters, type AutolinkArticle, AutolinkAuthError, type AutolinkCache, AutolinkClient, type AutolinkClientConfig, AutolinkError, AutolinkForbiddenError, type AutolinkInquiry, type AutolinkInquiryPayload, AutolinkNetworkError, AutolinkNotFoundError, type AutolinkProfile, AutolinkRateLimitError, AutolinkValidationError, type AutolinkVehicle, type CoverImageVariants, type FilterOptions, GATEWAY_BASE_URL, GATEWAY_URL, type GatewayEnvelope, type GatewayMeta, type GatewayPagination, type IntegrationStatus, type InventoryListFilters, MemoryCache, SDK_VERSION, type StockStatus, type VehicleCondition, type VehicleDealer, type VehiclePhoto, getFieldErrors, unwrap };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
interface RetryConfig {
|
|
2
|
+
attempts: number;
|
|
3
|
+
backoff: "exponential" | "linear";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface FetcherConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
timeout: number;
|
|
9
|
+
retry: RetryConfig;
|
|
10
|
+
debug: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface GatewayPagination {
|
|
14
|
+
total: number;
|
|
15
|
+
page: number;
|
|
16
|
+
page_size: number;
|
|
17
|
+
pages: number;
|
|
18
|
+
}
|
|
19
|
+
interface GatewayMeta {
|
|
20
|
+
request_id: string;
|
|
21
|
+
pagination?: GatewayPagination;
|
|
22
|
+
}
|
|
23
|
+
interface GatewayEnvelope<T> {
|
|
24
|
+
data: T;
|
|
25
|
+
meta: GatewayMeta;
|
|
26
|
+
}
|
|
27
|
+
type StockStatus = "available" | "reserved" | "sold" | "in_transit";
|
|
28
|
+
type VehicleCondition = "new" | "locally_used" | "foreign_used";
|
|
29
|
+
/** @deprecated Use cover_image / cover_image_variants instead */
|
|
30
|
+
interface VehiclePhoto {
|
|
31
|
+
url: string;
|
|
32
|
+
is_primary: boolean;
|
|
33
|
+
caption?: string;
|
|
34
|
+
}
|
|
35
|
+
interface CoverImageVariants {
|
|
36
|
+
thumb: string;
|
|
37
|
+
medium: string;
|
|
38
|
+
large: string;
|
|
39
|
+
master: string;
|
|
40
|
+
}
|
|
41
|
+
interface VehicleDealer {
|
|
42
|
+
name: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
logo?: string;
|
|
45
|
+
city?: string;
|
|
46
|
+
whatsapp_number?: string;
|
|
47
|
+
public_url?: string;
|
|
48
|
+
}
|
|
49
|
+
interface AutolinkVehicle {
|
|
50
|
+
/** UUID — internal identifier */
|
|
51
|
+
id: string;
|
|
52
|
+
/** URL-safe slug — use this for routes and API calls */
|
|
53
|
+
slug: string;
|
|
54
|
+
title: string;
|
|
55
|
+
make: string;
|
|
56
|
+
make_id?: string;
|
|
57
|
+
model: string;
|
|
58
|
+
model_id?: string;
|
|
59
|
+
year: number;
|
|
60
|
+
body_type: string;
|
|
61
|
+
body_type_display?: string;
|
|
62
|
+
colour?: string;
|
|
63
|
+
condition: VehicleCondition;
|
|
64
|
+
mileage_km?: number;
|
|
65
|
+
engine_size?: number;
|
|
66
|
+
fuel_type?: string;
|
|
67
|
+
fuel_type_display?: string;
|
|
68
|
+
transmission?: string;
|
|
69
|
+
transmission_display?: string;
|
|
70
|
+
drive_type?: string;
|
|
71
|
+
price_kes: number;
|
|
72
|
+
is_negotiable?: boolean;
|
|
73
|
+
has_discount?: boolean;
|
|
74
|
+
active_discount_price_kes?: number | null;
|
|
75
|
+
location?: string;
|
|
76
|
+
stock_status: StockStatus;
|
|
77
|
+
stock_status_display?: string;
|
|
78
|
+
is_featured?: boolean;
|
|
79
|
+
description?: string;
|
|
80
|
+
features?: string[];
|
|
81
|
+
/** Primary image URL */
|
|
82
|
+
cover_image?: string;
|
|
83
|
+
cover_image_variants?: CoverImageVariants;
|
|
84
|
+
/** @deprecated Use cover_image instead */
|
|
85
|
+
photos?: VehiclePhoto[];
|
|
86
|
+
listing_status?: "published";
|
|
87
|
+
published_at: string;
|
|
88
|
+
dealer?: VehicleDealer;
|
|
89
|
+
salesperson?: unknown;
|
|
90
|
+
}
|
|
91
|
+
interface InventoryListFilters {
|
|
92
|
+
make?: string;
|
|
93
|
+
model?: string;
|
|
94
|
+
year?: number;
|
|
95
|
+
min_year?: number;
|
|
96
|
+
max_year?: number;
|
|
97
|
+
condition?: VehicleCondition;
|
|
98
|
+
stock_status?: StockStatus;
|
|
99
|
+
min_price?: number;
|
|
100
|
+
max_price?: number;
|
|
101
|
+
min_mileage?: number;
|
|
102
|
+
max_mileage?: number;
|
|
103
|
+
transmission?: string;
|
|
104
|
+
fuel_type?: string;
|
|
105
|
+
body_type?: string;
|
|
106
|
+
search?: string;
|
|
107
|
+
ordering?: string;
|
|
108
|
+
page?: number;
|
|
109
|
+
page_size?: number;
|
|
110
|
+
feature_ids?: string;
|
|
111
|
+
}
|
|
112
|
+
interface FilterOptions {
|
|
113
|
+
makes: string[];
|
|
114
|
+
models: string[];
|
|
115
|
+
years: number[];
|
|
116
|
+
conditions: string[];
|
|
117
|
+
transmissions: string[];
|
|
118
|
+
fuel_types: string[];
|
|
119
|
+
body_types: string[];
|
|
120
|
+
stock_statuses?: string[];
|
|
121
|
+
colours?: string[];
|
|
122
|
+
price_range: {
|
|
123
|
+
min: number;
|
|
124
|
+
max: number;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface AutolinkInquiryPayload {
|
|
128
|
+
type: "vehicle" | "general";
|
|
129
|
+
customer_name: string;
|
|
130
|
+
customer_email: string;
|
|
131
|
+
customer_phone?: string;
|
|
132
|
+
subject?: string;
|
|
133
|
+
message: string;
|
|
134
|
+
vehicle_slug?: string;
|
|
135
|
+
}
|
|
136
|
+
interface AutolinkInquiry {
|
|
137
|
+
id: string;
|
|
138
|
+
type: string;
|
|
139
|
+
customer_name: string;
|
|
140
|
+
customer_email: string;
|
|
141
|
+
message: string;
|
|
142
|
+
vehicle_slug?: string;
|
|
143
|
+
lead_id?: string;
|
|
144
|
+
test_mode: boolean;
|
|
145
|
+
created_at: string;
|
|
146
|
+
}
|
|
147
|
+
interface AutolinkProfile {
|
|
148
|
+
name: string;
|
|
149
|
+
slug: string;
|
|
150
|
+
tagline?: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
phone?: string;
|
|
153
|
+
email?: string;
|
|
154
|
+
address?: string;
|
|
155
|
+
city?: string;
|
|
156
|
+
country?: string;
|
|
157
|
+
logo_url?: string;
|
|
158
|
+
cover_url?: string;
|
|
159
|
+
is_publicly_visible: boolean;
|
|
160
|
+
}
|
|
161
|
+
interface ArticleListFilters {
|
|
162
|
+
page?: number;
|
|
163
|
+
page_size?: number;
|
|
164
|
+
search?: string;
|
|
165
|
+
ordering?: string;
|
|
166
|
+
}
|
|
167
|
+
interface AutolinkArticle {
|
|
168
|
+
slug: string;
|
|
169
|
+
title: string;
|
|
170
|
+
excerpt?: string;
|
|
171
|
+
/** Raw HTML from the CMS — sanitize before rendering */
|
|
172
|
+
body: string;
|
|
173
|
+
cover_image_url?: string;
|
|
174
|
+
status: "published";
|
|
175
|
+
published_at: string;
|
|
176
|
+
author?: string;
|
|
177
|
+
}
|
|
178
|
+
interface IntegrationStatus {
|
|
179
|
+
ok: boolean;
|
|
180
|
+
environment: "test" | "live";
|
|
181
|
+
tenant: {
|
|
182
|
+
slug: string;
|
|
183
|
+
name: string;
|
|
184
|
+
};
|
|
185
|
+
scopes: string[];
|
|
186
|
+
api_version: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface AutolinkCache {
|
|
190
|
+
get(key: string): Promise<unknown> | unknown;
|
|
191
|
+
set(key: string, value: unknown, ttlSeconds?: number): Promise<void> | void;
|
|
192
|
+
delete(key: string): Promise<void> | void;
|
|
193
|
+
}
|
|
194
|
+
declare class MemoryCache implements AutolinkCache {
|
|
195
|
+
private store;
|
|
196
|
+
get(key: string): unknown;
|
|
197
|
+
set(key: string, value: unknown, ttlSeconds?: number): void;
|
|
198
|
+
delete(key: string): void;
|
|
199
|
+
/** Remove all expired entries. Optional maintenance call. */
|
|
200
|
+
purgeExpired(): void;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
declare class InventoryResource {
|
|
204
|
+
private config;
|
|
205
|
+
private cache?;
|
|
206
|
+
constructor(config: FetcherConfig, cache?: AutolinkCache | undefined);
|
|
207
|
+
list(filters?: InventoryListFilters, options?: {
|
|
208
|
+
ttl?: number;
|
|
209
|
+
}): Promise<GatewayEnvelope<AutolinkVehicle[]>>;
|
|
210
|
+
get(slug: string, options?: {
|
|
211
|
+
ttl?: number;
|
|
212
|
+
}): Promise<GatewayEnvelope<AutolinkVehicle>>;
|
|
213
|
+
filterOptions(options?: {
|
|
214
|
+
ttl?: number;
|
|
215
|
+
}): Promise<GatewayEnvelope<FilterOptions>>;
|
|
216
|
+
pages(filters?: Omit<InventoryListFilters, "page">): AsyncGenerator<GatewayEnvelope<AutolinkVehicle[]>>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
interface InquiryCreateOptions {
|
|
220
|
+
idempotencyKey?: string;
|
|
221
|
+
}
|
|
222
|
+
declare class InquiriesResource {
|
|
223
|
+
private config;
|
|
224
|
+
constructor(config: FetcherConfig);
|
|
225
|
+
create(payload: AutolinkInquiryPayload, options?: InquiryCreateOptions): Promise<GatewayEnvelope<AutolinkInquiry>>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare class ProfileResource {
|
|
229
|
+
private config;
|
|
230
|
+
constructor(config: FetcherConfig);
|
|
231
|
+
get(): Promise<GatewayEnvelope<AutolinkProfile>>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare class ArticlesResource {
|
|
235
|
+
private config;
|
|
236
|
+
private cache?;
|
|
237
|
+
constructor(config: FetcherConfig, cache?: AutolinkCache | undefined);
|
|
238
|
+
list(filters?: ArticleListFilters, options?: {
|
|
239
|
+
ttl?: number;
|
|
240
|
+
}): Promise<GatewayEnvelope<AutolinkArticle[]>>;
|
|
241
|
+
get(slug: string, options?: {
|
|
242
|
+
ttl?: number;
|
|
243
|
+
}): Promise<GatewayEnvelope<AutolinkArticle>>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare class IntegrationResource {
|
|
247
|
+
private config;
|
|
248
|
+
constructor(config: FetcherConfig);
|
|
249
|
+
check(): Promise<GatewayEnvelope<IntegrationStatus>>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface AutolinkClientConfig {
|
|
253
|
+
apiKey: string;
|
|
254
|
+
timeout?: number;
|
|
255
|
+
retry?: Partial<RetryConfig>;
|
|
256
|
+
debug?: boolean;
|
|
257
|
+
cache?: AutolinkCache;
|
|
258
|
+
}
|
|
259
|
+
declare class AutolinkClient {
|
|
260
|
+
readonly inventory: InventoryResource;
|
|
261
|
+
readonly inquiries: InquiriesResource;
|
|
262
|
+
readonly profile: ProfileResource;
|
|
263
|
+
readonly articles: ArticlesResource;
|
|
264
|
+
readonly integration: IntegrationResource;
|
|
265
|
+
constructor(config: AutolinkClientConfig);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
declare class AutolinkError extends Error {
|
|
269
|
+
readonly requestId: string;
|
|
270
|
+
readonly code: string;
|
|
271
|
+
constructor(message: string, code: string, requestId: string);
|
|
272
|
+
}
|
|
273
|
+
declare class AutolinkAuthError extends AutolinkError {
|
|
274
|
+
constructor(message: string, requestId: string);
|
|
275
|
+
}
|
|
276
|
+
declare class AutolinkForbiddenError extends AutolinkError {
|
|
277
|
+
constructor(message: string, requestId: string);
|
|
278
|
+
}
|
|
279
|
+
declare class AutolinkNotFoundError extends AutolinkError {
|
|
280
|
+
constructor(message: string, requestId: string);
|
|
281
|
+
}
|
|
282
|
+
declare class AutolinkValidationError extends AutolinkError {
|
|
283
|
+
readonly fields: Record<string, string[]>;
|
|
284
|
+
constructor(message: string, requestId: string, fields?: Record<string, string[]>);
|
|
285
|
+
}
|
|
286
|
+
declare class AutolinkRateLimitError extends AutolinkError {
|
|
287
|
+
readonly retryAfter: number;
|
|
288
|
+
constructor(message: string, requestId: string, retryAfter: number);
|
|
289
|
+
}
|
|
290
|
+
declare class AutolinkNetworkError extends AutolinkError {
|
|
291
|
+
readonly cause: Error;
|
|
292
|
+
constructor(message: string, cause: Error);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare const GATEWAY_BASE_URL = "https://gateway.autolink.ke";
|
|
296
|
+
declare const GATEWAY_URL = "https://gateway.autolink.ke/sdk/v1";
|
|
297
|
+
declare const SDK_VERSION = "0.1.0";
|
|
298
|
+
|
|
299
|
+
/** Unwraps a GatewayEnvelope and returns the data directly */
|
|
300
|
+
declare function unwrap<T>(envelope: GatewayEnvelope<T>): T;
|
|
301
|
+
/** Returns field-level validation errors for a given field name */
|
|
302
|
+
declare function getFieldErrors(error: AutolinkValidationError, field: string): string[];
|
|
303
|
+
|
|
304
|
+
export { type ArticleListFilters, type AutolinkArticle, AutolinkAuthError, type AutolinkCache, AutolinkClient, type AutolinkClientConfig, AutolinkError, AutolinkForbiddenError, type AutolinkInquiry, type AutolinkInquiryPayload, AutolinkNetworkError, AutolinkNotFoundError, type AutolinkProfile, AutolinkRateLimitError, AutolinkValidationError, type AutolinkVehicle, type CoverImageVariants, type FilterOptions, GATEWAY_BASE_URL, GATEWAY_URL, type GatewayEnvelope, type GatewayMeta, type GatewayPagination, type IntegrationStatus, type InventoryListFilters, MemoryCache, SDK_VERSION, type StockStatus, type VehicleCondition, type VehicleDealer, type VehiclePhoto, getFieldErrors, unwrap };
|