blocket.js 1.0.2 → 1.0.4

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,9 @@
1
+ import type { FetchOptions } from 'ofetch';
2
+ import type { BlocketQueryParams, BlocketAd } from '../types';
3
+ /**
4
+ * Find ads on Blocket based on query parameters.
5
+ * @param query Blocket query parameters.
6
+ * @param fetchOptions Additional fetch options.
7
+ * @returns Array of Blocket ads.
8
+ */
9
+ export declare function find(query: BlocketQueryParams, fetchOptions?: FetchOptions<'json', any>): Promise<BlocketAd[]>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.find = find;
13
+ const request_1 = require("./request");
14
+ const config_1 = require("../config");
15
+ /**
16
+ * Remap BlocketQueryParams to API query parameters.
17
+ * @param params Blocket query parameters.
18
+ * @returns Remapped query parameters.
19
+ */
20
+ function remapQueryParams(params) {
21
+ return {
22
+ q: params.query,
23
+ lim: params.limit,
24
+ sort: params.sort,
25
+ st: params.listingType,
26
+ status: params.status,
27
+ gl: params.gl,
28
+ include: params.include,
29
+ };
30
+ }
31
+ /**
32
+ * Find ads on Blocket based on query parameters.
33
+ * @param query Blocket query parameters.
34
+ * @param fetchOptions Additional fetch options.
35
+ * @returns Array of Blocket ads.
36
+ */
37
+ function find(query, fetchOptions) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const config = (0, config_1.getConfig)();
40
+ const response = yield (0, request_1.apiRequest)(config.apiBaseUrl, Object.assign({ query: remapQueryParams(query) }, fetchOptions));
41
+ if (!response || !response.data || !Array.isArray(response.data)) {
42
+ throw new Error(`Unexpected Blocket API response structure, expected array of ads, got: ${typeof (response === null || response === void 0 ? void 0 : response.data)}`);
43
+ }
44
+ return response.data;
45
+ });
46
+ }
47
+ /**
48
+ * Get details of a specific ad by its ID.
49
+ * @param adId Advertisement ID.
50
+ * @param fetchOptions Additional fetch options.
51
+ * @returns Blocket ad details.
52
+ */
53
+ function getAd(adId, fetchOptions) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const config = (0, config_1.getConfig)();
56
+ const url = `${config.apiBaseUrl}/ad/${adId}`;
57
+ return yield (0, request_1.apiRequest)(url, fetchOptions);
58
+ });
59
+ }
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;AA6BA,oBAiBC;AA9CD,uCAAuC;AACvC,sCAAsC;AAKtC;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,MAA0B;IAClD,OAAO;QACL,CAAC,EAAE,MAAM,CAAC,KAAK;QACf,GAAG,EAAE,MAAM,CAAC,KAAK;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,EAAE,EAAE,MAAM,CAAC,WAAW;QACtB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAsB,IAAI,CACxB,KAAyB,EACzB,YAAwC;;QAExC,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAU,EAAkB,MAAM,CAAC,UAAU,kBAClE,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,IAC3B,YAAY,EACf,CAAC;QAEH,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACjE,MAAM,IAAI,KAAK,CACb,0EAA0E,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAA,EAAE,CAClG,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA;AAED;;;;;GAKG;AACH,SAAe,KAAK,CAClB,IAAY,EACZ,YAAwC;;QAExC,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,UAAU,OAAO,IAAI,EAAE,CAAC;QAE9C,OAAO,MAAM,IAAA,oBAAU,EAAY,GAAG,EAAE,YAAY,CAAC,CAAC;IACxD,CAAC;CAAA"}
@@ -0,0 +1,9 @@
1
+ import { type FetchOptions } from 'ofetch';
2
+ /**
3
+ * Make an API request with automatic token handling and retry on 401 errors.
4
+ * @param url URL to fetch.
5
+ * @param options Fetch options.
6
+ * @param retryCount Current retry count.
7
+ * @returns Parsed response of type T.
8
+ */
9
+ export declare function apiRequest<T>(url: string, options?: FetchOptions<'json', any>, retryCount?: number): Promise<T>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.apiRequest = apiRequest;
13
+ const ofetch_1 = require("ofetch");
14
+ const token_1 = require("./token");
15
+ const config_1 = require("../config");
16
+ /**
17
+ * Make an API request with automatic token handling and retry on 401 errors.
18
+ * @param url URL to fetch.
19
+ * @param options Fetch options.
20
+ * @param retryCount Current retry count.
21
+ * @returns Parsed response of type T.
22
+ */
23
+ function apiRequest(url_1) {
24
+ return __awaiter(this, arguments, void 0, function* (url, options = {}, retryCount = 0) {
25
+ var _a;
26
+ const config = (0, config_1.getConfig)();
27
+ const token = yield (0, token_1.fetchToken)();
28
+ try {
29
+ return yield (0, ofetch_1.ofetch)(url, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign({}, options.headers), { Authorization: `Bearer ${token}` }) }));
30
+ }
31
+ catch (error) {
32
+ if (((_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.status_code) === 401 && retryCount < config.retryAttempts) {
33
+ (0, config_1.logger)('info', `Token expired. Retrying request (${retryCount + 1}/${config.retryAttempts}).`);
34
+ const newToken = yield (0, token_1.fetchToken)(true);
35
+ (0, token_1.setCachedToken)(newToken);
36
+ return apiRequest(url, options, retryCount + 1);
37
+ }
38
+ throw error;
39
+ }
40
+ });
41
+ }
42
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../lib/client/request.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,gCA8BC;AA1CD,mCAAmD;AAEnD,mCAAqD;AACrD,sCAA8C;AAE9C;;;;;;GAMG;AACH,SAAsB,UAAU;yDAC9B,GAAW,EACX,UAAqC,EAAE,EACvC,aAAqB,CAAC;;QAEtB,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,MAAM,IAAA,kBAAU,GAAE,CAAC;QAEjC,IAAI,CAAC;YACH,OAAO,MAAM,IAAA,eAAM,EAAI,GAAG,kCACrB,OAAO,KACV,OAAO,kCACF,OAAO,CAAC,OAAO,KAClB,aAAa,EAAE,UAAU,KAAK,EAAE,OAElC,CAAC;QACL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,0CAAE,WAAW,MAAK,GAAG,IAAI,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;gBAC1E,IAAA,eAAM,EACJ,MAAM,EACN,oCAAoC,UAAU,GAAG,CAAC,IAChD,MAAM,CAAC,aACT,IAAI,CACL,CAAC;gBACF,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;gBACxC,IAAA,sBAAc,EAAC,QAAQ,CAAC,CAAC;gBACzB,OAAO,UAAU,CAAI,GAAG,EAAE,OAAO,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Get the cached token.
3
+ * @returns Cached bearer token if available.
4
+ */
5
+ export declare const getCachedToken: () => string | null;
6
+ /**
7
+ * Set the cached token.
8
+ * @param token Bearer token.
9
+ */
10
+ export declare const setCachedToken: (token: string) => void;
11
+ /**
12
+ * Fetch a new token from Blocket API.
13
+ * @param forceRefresh If true, ignores cached token and fetches a new one.
14
+ * @returns The bearer token.
15
+ */
16
+ export declare const fetchToken: (forceRefresh?: boolean) => Promise<string>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.fetchToken = exports.setCachedToken = exports.getCachedToken = void 0;
13
+ const ofetch_1 = require("ofetch");
14
+ const config_1 = require("../config");
15
+ let cachedToken = null;
16
+ /**
17
+ * Get the cached token.
18
+ * @returns Cached bearer token if available.
19
+ */
20
+ const getCachedToken = () => cachedToken;
21
+ exports.getCachedToken = getCachedToken;
22
+ /**
23
+ * Set the cached token.
24
+ * @param token Bearer token.
25
+ */
26
+ const setCachedToken = (token) => {
27
+ cachedToken = token;
28
+ };
29
+ exports.setCachedToken = setCachedToken;
30
+ /**
31
+ * Fetch a new token from Blocket API.
32
+ * @param forceRefresh If true, ignores cached token and fetches a new one.
33
+ * @returns The bearer token.
34
+ */
35
+ const fetchToken = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (forceRefresh = false) {
36
+ if (!forceRefresh && cachedToken)
37
+ return cachedToken;
38
+ (0, config_1.logger)('debug', 'Fetching new Blocket API token.');
39
+ const config = (0, config_1.getConfig)();
40
+ const tokenData = yield (0, ofetch_1.ofetch)(config.tokenEndpoint);
41
+ if (!tokenData || !tokenData.bearerToken) {
42
+ throw new Error('Failed to retrieve Blocket API token.');
43
+ }
44
+ cachedToken = tokenData.bearerToken;
45
+ return cachedToken;
46
+ });
47
+ exports.fetchToken = fetchToken;
48
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../lib/client/token.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAgC;AAEhC,sCAA8C;AAI9C,IAAI,WAAW,GAAkB,IAAI,CAAC;AAEtC;;;GAGG;AACI,MAAM,cAAc,GAAG,GAAkB,EAAE,CAAC,WAAW,CAAC;AAAlD,QAAA,cAAc,kBAAoC;AAE/D;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,KAAa,EAAQ,EAAE;IACpD,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB;AAEF;;;;GAIG;AACI,MAAM,UAAU,GAAG,YAEP,EAAE,mDADnB,eAAwB,KAAK;IAE7B,IAAI,CAAC,YAAY,IAAI,WAAW;QAAE,OAAO,WAAW,CAAC;IAErD,IAAA,eAAM,EAAC,OAAO,EAAE,iCAAiC,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;IAE3B,MAAM,SAAS,GAAG,MAAM,IAAA,eAAM,EAAqB,MAAM,CAAC,aAAa,CAAC,CAAC;IACzE,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;IACpC,OAAO,WAAW,CAAC;AACrB,CAAC,CAAA,CAAC;AAhBW,QAAA,UAAU,cAgBrB"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Configuration interface.
3
+ */
4
+ export interface BlocketConfig {
5
+ /**
6
+ * Base URL for the Blocket API.
7
+ * @default 'https://api.blocket.se/v1'
8
+ */
9
+ apiBaseUrl: string;
10
+ /**
11
+ * Endpoint URL to fetch the token.
12
+ * @default 'https://www.blocket.se/api/adout-api-route/refresh-token-and-validate-session'
13
+ */
14
+ tokenEndpoint: string;
15
+ /**
16
+ * Log level for debugging.
17
+ * Options: 'none', 'error', 'info', 'debug'
18
+ * @default 'error'
19
+ */
20
+ logLevel: 'none' | 'error' | 'info' | 'debug';
21
+ /**
22
+ * Maximum number of retry attempts on 401 error.
23
+ * @default 3
24
+ */
25
+ retryAttempts: number;
26
+ }
27
+ /**
28
+ * Default configuration.
29
+ */
30
+ export declare const defaultConfig: BlocketConfig;
31
+ /**
32
+ * Configure Blocket.js globally.
33
+ * @param config Partial configuration to override defaults.
34
+ */
35
+ export declare const configure: (config: Partial<BlocketConfig>) => void;
36
+ /**
37
+ * Get the current configuration.
38
+ * @returns The current Blocket.js configuration.
39
+ */
40
+ export declare const getConfig: () => BlocketConfig;
41
+ /**
42
+ * Simple logger function based on log level.
43
+ * @param level Log level of the message.
44
+ * @param message Message to log.
45
+ */
46
+ export declare const logger: (level: "error" | "info" | "debug", message: string) => void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = exports.getConfig = exports.configure = exports.defaultConfig = void 0;
4
+ /**
5
+ * Default configuration.
6
+ */
7
+ exports.defaultConfig = {
8
+ apiBaseUrl: 'https://api.blocket.se/v1',
9
+ tokenEndpoint: 'https://www.blocket.se/api/adout-api-route/refresh-token-and-validate-session',
10
+ logLevel: 'error',
11
+ retryAttempts: 3,
12
+ };
13
+ let currentConfig = Object.assign({}, exports.defaultConfig);
14
+ /**
15
+ * Configure Blocket.js globally.
16
+ * @param config Partial configuration to override defaults.
17
+ */
18
+ const configure = (config) => {
19
+ currentConfig = Object.assign(Object.assign({}, currentConfig), config);
20
+ };
21
+ exports.configure = configure;
22
+ /**
23
+ * Get the current configuration.
24
+ * @returns The current Blocket.js configuration.
25
+ */
26
+ const getConfig = () => currentConfig;
27
+ exports.getConfig = getConfig;
28
+ /**
29
+ * Simple logger function based on log level.
30
+ * @param level Log level of the message.
31
+ * @param message Message to log.
32
+ */
33
+ const logger = (level, message) => {
34
+ const levels = { none: 0, error: 1, info: 2, debug: 3 };
35
+ if (levels[(0, exports.getConfig)().logLevel] >= levels[level]) {
36
+ console[level === 'error' ? 'error' : 'log'](message);
37
+ }
38
+ };
39
+ exports.logger = logger;
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/config/index.ts"],"names":[],"mappings":";;;AA2BA;;GAEG;AACU,QAAA,aAAa,GAAkB;IAC1C,UAAU,EAAE,2BAA2B;IACvC,aAAa,EACX,+EAA+E;IACjF,QAAQ,EAAE,OAAO;IACjB,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF,IAAI,aAAa,qBAAuB,qBAAa,CAAE,CAAC;AAExD;;;GAGG;AACI,MAAM,SAAS,GAAG,CAAC,MAA8B,EAAQ,EAAE;IAChE,aAAa,mCAAQ,aAAa,GAAK,MAAM,CAAE,CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEF;;;GAGG;AACI,MAAM,SAAS,GAAG,GAAkB,EAAE,CAAC,aAAa,CAAC;AAA/C,QAAA,SAAS,aAAsC;AAE5D;;;;GAIG;AACI,MAAM,MAAM,GAAG,CACpB,KAAiC,EACjC,OAAe,EACT,EAAE;IACR,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACxD,IAAI,MAAM,CAAC,IAAA,iBAAS,GAAE,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;AACH,CAAC,CAAC;AARW,QAAA,MAAM,UAQjB"}
@@ -0,0 +1,4 @@
1
+ import * as client from './client';
2
+ import { configure } from './config';
3
+ export { configure };
4
+ export default client;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,qCAAqC;AAE5B,0FAFA,kBAAS,OAEA;AAClB,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Access token.
3
+ */
4
+ export type BlocketAccessToken = {
5
+ user: null;
6
+ isLoggedIn: false;
7
+ bearerToken: string;
8
+ };
9
+ /**
10
+ * Blocket API response containing an array of ads.
11
+ */
12
+ export interface BlocketResponse {
13
+ data: BlocketAd[];
14
+ }
15
+ /**
16
+ * Blocket advertisement object.
17
+ */
18
+ export interface BlocketAd {
19
+ ad_id: string;
20
+ ad_status: 'active' | 'inactive' | string;
21
+ advertiser: {
22
+ account_id: string;
23
+ contact_methods: Record<string, any>;
24
+ name: string;
25
+ public_profile: Record<string, any>;
26
+ type: 'private' | 'business';
27
+ };
28
+ body: string;
29
+ category: Record<string, any>[];
30
+ co2_text: string;
31
+ images: Record<string, any>[];
32
+ list_id: string;
33
+ list_time: string;
34
+ location: Record<string, any>[];
35
+ map_url: string;
36
+ parameter_groups: Record<string, any>[];
37
+ parameters_raw: {
38
+ is_shipping_buy_now_enabled: Record<string, any>;
39
+ shipping_enabled: Record<string, any>;
40
+ };
41
+ price: {
42
+ suffix: string;
43
+ value: number;
44
+ };
45
+ price_badge?: {
46
+ icon: Record<string, any>;
47
+ id: string;
48
+ label: string;
49
+ };
50
+ share_url: string;
51
+ state_id: string;
52
+ subject: string;
53
+ type: string;
54
+ zipcode: string;
55
+ }
56
+ /**
57
+ * Parameters for querying Blocket ads.
58
+ */
59
+ export interface BlocketQueryParams {
60
+ /**
61
+ * The search query.
62
+ * @example 'macbook air'
63
+ */
64
+ query: string;
65
+ /**
66
+ * The maximum number of results to return.
67
+ * @example 10
68
+ * @default 60
69
+ */
70
+ limit?: number;
71
+ /**
72
+ * The sorting order of the results.
73
+ * @example 'rel'
74
+ * @default 'rel'
75
+ */
76
+ sort?: 'rel';
77
+ /**
78
+ * The type of listing to search for. 's' for selling, 'b' for buying.
79
+ * @example 's'
80
+ * @default 's'
81
+ * @options 's' | 'b'
82
+ */
83
+ listingType?: 's' | 'b';
84
+ /**
85
+ * The status of the ad.
86
+ * @example 'active'
87
+ * @default 'active'
88
+ */
89
+ status?: 'active' | 'inactive' | string;
90
+ /**
91
+ * The maximum distance in kilometers from the search location.
92
+ * @example 10
93
+ */
94
+ gl?: number;
95
+ /**
96
+ * Additional filters or fields to include in the response.
97
+ * @example 'image,description'
98
+ */
99
+ include?: string;
100
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":""}
@@ -1,8 +1,8 @@
1
1
  import { apiRequest } from './request';
2
- import { getConfig } from '@/config';
2
+ import { getConfig } from '../config';
3
3
 
4
4
  import type { FetchOptions } from 'ofetch';
5
- import type { BlocketQueryParams, BlocketAd, BlocketResponse } from '@/types';
5
+ import type { BlocketQueryParams, BlocketAd, BlocketResponse } from '../types';
6
6
 
7
7
  /**
8
8
  * Remap BlocketQueryParams to API query parameters.
@@ -52,7 +52,7 @@ export async function find(
52
52
  * @param fetchOptions Additional fetch options.
53
53
  * @returns Blocket ad details.
54
54
  */
55
- export async function getAd(
55
+ async function getAd(
56
56
  adId: string,
57
57
  fetchOptions?: FetchOptions<'json', any>
58
58
  ): Promise<BlocketAd> {
@@ -1,7 +1,7 @@
1
1
  import { ofetch, type FetchOptions } from 'ofetch';
2
2
 
3
3
  import { fetchToken, setCachedToken } from './token';
4
- import { getConfig, logger } from '@/config';
4
+ import { getConfig, logger } from '../config';
5
5
 
6
6
  /**
7
7
  * Make an API request with automatic token handling and retry on 401 errors.
@@ -1,7 +1,8 @@
1
1
  import { ofetch } from 'ofetch';
2
- import { getConfig, logger } from '@/config';
3
2
 
4
- import type { BlocketAccessToken } from '@/types';
3
+ import { getConfig, logger } from '../config';
4
+
5
+ import type { BlocketAccessToken } from '../types';
5
6
 
6
7
  let cachedToken: string | null = null;
7
8
 
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "blocket.js",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A user-friendly js wrapper for blocket.se",
5
5
  "keywords": [
6
6
  "blocket",
7
7
  "javascript",
8
8
  "api",
9
9
  "wrapper",
10
- "blocket.js"
10
+ "blocket.js",
11
+ "blocket.se"
11
12
  ],
12
13
  "license": "MIT",
13
14
  "author": "Philip Rutberg <philiprutberg00@gmail.com> (https://philiprutberg.com/)",
@@ -18,7 +19,8 @@
18
19
  "lib": "lib"
19
20
  },
20
21
  "files": [
21
- "lib"
22
+ "lib",
23
+ "dist"
22
24
  ],
23
25
  "publishConfig": {
24
26
  "registry": "https://registry.npmjs.org/"