@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.js ADDED
@@ -0,0 +1,426 @@
1
+ // src/transport/constants.ts
2
+ var GATEWAY_BASE_URL = "https://gateway.autolink.ke";
3
+ var GATEWAY_API_VERSION = "v1";
4
+ var GATEWAY_URL = `${GATEWAY_BASE_URL}/sdk/${GATEWAY_API_VERSION}`;
5
+ var DEFAULT_TIMEOUT_MS = 1e4;
6
+ var DEFAULT_RETRY_ATTEMPTS = 3;
7
+ var SDK_VERSION = "0.1.0";
8
+
9
+ // src/errors.ts
10
+ var AutolinkError = class extends Error {
11
+ requestId;
12
+ code;
13
+ constructor(message, code, requestId) {
14
+ super(message);
15
+ this.name = "AutolinkError";
16
+ this.code = code;
17
+ this.requestId = requestId;
18
+ }
19
+ };
20
+ var AutolinkAuthError = class extends AutolinkError {
21
+ constructor(message, requestId) {
22
+ super(message, "AUTHENTICATION_ERROR", requestId);
23
+ this.name = "AutolinkAuthError";
24
+ }
25
+ };
26
+ var AutolinkForbiddenError = class extends AutolinkError {
27
+ constructor(message, requestId) {
28
+ super(message, "FORBIDDEN", requestId);
29
+ this.name = "AutolinkForbiddenError";
30
+ }
31
+ };
32
+ var AutolinkNotFoundError = class extends AutolinkError {
33
+ constructor(message, requestId) {
34
+ super(message, "NOT_FOUND", requestId);
35
+ this.name = "AutolinkNotFoundError";
36
+ }
37
+ };
38
+ var AutolinkValidationError = class extends AutolinkError {
39
+ fields;
40
+ constructor(message, requestId, fields = {}) {
41
+ super(message, "VALIDATION_ERROR", requestId);
42
+ this.name = "AutolinkValidationError";
43
+ this.fields = fields;
44
+ }
45
+ };
46
+ var AutolinkRateLimitError = class extends AutolinkError {
47
+ retryAfter;
48
+ constructor(message, requestId, retryAfter) {
49
+ super(message, "RATE_LIMITED", requestId);
50
+ this.name = "AutolinkRateLimitError";
51
+ this.retryAfter = retryAfter;
52
+ }
53
+ };
54
+ var AutolinkNetworkError = class extends AutolinkError {
55
+ cause;
56
+ constructor(message, cause) {
57
+ super(message, "NETWORK_ERROR", "");
58
+ this.name = "AutolinkNetworkError";
59
+ this.cause = cause;
60
+ }
61
+ };
62
+
63
+ // src/transport/retry.ts
64
+ var RETRYABLE_STATUS = /* @__PURE__ */ new Set([500, 502, 503, 504]);
65
+ function isRetryableStatus(status) {
66
+ return RETRYABLE_STATUS.has(status);
67
+ }
68
+ function backoffMs(attempt) {
69
+ const base = 100 * Math.pow(2, attempt);
70
+ const jitter = Math.random() * 100;
71
+ return Math.min(base + jitter, 1e4);
72
+ }
73
+ async function sleep(ms) {
74
+ return new Promise((resolve) => setTimeout(resolve, ms));
75
+ }
76
+
77
+ // src/transport/fetcher.ts
78
+ function resolveGatewayUrl() {
79
+ if (process.env["NODE_ENV"] !== "production" && process.env["AUTOLINK_GATEWAY_URL"]) {
80
+ return `${process.env["AUTOLINK_GATEWAY_URL"]}/sdk/v1`;
81
+ }
82
+ return GATEWAY_URL;
83
+ }
84
+ function throwFromResponse(status, body, headers) {
85
+ const { code, message, fields, request_id } = body.error;
86
+ const rid = request_id ?? "";
87
+ if (status === 401) throw new AutolinkAuthError(message, rid);
88
+ if (status === 403) throw new AutolinkForbiddenError(message, rid);
89
+ if (status === 404) throw new AutolinkNotFoundError(message, rid);
90
+ if (status === 400 || status === 422)
91
+ throw new AutolinkValidationError(message, rid, fields ?? {});
92
+ if (status === 429) {
93
+ const retryAfter = parseInt(headers.get("Retry-After") ?? "60", 10);
94
+ throw new AutolinkRateLimitError(message, rid, retryAfter);
95
+ }
96
+ throw new AutolinkError(message, code ?? "GATEWAY_ERROR", rid);
97
+ }
98
+ async function gatewayFetch(config, method, path, options = {}) {
99
+ const base = resolveGatewayUrl();
100
+ const url = new URL(`${base}${path}`);
101
+ if (options.params) {
102
+ for (const [k, v] of Object.entries(options.params)) {
103
+ if (v !== void 0) url.searchParams.set(k, String(v));
104
+ }
105
+ }
106
+ const headers = {
107
+ "Content-Type": "application/json",
108
+ "X-API-Key": config.apiKey,
109
+ "X-Autolink-SDK-Version": SDK_VERSION
110
+ };
111
+ if (options.idempotencyKey) {
112
+ headers["Idempotency-Key"] = options.idempotencyKey;
113
+ }
114
+ const isWrite = method === "POST" || method === "PUT" || method === "PATCH";
115
+ const maxAttempts = isWrite && !options.idempotencyKey ? 1 : config.retry.attempts;
116
+ let lastError = null;
117
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
118
+ if (attempt > 0) await sleep(backoffMs(attempt - 1));
119
+ const controller = new AbortController();
120
+ const timeoutId = setTimeout(
121
+ () => controller.abort(),
122
+ config.timeout ?? DEFAULT_TIMEOUT_MS
123
+ );
124
+ const signal = options.signal ?? controller.signal;
125
+ try {
126
+ const res = await fetch(url.toString(), {
127
+ method,
128
+ headers,
129
+ ...options.body ? { body: JSON.stringify(options.body) } : {},
130
+ signal
131
+ });
132
+ clearTimeout(timeoutId);
133
+ if (config.debug) {
134
+ const rid = res.headers.get("X-Request-ID") ?? "";
135
+ console.debug(`[autolink] ${method} ${path} \u2192 ${res.status} (${rid})`);
136
+ }
137
+ if (!res.ok) {
138
+ const errorBody = await res.json();
139
+ if (isRetryableStatus(res.status) && attempt < maxAttempts - 1) {
140
+ lastError = new AutolinkError(
141
+ errorBody.error?.message ?? "Gateway error",
142
+ errorBody.error?.code ?? "GATEWAY_ERROR",
143
+ errorBody.error?.request_id ?? ""
144
+ );
145
+ continue;
146
+ }
147
+ throwFromResponse(res.status, errorBody, res.headers);
148
+ }
149
+ return await res.json();
150
+ } catch (err) {
151
+ clearTimeout(timeoutId);
152
+ if (err instanceof AutolinkError) throw err;
153
+ const networkErr = err instanceof Error ? err : new Error(String(err));
154
+ lastError = new AutolinkNetworkError(
155
+ `Request to Autolink gateway failed: ${networkErr.message}`,
156
+ networkErr
157
+ );
158
+ if (attempt < maxAttempts - 1) continue;
159
+ }
160
+ }
161
+ throw lastError ?? new AutolinkNetworkError("Request failed", new Error("Unknown error"));
162
+ }
163
+
164
+ // src/resources/inventory.ts
165
+ var TTL_LIST = 300;
166
+ var TTL_SINGLE = 600;
167
+ var TTL_FILTER_OPTIONS = 300;
168
+ var InventoryResource = class {
169
+ constructor(config, cache) {
170
+ this.config = config;
171
+ this.cache = cache;
172
+ }
173
+ config;
174
+ cache;
175
+ async list(filters = {}, options) {
176
+ const ttl = options?.ttl ?? TTL_LIST;
177
+ const key = `autolink:inventory:list:${JSON.stringify(filters)}`;
178
+ if (this.cache && ttl > 0) {
179
+ const cached = await this.cache.get(key);
180
+ if (cached !== void 0)
181
+ return cached;
182
+ }
183
+ const result = await gatewayFetch(
184
+ this.config,
185
+ "GET",
186
+ "/inventory",
187
+ {
188
+ params: filters
189
+ }
190
+ );
191
+ if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);
192
+ return result;
193
+ }
194
+ async get(slug, options) {
195
+ const ttl = options?.ttl ?? TTL_SINGLE;
196
+ const key = `autolink:inventory:${slug}`;
197
+ if (this.cache && ttl > 0) {
198
+ const cached = await this.cache.get(key);
199
+ if (cached !== void 0)
200
+ return cached;
201
+ }
202
+ const result = await gatewayFetch(
203
+ this.config,
204
+ "GET",
205
+ `/inventory/${slug}`
206
+ );
207
+ if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);
208
+ return result;
209
+ }
210
+ async filterOptions(options) {
211
+ const ttl = options?.ttl ?? TTL_FILTER_OPTIONS;
212
+ const key = "autolink:inventory:filter-options";
213
+ if (this.cache && ttl > 0) {
214
+ const cached = await this.cache.get(key);
215
+ if (cached !== void 0) return cached;
216
+ }
217
+ const result = await gatewayFetch(
218
+ this.config,
219
+ "GET",
220
+ "/inventory/filter-options"
221
+ );
222
+ if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);
223
+ return result;
224
+ }
225
+ async *pages(filters = {}) {
226
+ let page = 1;
227
+ while (true) {
228
+ const result = await this.list({ ...filters, page });
229
+ yield result;
230
+ const { pagination } = result.meta;
231
+ if (!pagination || page >= pagination.pages) break;
232
+ page++;
233
+ }
234
+ }
235
+ };
236
+
237
+ // src/resources/inquiries.ts
238
+ import { randomUUID } from "crypto";
239
+ var InquiriesResource = class {
240
+ constructor(config) {
241
+ this.config = config;
242
+ }
243
+ config;
244
+ async create(payload, options = {}) {
245
+ const idempotencyKey = options.idempotencyKey ?? randomUUID();
246
+ return gatewayFetch(
247
+ this.config,
248
+ "POST",
249
+ "/inquiries",
250
+ { body: payload, idempotencyKey }
251
+ );
252
+ }
253
+ };
254
+
255
+ // src/resources/profile.ts
256
+ var ProfileResource = class {
257
+ constructor(config) {
258
+ this.config = config;
259
+ }
260
+ config;
261
+ async get() {
262
+ return gatewayFetch(
263
+ this.config,
264
+ "GET",
265
+ "/profile"
266
+ );
267
+ }
268
+ };
269
+
270
+ // src/resources/articles.ts
271
+ var TTL_ARTICLES = 600;
272
+ var ArticlesResource = class {
273
+ constructor(config, cache) {
274
+ this.config = config;
275
+ this.cache = cache;
276
+ }
277
+ config;
278
+ cache;
279
+ async list(filters = {}, options) {
280
+ const ttl = options?.ttl ?? TTL_ARTICLES;
281
+ const key = `autolink:articles:list:${JSON.stringify(filters)}`;
282
+ if (this.cache && ttl > 0) {
283
+ const cached = await this.cache.get(key);
284
+ if (cached !== void 0)
285
+ return cached;
286
+ }
287
+ const result = await gatewayFetch(
288
+ this.config,
289
+ "GET",
290
+ "/articles",
291
+ {
292
+ params: filters
293
+ }
294
+ );
295
+ if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);
296
+ return result;
297
+ }
298
+ async get(slug, options) {
299
+ const ttl = options?.ttl ?? TTL_ARTICLES;
300
+ const key = `autolink:articles:${slug}`;
301
+ if (this.cache && ttl > 0) {
302
+ const cached = await this.cache.get(key);
303
+ if (cached !== void 0)
304
+ return cached;
305
+ }
306
+ const result = await gatewayFetch(
307
+ this.config,
308
+ "GET",
309
+ `/articles/${slug}`
310
+ );
311
+ if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);
312
+ return result;
313
+ }
314
+ };
315
+
316
+ // src/resources/integration.ts
317
+ var IntegrationResource = class {
318
+ constructor(config) {
319
+ this.config = config;
320
+ }
321
+ config;
322
+ async check() {
323
+ return gatewayFetch(
324
+ this.config,
325
+ "GET",
326
+ "/integration"
327
+ );
328
+ }
329
+ };
330
+
331
+ // src/client.ts
332
+ var AutolinkClient = class {
333
+ inventory;
334
+ inquiries;
335
+ profile;
336
+ articles;
337
+ integration;
338
+ constructor(config) {
339
+ if (!config.apiKey) {
340
+ throw new Error("AutolinkClient: apiKey is required");
341
+ }
342
+ if (!config.apiKey.startsWith("gw_live_") && !config.apiKey.startsWith("gw_test_")) {
343
+ throw new Error(
344
+ 'AutolinkClient: apiKey must start with "gw_live_" or "gw_test_"'
345
+ );
346
+ }
347
+ const fetcherConfig = {
348
+ apiKey: config.apiKey,
349
+ timeout: config.timeout ?? DEFAULT_TIMEOUT_MS,
350
+ retry: {
351
+ attempts: config.retry?.attempts ?? DEFAULT_RETRY_ATTEMPTS,
352
+ backoff: config.retry?.backoff ?? "exponential"
353
+ },
354
+ debug: config.debug ?? false
355
+ };
356
+ this.inventory = new InventoryResource(fetcherConfig, config.cache);
357
+ this.inquiries = new InquiriesResource(fetcherConfig);
358
+ this.profile = new ProfileResource(fetcherConfig);
359
+ this.articles = new ArticlesResource(fetcherConfig, config.cache);
360
+ this.integration = new IntegrationResource(fetcherConfig);
361
+ }
362
+ };
363
+
364
+ // src/cache/index.ts
365
+ var MAX_ENTRIES = 200;
366
+ var MemoryCache = class {
367
+ store = /* @__PURE__ */ new Map();
368
+ get(key) {
369
+ const entry = this.store.get(key);
370
+ if (!entry) return void 0;
371
+ if (entry.expiresAt !== null && Date.now() > entry.expiresAt) {
372
+ this.store.delete(key);
373
+ return void 0;
374
+ }
375
+ return entry.value;
376
+ }
377
+ set(key, value, ttlSeconds) {
378
+ if (this.store.size >= MAX_ENTRIES && !this.store.has(key)) {
379
+ const oldestKey = this.store.keys().next().value;
380
+ if (oldestKey !== void 0) {
381
+ this.store.delete(oldestKey);
382
+ }
383
+ }
384
+ this.store.set(key, {
385
+ value,
386
+ expiresAt: ttlSeconds != null ? Date.now() + ttlSeconds * 1e3 : null
387
+ });
388
+ }
389
+ delete(key) {
390
+ this.store.delete(key);
391
+ }
392
+ /** Remove all expired entries. Optional maintenance call. */
393
+ purgeExpired() {
394
+ const now = Date.now();
395
+ for (const [key, entry] of this.store) {
396
+ if (entry.expiresAt !== null && now > entry.expiresAt) {
397
+ this.store.delete(key);
398
+ }
399
+ }
400
+ }
401
+ };
402
+
403
+ // src/index.ts
404
+ function unwrap(envelope) {
405
+ return envelope.data;
406
+ }
407
+ function getFieldErrors(error, field) {
408
+ return error.fields[field] ?? [];
409
+ }
410
+ export {
411
+ AutolinkAuthError,
412
+ AutolinkClient,
413
+ AutolinkError,
414
+ AutolinkForbiddenError,
415
+ AutolinkNetworkError,
416
+ AutolinkNotFoundError,
417
+ AutolinkRateLimitError,
418
+ AutolinkValidationError,
419
+ GATEWAY_BASE_URL,
420
+ GATEWAY_URL,
421
+ MemoryCache,
422
+ SDK_VERSION,
423
+ getFieldErrors,
424
+ unwrap
425
+ };
426
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/transport/constants.ts","../src/errors.ts","../src/transport/retry.ts","../src/transport/fetcher.ts","../src/resources/inventory.ts","../src/resources/inquiries.ts","../src/resources/profile.ts","../src/resources/articles.ts","../src/resources/integration.ts","../src/client.ts","../src/cache/index.ts","../src/index.ts"],"sourcesContent":["export const GATEWAY_BASE_URL = \"https://gateway.autolink.ke\";\nexport const GATEWAY_API_VERSION = \"v1\";\nexport const GATEWAY_URL = `${GATEWAY_BASE_URL}/sdk/${GATEWAY_API_VERSION}`;\n\nexport const DEFAULT_TIMEOUT_MS = 10_000;\nexport const DEFAULT_RETRY_ATTEMPTS = 3;\nexport const SDK_VERSION = \"0.1.0\";\n","export class AutolinkError extends Error {\n readonly requestId: string;\n readonly code: string;\n\n constructor(message: string, code: string, requestId: string) {\n super(message);\n this.name = \"AutolinkError\";\n this.code = code;\n this.requestId = requestId;\n }\n}\n\nexport class AutolinkAuthError extends AutolinkError {\n constructor(message: string, requestId: string) {\n super(message, \"AUTHENTICATION_ERROR\", requestId);\n this.name = \"AutolinkAuthError\";\n }\n}\n\nexport class AutolinkForbiddenError extends AutolinkError {\n constructor(message: string, requestId: string) {\n super(message, \"FORBIDDEN\", requestId);\n this.name = \"AutolinkForbiddenError\";\n }\n}\n\nexport class AutolinkNotFoundError extends AutolinkError {\n constructor(message: string, requestId: string) {\n super(message, \"NOT_FOUND\", requestId);\n this.name = \"AutolinkNotFoundError\";\n }\n}\n\nexport class AutolinkValidationError extends AutolinkError {\n readonly fields: Record<string, string[]>;\n\n constructor(\n message: string,\n requestId: string,\n fields: Record<string, string[]> = {},\n ) {\n super(message, \"VALIDATION_ERROR\", requestId);\n this.name = \"AutolinkValidationError\";\n this.fields = fields;\n }\n}\n\nexport class AutolinkRateLimitError extends AutolinkError {\n readonly retryAfter: number;\n\n constructor(message: string, requestId: string, retryAfter: number) {\n super(message, \"RATE_LIMITED\", requestId);\n this.name = \"AutolinkRateLimitError\";\n this.retryAfter = retryAfter;\n }\n}\n\nexport class AutolinkNetworkError extends AutolinkError {\n readonly cause: Error;\n\n constructor(message: string, cause: Error) {\n super(message, \"NETWORK_ERROR\", \"\");\n this.name = \"AutolinkNetworkError\";\n this.cause = cause;\n }\n}\n","export interface RetryConfig {\n attempts: number;\n backoff: \"exponential\" | \"linear\";\n}\n\nconst RETRYABLE_STATUS = new Set([500, 502, 503, 504]);\n\nexport function isRetryableStatus(status: number): boolean {\n return RETRYABLE_STATUS.has(status);\n}\n\nexport function backoffMs(attempt: number): number {\n const base = 100 * Math.pow(2, attempt);\n const jitter = Math.random() * 100;\n return Math.min(base + jitter, 10_000);\n}\n\nexport async function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import { GATEWAY_URL, DEFAULT_TIMEOUT_MS, SDK_VERSION } from \"./constants.js\";\nimport {\n AutolinkAuthError,\n AutolinkForbiddenError,\n AutolinkNotFoundError,\n AutolinkValidationError,\n AutolinkRateLimitError,\n AutolinkNetworkError,\n AutolinkError,\n} from \"../errors.js\";\nimport { RetryConfig, isRetryableStatus, backoffMs, sleep } from \"./retry.js\";\n\n// Internal escape hatch for Autolink engineering only — not documented publicly.\n// Silently ignored when NODE_ENV is \"production\".\nfunction resolveGatewayUrl(): string {\n if (\n process.env[\"NODE_ENV\"] !== \"production\" &&\n process.env[\"AUTOLINK_GATEWAY_URL\"]\n ) {\n return `${process.env[\"AUTOLINK_GATEWAY_URL\"]}/sdk/v1`;\n }\n return GATEWAY_URL;\n}\n\nexport interface FetcherConfig {\n apiKey: string;\n timeout: number;\n retry: RetryConfig;\n debug: boolean;\n}\n\ninterface GatewayErrorBody {\n error: {\n code: string;\n message: string;\n fields?: Record<string, string[]>;\n request_id: string;\n };\n}\n\nfunction throwFromResponse(\n status: number,\n body: GatewayErrorBody,\n headers: Headers,\n): never {\n const { code, message, fields, request_id } = body.error;\n const rid = request_id ?? \"\";\n\n if (status === 401) throw new AutolinkAuthError(message, rid);\n if (status === 403) throw new AutolinkForbiddenError(message, rid);\n if (status === 404) throw new AutolinkNotFoundError(message, rid);\n if (status === 400 || status === 422)\n throw new AutolinkValidationError(message, rid, fields ?? {});\n if (status === 429) {\n const retryAfter = parseInt(headers.get(\"Retry-After\") ?? \"60\", 10);\n throw new AutolinkRateLimitError(message, rid, retryAfter);\n }\n throw new AutolinkError(message, code ?? \"GATEWAY_ERROR\", rid);\n}\n\nexport async function gatewayFetch<T>(\n config: FetcherConfig,\n method: string,\n path: string,\n options: {\n params?: Record<string, string | number | boolean | undefined>;\n body?: unknown;\n idempotencyKey?: string;\n signal?: AbortSignal;\n } = {},\n): Promise<T> {\n const base = resolveGatewayUrl();\n const url = new URL(`${base}${path}`);\n\n if (options.params) {\n for (const [k, v] of Object.entries(options.params)) {\n if (v !== undefined) url.searchParams.set(k, String(v));\n }\n }\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": config.apiKey,\n \"X-Autolink-SDK-Version\": SDK_VERSION,\n };\n if (options.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n\n const isWrite = method === \"POST\" || method === \"PUT\" || method === \"PATCH\";\n const maxAttempts =\n isWrite && !options.idempotencyKey ? 1 : config.retry.attempts;\n\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n if (attempt > 0) await sleep(backoffMs(attempt - 1));\n\n const controller = new AbortController();\n const timeoutId = setTimeout(\n () => controller.abort(),\n config.timeout ?? DEFAULT_TIMEOUT_MS,\n );\n const signal = options.signal ?? controller.signal;\n\n try {\n const res = await fetch(url.toString(), {\n method,\n headers,\n ...(options.body ? { body: JSON.stringify(options.body) } : {}),\n signal,\n });\n clearTimeout(timeoutId);\n\n if (config.debug) {\n const rid = res.headers.get(\"X-Request-ID\") ?? \"\";\n console.debug(`[autolink] ${method} ${path} → ${res.status} (${rid})`);\n }\n\n if (!res.ok) {\n const errorBody = (await res.json()) as GatewayErrorBody;\n\n // Retry on 5xx but not on 4xx\n if (isRetryableStatus(res.status) && attempt < maxAttempts - 1) {\n lastError = new AutolinkError(\n errorBody.error?.message ?? \"Gateway error\",\n errorBody.error?.code ?? \"GATEWAY_ERROR\",\n errorBody.error?.request_id ?? \"\",\n );\n continue;\n }\n\n throwFromResponse(res.status, errorBody, res.headers);\n }\n\n return (await res.json()) as T;\n } catch (err) {\n clearTimeout(timeoutId);\n\n if (err instanceof AutolinkError) throw err;\n\n const networkErr = err instanceof Error ? err : new Error(String(err));\n lastError = new AutolinkNetworkError(\n `Request to Autolink gateway failed: ${networkErr.message}`,\n networkErr,\n );\n\n if (attempt < maxAttempts - 1) continue;\n }\n }\n\n throw (\n lastError ??\n new AutolinkNetworkError(\"Request failed\", new Error(\"Unknown error\"))\n );\n}\n","import { gatewayFetch, FetcherConfig } from \"../transport/fetcher.js\";\nimport type {\n GatewayEnvelope,\n AutolinkVehicle,\n FilterOptions,\n InventoryListFilters,\n} from \"../types/index.js\";\nimport type { AutolinkCache } from \"../cache/index.js\";\n\nconst TTL_LIST = 300; // 5 minutes\nconst TTL_SINGLE = 600; // 10 minutes\nconst TTL_FILTER_OPTIONS = 300;\n\nexport class InventoryResource {\n constructor(\n private config: FetcherConfig,\n private cache?: AutolinkCache,\n ) {}\n\n async list(\n filters: InventoryListFilters = {},\n options?: { ttl?: number },\n ): Promise<GatewayEnvelope<AutolinkVehicle[]>> {\n const ttl = options?.ttl ?? TTL_LIST;\n const key = `autolink:inventory:list:${JSON.stringify(filters)}`;\n if (this.cache && ttl > 0) {\n const cached = await this.cache.get(key);\n if (cached !== undefined)\n return cached as GatewayEnvelope<AutolinkVehicle[]>;\n }\n const result = await gatewayFetch<GatewayEnvelope<AutolinkVehicle[]>>(\n this.config,\n \"GET\",\n \"/inventory\",\n {\n params: filters as Record<\n string,\n string | number | boolean | undefined\n >,\n },\n );\n if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);\n return result;\n }\n\n async get(\n slug: string,\n options?: { ttl?: number },\n ): Promise<GatewayEnvelope<AutolinkVehicle>> {\n const ttl = options?.ttl ?? TTL_SINGLE;\n const key = `autolink:inventory:${slug}`;\n if (this.cache && ttl > 0) {\n const cached = await this.cache.get(key);\n if (cached !== undefined)\n return cached as GatewayEnvelope<AutolinkVehicle>;\n }\n const result = await gatewayFetch<GatewayEnvelope<AutolinkVehicle>>(\n this.config,\n \"GET\",\n `/inventory/${slug}`,\n );\n if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);\n return result;\n }\n\n async filterOptions(options?: {\n ttl?: number;\n }): Promise<GatewayEnvelope<FilterOptions>> {\n const ttl = options?.ttl ?? TTL_FILTER_OPTIONS;\n const key = \"autolink:inventory:filter-options\";\n if (this.cache && ttl > 0) {\n const cached = await this.cache.get(key);\n if (cached !== undefined) return cached as GatewayEnvelope<FilterOptions>;\n }\n const result = await gatewayFetch<GatewayEnvelope<FilterOptions>>(\n this.config,\n \"GET\",\n \"/inventory/filter-options\",\n );\n if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);\n return result;\n }\n\n async *pages(\n filters: Omit<InventoryListFilters, \"page\"> = {},\n ): AsyncGenerator<GatewayEnvelope<AutolinkVehicle[]>> {\n let page = 1;\n while (true) {\n const result = await this.list({ ...filters, page });\n yield result;\n const { pagination } = result.meta;\n if (!pagination || page >= pagination.pages) break;\n page++;\n }\n }\n}\n","import { gatewayFetch, FetcherConfig } from \"../transport/fetcher.js\";\nimport type {\n GatewayEnvelope,\n AutolinkInquiry,\n AutolinkInquiryPayload,\n} from \"../types/index.js\";\nimport { randomUUID } from \"crypto\";\n\nexport interface InquiryCreateOptions {\n idempotencyKey?: string;\n}\n\nexport class InquiriesResource {\n constructor(private config: FetcherConfig) {}\n\n async create(\n payload: AutolinkInquiryPayload,\n options: InquiryCreateOptions = {},\n ): Promise<GatewayEnvelope<AutolinkInquiry>> {\n const idempotencyKey = options.idempotencyKey ?? randomUUID();\n return gatewayFetch<GatewayEnvelope<AutolinkInquiry>>(\n this.config,\n \"POST\",\n \"/inquiries\",\n { body: payload, idempotencyKey },\n );\n }\n}\n","import { gatewayFetch, FetcherConfig } from \"../transport/fetcher.js\";\nimport type { GatewayEnvelope, AutolinkProfile } from \"../types/index.js\";\n\nexport class ProfileResource {\n constructor(private config: FetcherConfig) {}\n\n async get(): Promise<GatewayEnvelope<AutolinkProfile>> {\n return gatewayFetch<GatewayEnvelope<AutolinkProfile>>(\n this.config,\n \"GET\",\n \"/profile\",\n );\n }\n}\n","import { gatewayFetch, FetcherConfig } from \"../transport/fetcher.js\";\nimport type {\n GatewayEnvelope,\n AutolinkArticle,\n ArticleListFilters,\n} from \"../types/index.js\";\nimport type { AutolinkCache } from \"../cache/index.js\";\n\nconst TTL_ARTICLES = 600; // 10 minutes\n\nexport class ArticlesResource {\n constructor(\n private config: FetcherConfig,\n private cache?: AutolinkCache,\n ) {}\n\n async list(\n filters: ArticleListFilters = {},\n options?: { ttl?: number },\n ): Promise<GatewayEnvelope<AutolinkArticle[]>> {\n const ttl = options?.ttl ?? TTL_ARTICLES;\n const key = `autolink:articles:list:${JSON.stringify(filters)}`;\n if (this.cache && ttl > 0) {\n const cached = await this.cache.get(key);\n if (cached !== undefined)\n return cached as GatewayEnvelope<AutolinkArticle[]>;\n }\n const result = await gatewayFetch<GatewayEnvelope<AutolinkArticle[]>>(\n this.config,\n \"GET\",\n \"/articles\",\n {\n params: filters as Record<\n string,\n string | number | boolean | undefined\n >,\n },\n );\n if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);\n return result;\n }\n\n async get(\n slug: string,\n options?: { ttl?: number },\n ): Promise<GatewayEnvelope<AutolinkArticle>> {\n const ttl = options?.ttl ?? TTL_ARTICLES;\n const key = `autolink:articles:${slug}`;\n if (this.cache && ttl > 0) {\n const cached = await this.cache.get(key);\n if (cached !== undefined)\n return cached as GatewayEnvelope<AutolinkArticle>;\n }\n const result = await gatewayFetch<GatewayEnvelope<AutolinkArticle>>(\n this.config,\n \"GET\",\n `/articles/${slug}`,\n );\n if (this.cache && ttl > 0) await this.cache.set(key, result, ttl);\n return result;\n }\n}\n","import { gatewayFetch, FetcherConfig } from \"../transport/fetcher.js\";\nimport type { GatewayEnvelope, IntegrationStatus } from \"../types/index.js\";\n\nexport class IntegrationResource {\n constructor(private config: FetcherConfig) {}\n\n async check(): Promise<GatewayEnvelope<IntegrationStatus>> {\n return gatewayFetch<GatewayEnvelope<IntegrationStatus>>(\n this.config,\n \"GET\",\n \"/integration\",\n );\n }\n}\n","import {\n DEFAULT_TIMEOUT_MS,\n DEFAULT_RETRY_ATTEMPTS,\n} from \"./transport/constants.js\";\nimport type { RetryConfig } from \"./transport/retry.js\";\nimport type { FetcherConfig } from \"./transport/fetcher.js\";\nimport { InventoryResource } from \"./resources/inventory.js\";\nimport { InquiriesResource } from \"./resources/inquiries.js\";\nimport { ProfileResource } from \"./resources/profile.js\";\nimport { ArticlesResource } from \"./resources/articles.js\";\nimport { IntegrationResource } from \"./resources/integration.js\";\nimport type { AutolinkCache } from \"./cache/index.js\";\n\nexport interface AutolinkClientConfig {\n apiKey: string;\n timeout?: number;\n retry?: Partial<RetryConfig>;\n debug?: boolean;\n cache?: AutolinkCache;\n}\n\nexport class AutolinkClient {\n readonly inventory: InventoryResource;\n readonly inquiries: InquiriesResource;\n readonly profile: ProfileResource;\n readonly articles: ArticlesResource;\n readonly integration: IntegrationResource;\n\n constructor(config: AutolinkClientConfig) {\n if (!config.apiKey) {\n throw new Error(\"AutolinkClient: apiKey is required\");\n }\n if (\n !config.apiKey.startsWith(\"gw_live_\") &&\n !config.apiKey.startsWith(\"gw_test_\")\n ) {\n throw new Error(\n 'AutolinkClient: apiKey must start with \"gw_live_\" or \"gw_test_\"',\n );\n }\n\n const fetcherConfig: FetcherConfig = {\n apiKey: config.apiKey,\n timeout: config.timeout ?? DEFAULT_TIMEOUT_MS,\n retry: {\n attempts: config.retry?.attempts ?? DEFAULT_RETRY_ATTEMPTS,\n backoff: config.retry?.backoff ?? \"exponential\",\n },\n debug: config.debug ?? false,\n };\n\n this.inventory = new InventoryResource(fetcherConfig, config.cache);\n this.inquiries = new InquiriesResource(fetcherConfig);\n this.profile = new ProfileResource(fetcherConfig);\n this.articles = new ArticlesResource(fetcherConfig, config.cache);\n this.integration = new IntegrationResource(fetcherConfig);\n }\n}\n","export interface AutolinkCache {\n get(key: string): Promise<unknown> | unknown;\n set(key: string, value: unknown, ttlSeconds?: number): Promise<void> | void;\n delete(key: string): Promise<void> | void;\n}\n\ninterface CacheEntry {\n value: unknown;\n expiresAt: number | null; // null = no expiry\n}\n\nconst MAX_ENTRIES = 200;\n\nexport class MemoryCache implements AutolinkCache {\n private store = new Map<string, CacheEntry>();\n\n get(key: string): unknown {\n const entry = this.store.get(key);\n if (!entry) return undefined;\n if (entry.expiresAt !== null && Date.now() > entry.expiresAt) {\n this.store.delete(key);\n return undefined;\n }\n return entry.value;\n }\n\n set(key: string, value: unknown, ttlSeconds?: number): void {\n // Evict oldest entry if at capacity and key is new\n if (this.store.size >= MAX_ENTRIES && !this.store.has(key)) {\n const oldestKey = this.store.keys().next().value;\n if (oldestKey !== undefined) {\n this.store.delete(oldestKey);\n }\n }\n this.store.set(key, {\n value,\n expiresAt: ttlSeconds != null ? Date.now() + ttlSeconds * 1000 : null,\n });\n }\n\n delete(key: string): void {\n this.store.delete(key);\n }\n\n /** Remove all expired entries. Optional maintenance call. */\n purgeExpired(): void {\n const now = Date.now();\n for (const [key, entry] of this.store) {\n if (entry.expiresAt !== null && now > entry.expiresAt) {\n this.store.delete(key);\n }\n }\n }\n}\n","export { AutolinkClient } from \"./client.js\";\nexport type { AutolinkClientConfig } from \"./client.js\";\n\nexport {\n AutolinkError,\n AutolinkAuthError,\n AutolinkForbiddenError,\n AutolinkNotFoundError,\n AutolinkValidationError,\n AutolinkRateLimitError,\n AutolinkNetworkError,\n} from \"./errors.js\";\n\nexport type {\n GatewayEnvelope,\n GatewayMeta,\n GatewayPagination,\n AutolinkVehicle,\n VehiclePhoto,\n VehicleDealer,\n CoverImageVariants,\n InventoryListFilters,\n FilterOptions,\n AutolinkInquiryPayload,\n AutolinkInquiry,\n AutolinkProfile,\n AutolinkArticle,\n ArticleListFilters,\n IntegrationStatus,\n StockStatus,\n VehicleCondition,\n} from \"./types/index.js\";\n\n// ---------------------------------------------------------------------------\n// DX helpers\n// ---------------------------------------------------------------------------\n\nimport type { GatewayEnvelope } from \"./types/index.js\";\nimport type { AutolinkValidationError } from \"./errors.js\";\n\n/** Unwraps a GatewayEnvelope and returns the data directly */\nexport function unwrap<T>(envelope: GatewayEnvelope<T>): T {\n return envelope.data;\n}\n\n/** Returns field-level validation errors for a given field name */\nexport function getFieldErrors(\n error: AutolinkValidationError,\n field: string,\n): string[] {\n return error.fields[field] ?? [];\n}\n\nexport {\n GATEWAY_BASE_URL,\n GATEWAY_URL,\n SDK_VERSION,\n} from \"./transport/constants.js\";\n\nexport type { AutolinkCache } from \"./cache/index.js\";\nexport { MemoryCache } from \"./cache/index.js\";\n"],"mappings":";AAAO,IAAM,mBAAmB;AACzB,IAAM,sBAAsB;AAC5B,IAAM,cAAc,GAAG,gBAAgB,QAAQ,mBAAmB;AAElE,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAC/B,IAAM,cAAc;;;ACNpB,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,MAAc,WAAmB;AAC5D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,oBAAN,cAAgC,cAAc;AAAA,EACnD,YAAY,SAAiB,WAAmB;AAC9C,UAAM,SAAS,wBAAwB,SAAS;AAChD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,yBAAN,cAAqC,cAAc;AAAA,EACxD,YAAY,SAAiB,WAAmB;AAC9C,UAAM,SAAS,aAAa,SAAS;AACrC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,wBAAN,cAAoC,cAAc;AAAA,EACvD,YAAY,SAAiB,WAAmB;AAC9C,UAAM,SAAS,aAAa,SAAS;AACrC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,0BAAN,cAAsC,cAAc;AAAA,EAChD;AAAA,EAET,YACE,SACA,WACA,SAAmC,CAAC,GACpC;AACA,UAAM,SAAS,oBAAoB,SAAS;AAC5C,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,yBAAN,cAAqC,cAAc;AAAA,EAC/C;AAAA,EAET,YAAY,SAAiB,WAAmB,YAAoB;AAClE,UAAM,SAAS,gBAAgB,SAAS;AACxC,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AACF;AAEO,IAAM,uBAAN,cAAmC,cAAc;AAAA,EAC7C;AAAA,EAET,YAAY,SAAiB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c;AAEb,IAAM,cAAN,MAA2C;AAAA,EACxC,QAAQ,oBAAI,IAAwB;AAAA,EAE5C,IAAI,KAAsB;AACxB,UAAM,QAAQ,KAAK,MAAM,IAAI,GAAG;AAChC,QAAI,CAAC,MAAO,QAAO;AACnB,QAAI,MAAM,cAAc,QAAQ,KAAK,IAAI,IAAI,MAAM,WAAW;AAC5D,WAAK,MAAM,OAAO,GAAG;AACrB,aAAO;AAAA,IACT;AACA,WAAO,MAAM;AAAA,EACf;AAAA,EAEA,IAAI,KAAa,OAAgB,YAA2B;AAE1D,QAAI,KAAK,MAAM,QAAQ,eAAe,CAAC,KAAK,MAAM,IAAI,GAAG,GAAG;AAC1D,YAAM,YAAY,KAAK,MAAM,KAAK,EAAE,KAAK,EAAE;AAC3C,UAAI,cAAc,QAAW;AAC3B,aAAK,MAAM,OAAO,SAAS;AAAA,MAC7B;AAAA,IACF;AACA,SAAK,MAAM,IAAI,KAAK;AAAA,MAClB;AAAA,MACA,WAAW,cAAc,OAAO,KAAK,IAAI,IAAI,aAAa,MAAO;AAAA,IACnE,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,KAAmB;AACxB,SAAK,MAAM,OAAO,GAAG;AAAA,EACvB;AAAA;AAAA,EAGA,eAAqB;AACnB,UAAM,MAAM,KAAK,IAAI;AACrB,eAAW,CAAC,KAAK,KAAK,KAAK,KAAK,OAAO;AACrC,UAAI,MAAM,cAAc,QAAQ,MAAM,MAAM,WAAW;AACrD,aAAK,MAAM,OAAO,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACF;;;ACZO,SAAS,OAAU,UAAiC;AACzD,SAAO,SAAS;AAClB;AAGO,SAAS,eACd,OACA,OACU;AACV,SAAO,MAAM,OAAO,KAAK,KAAK,CAAC;AACjC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@autolink/sdk",
3
+ "version": "0.2.0",
4
+ "description": "Official Autolink SDK for Node.js — server-side inventory, inquiries, and dealer data",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest",
23
+ "typecheck": "tsc --noEmit",
24
+ "lint": "eslint src",
25
+ "clean": "rm -rf dist"
26
+ },
27
+ "devDependencies": {
28
+ "tsup": "^8.3.5",
29
+ "vitest": "^2.1.8",
30
+ "msw": "^2.6.8",
31
+ "@types/node": "^22.10.5",
32
+ "typescript": "^5.7.3"
33
+ },
34
+ "engines": {
35
+ "node": ">=20"
36
+ },
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/Autolinkventures/autolink-node"
41
+ },
42
+ "keywords": [
43
+ "autolink",
44
+ "sdk",
45
+ "inventory",
46
+ "dealership",
47
+ "kenya"
48
+ ]
49
+ }