@wovvmap/map-data 0.0.0-stage → 1.2.1
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/README.md +85 -2
- package/dist/adapters/index.d.ts +12 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +16 -0
- package/dist/adapters/sdkApiAdapter.d.ts +20 -0
- package/dist/adapters/sdkApiAdapter.d.ts.map +1 -0
- package/dist/adapters/sdkApiAdapter.js +31 -0
- package/dist/adapters/types.d.ts +84 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +8 -0
- package/dist/cache/mallMapCache.types.d.ts +32 -0
- package/dist/cache/mallMapCache.types.d.ts.map +1 -0
- package/dist/cache/mallMapCache.types.js +1 -0
- package/dist/cache/memoryMallMapCache.d.ts +37 -0
- package/dist/cache/memoryMallMapCache.d.ts.map +1 -0
- package/dist/cache/memoryMallMapCache.js +44 -0
- package/dist/catalog/catalogIndexReadPort.d.ts +35 -0
- package/dist/catalog/catalogIndexReadPort.d.ts.map +1 -0
- package/dist/catalog/catalogIndexReadPort.js +1 -0
- package/dist/catalog/catalogReader.d.ts +496 -0
- package/dist/catalog/catalogReader.d.ts.map +1 -0
- package/dist/catalog/catalogReader.js +1799 -0
- package/dist/catalog/index.d.ts +9 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +6 -0
- package/dist/catalog/offerAvailability.d.ts +25 -0
- package/dist/catalog/offerAvailability.d.ts.map +1 -0
- package/dist/catalog/offerAvailability.js +107 -0
- package/dist/controllers/mallController.d.ts +69 -0
- package/dist/controllers/mallController.d.ts.map +1 -0
- package/dist/controllers/mallController.js +92 -0
- package/dist/controllers/mallController.types.d.ts +10 -0
- package/dist/controllers/mallController.types.d.ts.map +1 -0
- package/dist/controllers/mallController.types.js +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/indexer/nodeDataIndexer.types.d.ts +16 -0
- package/dist/indexer/nodeDataIndexer.types.d.ts.map +1 -0
- package/dist/indexer/nodeDataIndexer.types.js +1 -0
- package/dist/models/catalog.d.ts +2 -0
- package/dist/models/catalog.d.ts.map +1 -0
- package/dist/models/catalog.js +1 -0
- package/dist/models/floor.d.ts +16 -0
- package/dist/models/floor.d.ts.map +1 -0
- package/dist/models/floor.js +1 -0
- package/dist/models/mall.d.ts +29 -0
- package/dist/models/mall.d.ts.map +1 -0
- package/dist/models/mall.js +1 -0
- package/dist/parser/index.d.ts +3 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +1 -0
- package/dist/parser/mapParser.types.d.ts +34 -0
- package/dist/parser/mapParser.types.d.ts.map +1 -0
- package/dist/parser/mapParser.types.js +1 -0
- package/dist/parser/mapParserService.d.ts +8 -0
- package/dist/parser/mapParserService.d.ts.map +1 -0
- package/dist/parser/mapParserService.js +61 -0
- package/dist/prepared/index.d.ts +3 -0
- package/dist/prepared/index.d.ts.map +1 -0
- package/dist/prepared/index.js +2 -0
- package/dist/prepared/preparedGeometryValidation.d.ts +6 -0
- package/dist/prepared/preparedGeometryValidation.d.ts.map +1 -0
- package/dist/prepared/preparedGeometryValidation.js +76 -0
- package/dist/prepared/preparedMapFields.d.ts +36 -0
- package/dist/prepared/preparedMapFields.d.ts.map +1 -0
- package/dist/prepared/preparedMapFields.js +205 -0
- package/dist/prepared/preparedMapReader.d.ts +68 -0
- package/dist/prepared/preparedMapReader.d.ts.map +1 -0
- package/dist/prepared/preparedMapReader.js +231 -0
- package/dist/prepared/preparedMapValidation.d.ts +23 -0
- package/dist/prepared/preparedMapValidation.d.ts.map +1 -0
- package/dist/prepared/preparedMapValidation.js +216 -0
- package/dist/search/catalogEndpointLookup.d.ts +23 -0
- package/dist/search/catalogEndpointLookup.d.ts.map +1 -0
- package/dist/search/catalogEndpointLookup.js +56 -0
- package/dist/search/catalogSearchService.d.ts +182 -0
- package/dist/search/catalogSearchService.d.ts.map +1 -0
- package/dist/search/catalogSearchService.js +653 -0
- package/dist/search/searchProfiles.d.ts +240 -0
- package/dist/search/searchProfiles.d.ts.map +1 -0
- package/dist/search/searchProfiles.js +364 -0
- package/dist/services/mallService.d.ts +82 -0
- package/dist/services/mallService.d.ts.map +1 -0
- package/dist/services/mallService.js +230 -0
- package/dist/services/mallService.types.d.ts +51 -0
- package/dist/services/mallService.types.d.ts.map +1 -0
- package/dist/services/mallService.types.js +1 -0
- package/dist/transport/fetchHttpClient.d.ts +25 -0
- package/dist/transport/fetchHttpClient.d.ts.map +1 -0
- package/dist/transport/fetchHttpClient.js +170 -0
- package/dist/transport/httpClient.types.d.ts +26 -0
- package/dist/transport/httpClient.types.d.ts.map +1 -0
- package/dist/transport/httpClient.types.js +1 -0
- package/dist/transport/httpTransportError.d.ts +25 -0
- package/dist/transport/httpTransportError.d.ts.map +1 -0
- package/dist/transport/httpTransportError.js +16 -0
- package/package.json +33 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type MallApiAdapter, type MallApiRequestOptions } from '../adapters/types.js';
|
|
2
|
+
import type { MallApiVersion, MallListResponse, MallMapData } from '../models/mall.js';
|
|
3
|
+
import type { MallServiceOptions } from './mallService.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Service managing mall map data retrieval, metadata freshness verification, and caching.
|
|
6
|
+
* Holds sensible defaults (DEFAULT_BASE_URL, DEFAULT_MALL_ENVIRONMENT) that can be overridden.
|
|
7
|
+
*
|
|
8
|
+
* Hinglish: Mall map data fetch karne, cache freshness check karne aur storage update karne ka main service layer.
|
|
9
|
+
* Default baseUrl ("http://localhost:5180") aur environment ("prod") pehle se set hain.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MallService {
|
|
12
|
+
#private;
|
|
13
|
+
private readonly cacheKeys;
|
|
14
|
+
constructor(options?: MallServiceOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Current API version ('v1' | 'v2').
|
|
17
|
+
* Hinglish: Current active API version.
|
|
18
|
+
*/
|
|
19
|
+
get version(): MallApiVersion;
|
|
20
|
+
/**
|
|
21
|
+
* Current endpoint path.
|
|
22
|
+
* Hinglish: Currently configured API endpoint path.
|
|
23
|
+
*/
|
|
24
|
+
get mallDataEndpoint(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Current active backend base URL.
|
|
27
|
+
* Hinglish: Configured base URL (default: "http://localhost:5180").
|
|
28
|
+
*/
|
|
29
|
+
get baseUrl(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Current active backend environment.
|
|
32
|
+
* Hinglish: Configured environment (default: "prod").
|
|
33
|
+
*/
|
|
34
|
+
get environment(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Updates the active backend environment ('sit' | 'prod').
|
|
37
|
+
* Hinglish: Active backend environment update karta hai ('sit' ya 'prod').
|
|
38
|
+
*/
|
|
39
|
+
setEnvironment(environment: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Current active adapter instance.
|
|
42
|
+
* Hinglish: Current active SDK API adapter.
|
|
43
|
+
*/
|
|
44
|
+
get adapter(): MallApiAdapter;
|
|
45
|
+
/**
|
|
46
|
+
* Switches the active API adapter and version.
|
|
47
|
+
* If a custom endpoint was not explicitly passed in constructor, the endpoint updates to match the version.
|
|
48
|
+
*
|
|
49
|
+
* Hinglish: API version aur adapter switch karta hai. Agar custom endpoint set nahi tha to default endpoint bhi auto-update ho jata hai.
|
|
50
|
+
*/
|
|
51
|
+
setAdapter(version: MallApiVersion, customAdapter?: MallApiAdapter): void;
|
|
52
|
+
/**
|
|
53
|
+
* Fetches active malls matching the current environment.
|
|
54
|
+
* Supports passing an AbortSignal or request options override.
|
|
55
|
+
*
|
|
56
|
+
* Hinglish: Active malls ki list fetch karta hai. Signal ya override options pass kiye ja sakte hain.
|
|
57
|
+
*/
|
|
58
|
+
getActiveMalls(optionsOrSignal?: MallApiRequestOptions | AbortSignal): Promise<MallListResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Fetches complete map data for a mall.
|
|
61
|
+
* When cache is enabled:
|
|
62
|
+
* 1. Fetches lightweight metadata.
|
|
63
|
+
* 2. Compares updatedAt with cached record.
|
|
64
|
+
* 3. Reuses cache on match, or fetches full payload and updates cache on miss/change.
|
|
65
|
+
* When cache is disabled, fetches full data directly.
|
|
66
|
+
*
|
|
67
|
+
* Hinglish: Mall ka map data load karta hai. Agar cache hai to pehle metadata ka updatedAt compare karta hai,
|
|
68
|
+
* match hone par cached data return karta hai, miss hone par pura data fetch karke cache update karta hai.
|
|
69
|
+
*/
|
|
70
|
+
getMallMapData(mallId: string, optionsOrSignal?: MallApiRequestOptions | AbortSignal): Promise<MallMapData>;
|
|
71
|
+
/**
|
|
72
|
+
* Clears cached data for a specific mall or completely resets the cache.
|
|
73
|
+
* Hinglish: Particular mall ka cache ya pura cache clear karta hai.
|
|
74
|
+
*/
|
|
75
|
+
clearCache(mallId?: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Computes the default request cache key scoped by version, source and mall ID.
|
|
78
|
+
* Hinglish: Backend/environment alag ho to same mall ka cache mix nahi hota.
|
|
79
|
+
*/
|
|
80
|
+
getCacheKey(mallId: string): string;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=mallService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mallService.d.ts","sourceRoot":"","sources":["../../src/services/mallService.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAA;AAG1B,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAI7D;;;;;;GAMG;AACH,qBAAa,WAAW;;IAUtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;gBAE/C,OAAO,GAAE,kBAAuB;IAiB5C;;;OAGG;IACH,IAAI,OAAO,IAAI,cAAc,CAE5B;IAED;;;OAGG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIzC;;;OAGG;IACH,IAAI,OAAO,IAAI,cAAc,CAE5B;IAED;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI;IAQzE;;;;;OAKG;IACG,cAAc,CAClB,eAAe,CAAC,EAAE,qBAAqB,GAAG,WAAW,GACpD,OAAO,CAAC,gBAAgB,CAAC;IAiB5B;;;;;;;;;;OAUG;IACG,cAAc,CAClB,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,qBAAqB,GAAG,WAAW,GACpD,OAAO,CAAC,WAAW,CAAC;IAwFvB;;;OAGG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhD;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAapC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { PREPARED_MAP_PREPARATION_VERSION } from '@wovvmap/contracts';
|
|
2
|
+
import { getAdapter } from '../adapters/index.js';
|
|
3
|
+
import { DEFAULT_BASE_URL, DEFAULT_MALL_ENVIRONMENT, DEFAULT_V1_ENDPOINT, } from '../adapters/types.js';
|
|
4
|
+
import { MemoryMallMapCache } from '../cache/memoryMallMapCache.js';
|
|
5
|
+
const DEFAULT_CACHE_PREFIX = 'mall-';
|
|
6
|
+
/**
|
|
7
|
+
* Service managing mall map data retrieval, metadata freshness verification, and caching.
|
|
8
|
+
* Holds sensible defaults (DEFAULT_BASE_URL, DEFAULT_MALL_ENVIRONMENT) that can be overridden.
|
|
9
|
+
*
|
|
10
|
+
* Hinglish: Mall map data fetch karne, cache freshness check karne aur storage update karne ka main service layer.
|
|
11
|
+
* Default baseUrl ("http://localhost:5180") aur environment ("prod") pehle se set hain.
|
|
12
|
+
*/
|
|
13
|
+
export class MallService {
|
|
14
|
+
#baseUrl;
|
|
15
|
+
#cachePrefix;
|
|
16
|
+
#cache;
|
|
17
|
+
#customEndpointProvided;
|
|
18
|
+
#environment;
|
|
19
|
+
#version;
|
|
20
|
+
#endpoint;
|
|
21
|
+
#adapter;
|
|
22
|
+
cacheKeys = new Map();
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.#baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
25
|
+
this.#environment = options.environment ?? DEFAULT_MALL_ENVIRONMENT;
|
|
26
|
+
this.#cachePrefix = options.cachePrefix ?? DEFAULT_CACHE_PREFIX;
|
|
27
|
+
this.#version = options.version ?? 'v1';
|
|
28
|
+
this.#adapter = options.adapter ?? getAdapter(this.#version);
|
|
29
|
+
this.#cache = options.cache === undefined ? new MemoryMallMapCache() : options.cache;
|
|
30
|
+
if (options.mallDataEndpoint) {
|
|
31
|
+
this.#endpoint = options.mallDataEndpoint;
|
|
32
|
+
this.#customEndpointProvided = true;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.#endpoint = this.#adapter.defaultEndpoint ?? DEFAULT_V1_ENDPOINT;
|
|
36
|
+
this.#customEndpointProvided = false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Current API version ('v1' | 'v2').
|
|
41
|
+
* Hinglish: Current active API version.
|
|
42
|
+
*/
|
|
43
|
+
get version() {
|
|
44
|
+
return this.#version;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Current endpoint path.
|
|
48
|
+
* Hinglish: Currently configured API endpoint path.
|
|
49
|
+
*/
|
|
50
|
+
get mallDataEndpoint() {
|
|
51
|
+
return this.#endpoint;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Current active backend base URL.
|
|
55
|
+
* Hinglish: Configured base URL (default: "http://localhost:5180").
|
|
56
|
+
*/
|
|
57
|
+
get baseUrl() {
|
|
58
|
+
return this.#baseUrl;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Current active backend environment.
|
|
62
|
+
* Hinglish: Configured environment (default: "prod").
|
|
63
|
+
*/
|
|
64
|
+
get environment() {
|
|
65
|
+
return this.#environment;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Updates the active backend environment ('sit' | 'prod').
|
|
69
|
+
* Hinglish: Active backend environment update karta hai ('sit' ya 'prod').
|
|
70
|
+
*/
|
|
71
|
+
setEnvironment(environment) {
|
|
72
|
+
this.#environment = environment;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Current active adapter instance.
|
|
76
|
+
* Hinglish: Current active SDK API adapter.
|
|
77
|
+
*/
|
|
78
|
+
get adapter() {
|
|
79
|
+
return this.#adapter;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Switches the active API adapter and version.
|
|
83
|
+
* If a custom endpoint was not explicitly passed in constructor, the endpoint updates to match the version.
|
|
84
|
+
*
|
|
85
|
+
* Hinglish: API version aur adapter switch karta hai. Agar custom endpoint set nahi tha to default endpoint bhi auto-update ho jata hai.
|
|
86
|
+
*/
|
|
87
|
+
setAdapter(version, customAdapter) {
|
|
88
|
+
this.#version = version;
|
|
89
|
+
this.#adapter = customAdapter ?? getAdapter(version);
|
|
90
|
+
if (!this.#customEndpointProvided) {
|
|
91
|
+
this.#endpoint = this.#adapter.defaultEndpoint ?? DEFAULT_V1_ENDPOINT;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Fetches active malls matching the current environment.
|
|
96
|
+
* Supports passing an AbortSignal or request options override.
|
|
97
|
+
*
|
|
98
|
+
* Hinglish: Active malls ki list fetch karta hai. Signal ya override options pass kiye ja sakte hain.
|
|
99
|
+
*/
|
|
100
|
+
async getActiveMalls(optionsOrSignal) {
|
|
101
|
+
const opts = this.#resolveRequestOptions(optionsOrSignal);
|
|
102
|
+
const adapter = opts.version && opts.version !== this.#version ? getAdapter(opts.version) : this.#adapter;
|
|
103
|
+
return adapter.fetchActiveMalls({
|
|
104
|
+
baseUrl: opts.baseUrl ?? this.#baseUrl,
|
|
105
|
+
endpoint: opts.endpoint ??
|
|
106
|
+
(opts.version && opts.version !== this.#version && !this.#customEndpointProvided
|
|
107
|
+
? (adapter.defaultEndpoint ?? DEFAULT_V1_ENDPOINT)
|
|
108
|
+
: this.#endpoint),
|
|
109
|
+
environment: opts.environment ?? this.#environment,
|
|
110
|
+
signal: opts.signal,
|
|
111
|
+
preparation: opts.preparation,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetches complete map data for a mall.
|
|
116
|
+
* When cache is enabled:
|
|
117
|
+
* 1. Fetches lightweight metadata.
|
|
118
|
+
* 2. Compares updatedAt with cached record.
|
|
119
|
+
* 3. Reuses cache on match, or fetches full payload and updates cache on miss/change.
|
|
120
|
+
* When cache is disabled, fetches full data directly.
|
|
121
|
+
*
|
|
122
|
+
* Hinglish: Mall ka map data load karta hai. Agar cache hai to pehle metadata ka updatedAt compare karta hai,
|
|
123
|
+
* match hone par cached data return karta hai, miss hone par pura data fetch karke cache update karta hai.
|
|
124
|
+
*/
|
|
125
|
+
async getMallMapData(mallId, optionsOrSignal) {
|
|
126
|
+
const trimmedId = mallId ? mallId.trim() : '';
|
|
127
|
+
if (!trimmedId) {
|
|
128
|
+
throw new Error('Mall ID is required to fetch map data');
|
|
129
|
+
}
|
|
130
|
+
const opts = this.#resolveRequestOptions(optionsOrSignal);
|
|
131
|
+
// Capture request identity before awaiting metadata; concurrent hooks may use different versions.
|
|
132
|
+
// Hinglish: Await se pehle adapter/config fix karein taaki dusri request ise badal na sake.
|
|
133
|
+
const version = opts.version ?? this.#version;
|
|
134
|
+
const adapter = version === this.#version ? this.#adapter : getAdapter(version);
|
|
135
|
+
const effectiveBaseUrl = opts.baseUrl ?? this.#baseUrl;
|
|
136
|
+
const effectiveEndpoint = opts.endpoint ??
|
|
137
|
+
(version === this.#version || this.#customEndpointProvided
|
|
138
|
+
? this.#endpoint
|
|
139
|
+
: (adapter.defaultEndpoint ?? DEFAULT_V1_ENDPOINT));
|
|
140
|
+
const effectiveEnvironment = opts.environment ?? this.#environment;
|
|
141
|
+
// Cache is enabled: check metadata updatedAt before full fetch
|
|
142
|
+
// Hinglish: Agar cache enabled hai to lightweight metadata se freshness verify karo
|
|
143
|
+
if (this.#cache) {
|
|
144
|
+
const metadataResponse = await adapter.fetchMallMetadata(trimmedId, {
|
|
145
|
+
baseUrl: effectiveBaseUrl,
|
|
146
|
+
endpoint: effectiveEndpoint,
|
|
147
|
+
environment: effectiveEnvironment,
|
|
148
|
+
signal: opts.signal,
|
|
149
|
+
preparation: opts.preparation,
|
|
150
|
+
});
|
|
151
|
+
const metadata = metadataResponse.data[0];
|
|
152
|
+
if (!metadata) {
|
|
153
|
+
throw new Error('Mall map data not found');
|
|
154
|
+
}
|
|
155
|
+
const cacheKey = `${this.#cachePrefix}${version}-${trimmedId}-${JSON.stringify([effectiveBaseUrl, effectiveEndpoint, effectiveEnvironment, opts.preparation ?? null])}`;
|
|
156
|
+
const keys = this.cacheKeys.get(trimmedId) ?? new Set();
|
|
157
|
+
keys.add(cacheKey);
|
|
158
|
+
this.cacheKeys.set(trimmedId, keys);
|
|
159
|
+
const cached = await this.#cache.get(cacheKey);
|
|
160
|
+
const packet = cached?.data_json;
|
|
161
|
+
const validUntil = packet?.identity?.validUntil;
|
|
162
|
+
if (cached &&
|
|
163
|
+
packet?.identity?.preparationVersion === PREPARED_MAP_PREPARATION_VERSION &&
|
|
164
|
+
metadata.updatedAt &&
|
|
165
|
+
cached.updatedAt === metadata.updatedAt &&
|
|
166
|
+
(validUntil === undefined || Date.now() < validUntil)) {
|
|
167
|
+
return cached;
|
|
168
|
+
}
|
|
169
|
+
const response = await adapter.fetchMallData(trimmedId, {
|
|
170
|
+
baseUrl: effectiveBaseUrl,
|
|
171
|
+
endpoint: effectiveEndpoint,
|
|
172
|
+
environment: effectiveEnvironment,
|
|
173
|
+
signal: opts.signal,
|
|
174
|
+
preparation: opts.preparation,
|
|
175
|
+
});
|
|
176
|
+
const mall = response.data[0];
|
|
177
|
+
if (!mall) {
|
|
178
|
+
throw new Error('Mall map data not found');
|
|
179
|
+
}
|
|
180
|
+
await this.#cache.set(cacheKey, mall);
|
|
181
|
+
return mall;
|
|
182
|
+
}
|
|
183
|
+
// Cache disabled: direct full fetch without extra metadata round-trip
|
|
184
|
+
// Hinglish: Cache band hai to seedha full payload mangao (extra metadata call ki zarurat nahi)
|
|
185
|
+
const response = await adapter.fetchMallData(trimmedId, {
|
|
186
|
+
baseUrl: effectiveBaseUrl,
|
|
187
|
+
endpoint: effectiveEndpoint,
|
|
188
|
+
environment: effectiveEnvironment,
|
|
189
|
+
signal: opts.signal,
|
|
190
|
+
preparation: opts.preparation,
|
|
191
|
+
});
|
|
192
|
+
const mall = response.data[0];
|
|
193
|
+
if (!mall) {
|
|
194
|
+
throw new Error('Mall map data not found');
|
|
195
|
+
}
|
|
196
|
+
return mall;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Clears cached data for a specific mall or completely resets the cache.
|
|
200
|
+
* Hinglish: Particular mall ka cache ya pura cache clear karta hai.
|
|
201
|
+
*/
|
|
202
|
+
async clearCache(mallId) {
|
|
203
|
+
if (!this.#cache)
|
|
204
|
+
return;
|
|
205
|
+
if (mallId) {
|
|
206
|
+
const id = mallId.trim();
|
|
207
|
+
await Promise.all([...(this.cacheKeys.get(id) ?? []), this.getCacheKey(id)].map((key) => this.#cache.delete(key)));
|
|
208
|
+
this.cacheKeys.delete(id);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
await this.#cache.clear();
|
|
212
|
+
this.cacheKeys.clear();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Computes the default request cache key scoped by version, source and mall ID.
|
|
217
|
+
* Hinglish: Backend/environment alag ho to same mall ka cache mix nahi hota.
|
|
218
|
+
*/
|
|
219
|
+
getCacheKey(mallId) {
|
|
220
|
+
return `${this.#cachePrefix}${this.#version}-${mallId}-${JSON.stringify([this.#baseUrl, this.#endpoint, this.#environment, null])}`;
|
|
221
|
+
}
|
|
222
|
+
#resolveRequestOptions(optionsOrSignal) {
|
|
223
|
+
if (!optionsOrSignal)
|
|
224
|
+
return {};
|
|
225
|
+
if ('aborted' in optionsOrSignal) {
|
|
226
|
+
return { signal: optionsOrSignal };
|
|
227
|
+
}
|
|
228
|
+
return optionsOrSignal;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { MallApiAdapter } from '../adapters/types.js';
|
|
2
|
+
import type { MallMapCache } from '../cache/mallMapCache.types.js';
|
|
3
|
+
import type { MallApiVersion } from '../models/mall.js';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for initializing MallService.
|
|
6
|
+
* All fields have built-in defaults (DEFAULT_BASE_URL, DEFAULT_MALL_ENVIRONMENT).
|
|
7
|
+
* Providing values will override the defaults.
|
|
8
|
+
*
|
|
9
|
+
* Hinglish: MallService ke configuration options. BaseUrl aur environment ke defaults pehle se set hain.
|
|
10
|
+
* Agar aap pass karte hain to wo default ko override kar dega.
|
|
11
|
+
*/
|
|
12
|
+
export interface MallServiceOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Base URL of the SDK delivery API (defaults to "http://localhost:5180").
|
|
15
|
+
* Hinglish: SDK API server ka base URL (default: "http://localhost:5180").
|
|
16
|
+
*/
|
|
17
|
+
readonly baseUrl?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Target environment name (defaults to "prod").
|
|
20
|
+
* Hinglish: Target environment (default: "prod").
|
|
21
|
+
*/
|
|
22
|
+
readonly environment?: string;
|
|
23
|
+
/**
|
|
24
|
+
* API adapter version ("v1" | "v2"), defaults to "v1".
|
|
25
|
+
* Hinglish: Default API version ("v1" ya "v2", default: "v1").
|
|
26
|
+
*/
|
|
27
|
+
readonly version?: MallApiVersion;
|
|
28
|
+
/**
|
|
29
|
+
* Optional custom mall endpoint path (defaults to /api/mall-datas for v1, /api/mall-data-v2s for v2).
|
|
30
|
+
* Hinglish: Custom endpoint path (default: v1 ke liye /api/mall-datas, v2 ke liye /api/mall-data-v2s).
|
|
31
|
+
*/
|
|
32
|
+
readonly mallDataEndpoint?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional custom adapter implementing MallApiAdapter.
|
|
35
|
+
* Hinglish: Custom adapter implementation.
|
|
36
|
+
*/
|
|
37
|
+
readonly adapter?: MallApiAdapter;
|
|
38
|
+
/**
|
|
39
|
+
* Optional cache implementation (defaults to in-memory cache).
|
|
40
|
+
* Pass null to explicitly disable caching and always fetch full data directly.
|
|
41
|
+
*
|
|
42
|
+
* Hinglish: Optional cache instance (default in-memory cache). Null pass karne par cache disable ho jata hai.
|
|
43
|
+
*/
|
|
44
|
+
readonly cache?: MallMapCache | null;
|
|
45
|
+
/**
|
|
46
|
+
* Prefix used for cache keys (defaults to "mall-").
|
|
47
|
+
* Hinglish: Cache key ka prefix (default: "mall-").
|
|
48
|
+
*/
|
|
49
|
+
readonly cachePrefix?: string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=mallService.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mallService.types.d.ts","sourceRoot":"","sources":["../../src/services/mallService.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEzB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAE7B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;IAEjC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAElC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAEpC;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HttpClient, HttpRequestOptions } from './httpClient.types.js';
|
|
2
|
+
export type FetchFunction = typeof globalThis.fetch;
|
|
3
|
+
/**
|
|
4
|
+
* Fetch-specific adapter for the framework-neutral HttpClient port.
|
|
5
|
+
* Handles timeouts, cancellation (AbortSignal), and safe response reading.
|
|
6
|
+
*
|
|
7
|
+
* Hinglish: Ye class Fetch API ke through HTTP request execute karti hai; timeout aur cancel handling bhi yahi hoti hai.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FetchHttpClient implements HttpClient {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(fetchImplementation?: FetchFunction, options?: {
|
|
12
|
+
defaultTimeoutMs?: number;
|
|
13
|
+
defaultHeaders?: Record<string, string>;
|
|
14
|
+
});
|
|
15
|
+
getJson<T = unknown>(url: string, options?: HttpRequestOptions): Promise<T>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Factory to create FetchHttpClient instance.
|
|
19
|
+
* Hinglish: FetchHttpClient ka instance create karne ka helper function.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createFetchHttpClient(fetchImplementation?: FetchFunction, options?: {
|
|
22
|
+
defaultTimeoutMs?: number;
|
|
23
|
+
defaultHeaders?: Record<string, string>;
|
|
24
|
+
}): HttpClient;
|
|
25
|
+
//# sourceMappingURL=fetchHttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchHttpClient.d.ts","sourceRoot":"","sources":["../../src/transport/fetchHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAKxE,MAAM,MAAM,aAAa,GAAG,OAAO,UAAU,CAAC,KAAK,CAAA;AAEnD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,UAAU;;gBAM9C,mBAAmB,GAAE,aAAgC,EACrD,OAAO,GAAE;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAO;IAUhF,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,CAAC;CA4KtF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,mBAAmB,CAAC,EAAE,aAAa,EACnC,OAAO,CAAC,EAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC/E,UAAU,CAEZ"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { HttpTransportError } from './httpTransportError.js';
|
|
2
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
3
|
+
/**
|
|
4
|
+
* Fetch-specific adapter for the framework-neutral HttpClient port.
|
|
5
|
+
* Handles timeouts, cancellation (AbortSignal), and safe response reading.
|
|
6
|
+
*
|
|
7
|
+
* Hinglish: Ye class Fetch API ke through HTTP request execute karti hai; timeout aur cancel handling bhi yahi hoti hai.
|
|
8
|
+
*/
|
|
9
|
+
export class FetchHttpClient {
|
|
10
|
+
#fetchImplementation;
|
|
11
|
+
#defaultTimeoutMs;
|
|
12
|
+
#defaultHeaders;
|
|
13
|
+
constructor(fetchImplementation = globalThis.fetch, options = {}) {
|
|
14
|
+
// English: Ensure fetch is invoked with globalThis receiver to avoid Illegal invocation error in browsers
|
|
15
|
+
// Hinglish: Browser me 'Illegal invocation' error se bachne ke liye fetch ko globalThis receiver ke saath call karte hain
|
|
16
|
+
this.#fetchImplementation = (input, init) => (fetchImplementation ?? globalThis.fetch).call(globalThis, input, init);
|
|
17
|
+
this.#defaultTimeoutMs = options.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
18
|
+
this.#defaultHeaders = { ...options.defaultHeaders };
|
|
19
|
+
}
|
|
20
|
+
async getJson(url, options = {}) {
|
|
21
|
+
const requestTarget = sanitizeUrlForDiagnostics(url);
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const callerSignal = options.signal;
|
|
24
|
+
if (callerSignal?.aborted) {
|
|
25
|
+
throw new HttpTransportError('Map data request was cancelled by caller.', {
|
|
26
|
+
code: 'REQUEST_ABORTED',
|
|
27
|
+
requestTarget,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const onCallerAbort = () => controller.abort();
|
|
31
|
+
callerSignal?.addEventListener('abort', onCallerAbort, { once: true });
|
|
32
|
+
const timeoutDuration = options.timeoutMs ?? this.#defaultTimeoutMs;
|
|
33
|
+
let timedOut = false;
|
|
34
|
+
const timeoutId = setTimeout(() => {
|
|
35
|
+
timedOut = true;
|
|
36
|
+
controller.abort();
|
|
37
|
+
}, timeoutDuration);
|
|
38
|
+
try {
|
|
39
|
+
const headers = new Headers({
|
|
40
|
+
accept: 'application/json',
|
|
41
|
+
...this.#defaultHeaders,
|
|
42
|
+
...options.headers,
|
|
43
|
+
});
|
|
44
|
+
const response = await this.#awaitLifecycle(this.#fetchImplementation(url, {
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers,
|
|
47
|
+
signal: controller.signal,
|
|
48
|
+
}), controller, requestTarget, () => timedOut, timeoutDuration);
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
let message = `Map data request failed with HTTP ${response.status}.`;
|
|
51
|
+
try {
|
|
52
|
+
const errorBody = (await this.#awaitLifecycle(response.json(), controller, requestTarget, () => timedOut, timeoutDuration));
|
|
53
|
+
if (errorBody?.error?.message) {
|
|
54
|
+
message = errorBody.error.message;
|
|
55
|
+
}
|
|
56
|
+
else if (errorBody?.message) {
|
|
57
|
+
message = errorBody.message;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof HttpTransportError)
|
|
62
|
+
throw error;
|
|
63
|
+
// Ignore JSON parse error on failed responses / Error body parse na ho to default message rahega
|
|
64
|
+
}
|
|
65
|
+
throw new HttpTransportError(message, {
|
|
66
|
+
code: 'HTTP_STATUS_FAILURE',
|
|
67
|
+
requestTarget,
|
|
68
|
+
status: response.status,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
return (await this.#awaitLifecycle(response.json(), controller, requestTarget, () => timedOut, timeoutDuration));
|
|
73
|
+
}
|
|
74
|
+
catch (jsonErr) {
|
|
75
|
+
if (jsonErr instanceof HttpTransportError)
|
|
76
|
+
throw jsonErr;
|
|
77
|
+
throw new HttpTransportError('Map data response was not valid JSON.', {
|
|
78
|
+
code: 'INVALID_JSON_RESPONSE',
|
|
79
|
+
requestTarget,
|
|
80
|
+
status: response.status,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof HttpTransportError) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
if (timedOut) {
|
|
89
|
+
throw new HttpTransportError(`Map data request timed out after ${timeoutDuration} ms.`, {
|
|
90
|
+
code: 'REQUEST_TIMEOUT',
|
|
91
|
+
requestTarget,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (callerSignal?.aborted) {
|
|
95
|
+
throw new HttpTransportError('Map data request was cancelled by caller.', {
|
|
96
|
+
code: 'REQUEST_ABORTED',
|
|
97
|
+
requestTarget,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const originalMessage = error instanceof Error ? error.message : 'Unknown network failure';
|
|
101
|
+
throw new HttpTransportError(`Map data request failed: ${originalMessage}`, {
|
|
102
|
+
code: 'NETWORK_FAILURE',
|
|
103
|
+
requestTarget,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
clearTimeout(timeoutId);
|
|
108
|
+
callerSignal?.removeEventListener('abort', onCallerAbort);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Rejects immediately when controller signal fires, even if injected fetch ignores AbortSignal.
|
|
113
|
+
* Hinglish: Agar custom fetch AbortSignal ignore bhi kare tab bhi ye wrapper turant timeout/cancel throw karta hai.
|
|
114
|
+
*/
|
|
115
|
+
#awaitLifecycle(operation, controller, requestTarget, timedOut, timeoutDuration) {
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
let settled = false;
|
|
118
|
+
const onAbort = () => {
|
|
119
|
+
if (settled)
|
|
120
|
+
return;
|
|
121
|
+
settled = true;
|
|
122
|
+
if (timedOut()) {
|
|
123
|
+
reject(new HttpTransportError(`Map data request timed out after ${timeoutDuration} ms.`, {
|
|
124
|
+
code: 'REQUEST_TIMEOUT',
|
|
125
|
+
requestTarget,
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
reject(new HttpTransportError('Map data request was cancelled by caller.', {
|
|
130
|
+
code: 'REQUEST_ABORTED',
|
|
131
|
+
requestTarget,
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
controller.signal.addEventListener('abort', onAbort, { once: true });
|
|
136
|
+
operation.then((value) => {
|
|
137
|
+
if (settled)
|
|
138
|
+
return;
|
|
139
|
+
settled = true;
|
|
140
|
+
controller.signal.removeEventListener('abort', onAbort);
|
|
141
|
+
resolve(value);
|
|
142
|
+
}, (error) => {
|
|
143
|
+
if (settled)
|
|
144
|
+
return;
|
|
145
|
+
settled = true;
|
|
146
|
+
controller.signal.removeEventListener('abort', onAbort);
|
|
147
|
+
reject(error);
|
|
148
|
+
});
|
|
149
|
+
if (controller.signal.aborted) {
|
|
150
|
+
onAbort();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Factory to create FetchHttpClient instance.
|
|
157
|
+
* Hinglish: FetchHttpClient ka instance create karne ka helper function.
|
|
158
|
+
*/
|
|
159
|
+
export function createFetchHttpClient(fetchImplementation, options) {
|
|
160
|
+
return new FetchHttpClient(fetchImplementation, options);
|
|
161
|
+
}
|
|
162
|
+
function sanitizeUrlForDiagnostics(url) {
|
|
163
|
+
try {
|
|
164
|
+
const parsed = new URL(url);
|
|
165
|
+
return `${parsed.origin}${parsed.pathname}`;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return url;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for outgoing HTTP requests.
|
|
3
|
+
* Hinglish: Outgoing HTTP request ke liye optional parameters (signal, headers, timeout).
|
|
4
|
+
*/
|
|
5
|
+
export interface HttpRequestOptions {
|
|
6
|
+
/** Optional cancellation signal / Request cancel karne ke liye AbortSignal */
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
/** Custom request headers (such as Authorization) / Custom headers jaise API tokens */
|
|
9
|
+
readonly headers?: Record<string, string>;
|
|
10
|
+
/** Timeout in milliseconds / Request timeout duration ms me */
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Portable, framework-neutral HTTP client contract.
|
|
15
|
+
* Keeps browser/Node fetch and networking details away from services and controllers.
|
|
16
|
+
*
|
|
17
|
+
* Hinglish: Framework-neutral HTTP client port. Service aur controller ko direct fetch ya browser APIs par depend nahi hona padta.
|
|
18
|
+
*/
|
|
19
|
+
export interface HttpClient {
|
|
20
|
+
/**
|
|
21
|
+
* Performs an HTTP GET request and parses JSON response.
|
|
22
|
+
* Hinglish: HTTP GET call karta hai aur JSON response parse karke return karta hai.
|
|
23
|
+
*/
|
|
24
|
+
getJson<T = unknown>(url: string, options?: HttpRequestOptions): Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=httpClient.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpClient.types.d.ts","sourceRoot":"","sources":["../../src/transport/httpClient.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CAC5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostic codes for HTTP transport failures.
|
|
3
|
+
* Hinglish: Network aur HTTP errors ke liye standard codes.
|
|
4
|
+
*/
|
|
5
|
+
export type HttpTransportErrorCode = 'HTTP_STATUS_FAILURE' | 'NETWORK_FAILURE' | 'REQUEST_TIMEOUT' | 'REQUEST_ABORTED' | 'INVALID_JSON_RESPONSE';
|
|
6
|
+
/**
|
|
7
|
+
* Details associated with an HTTP transport error.
|
|
8
|
+
* Hinglish: HTTP error ke details (status code, request URL path, code).
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpTransportErrorDetails {
|
|
11
|
+
readonly code: HttpTransportErrorCode;
|
|
12
|
+
readonly requestTarget: string;
|
|
13
|
+
readonly status?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Typed error thrown when an HTTP network, timeout, or status issue occurs.
|
|
17
|
+
* Hinglish: HTTP request fail hone par throw hone wala typed error class.
|
|
18
|
+
*/
|
|
19
|
+
export declare class HttpTransportError extends Error {
|
|
20
|
+
readonly code: HttpTransportErrorCode;
|
|
21
|
+
readonly requestTarget: string;
|
|
22
|
+
readonly status?: number;
|
|
23
|
+
constructor(message: string, details: HttpTransportErrorDetails);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=httpTransportError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpTransportError.d.ts","sourceRoot":"","sources":["../../src/transport/httpTransportError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,uBAAuB,CAAA;AAE3B;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEZ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB;CAOhE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error thrown when an HTTP network, timeout, or status issue occurs.
|
|
3
|
+
* Hinglish: HTTP request fail hone par throw hone wala typed error class.
|
|
4
|
+
*/
|
|
5
|
+
export class HttpTransportError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
requestTarget;
|
|
8
|
+
status;
|
|
9
|
+
constructor(message, details) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'HttpTransportError';
|
|
12
|
+
this.code = details.code;
|
|
13
|
+
this.requestTarget = details.requestTarget;
|
|
14
|
+
this.status = details.status;
|
|
15
|
+
}
|
|
16
|
+
}
|