@wovvmap/map-data 0.0.0-stage → 1.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.
Files changed (98) hide show
  1. package/README.md +65 -2
  2. package/dist/adapters/index.d.ts +12 -0
  3. package/dist/adapters/index.d.ts.map +1 -0
  4. package/dist/adapters/index.js +16 -0
  5. package/dist/adapters/sdkApiAdapter.d.ts +20 -0
  6. package/dist/adapters/sdkApiAdapter.d.ts.map +1 -0
  7. package/dist/adapters/sdkApiAdapter.js +31 -0
  8. package/dist/adapters/types.d.ts +84 -0
  9. package/dist/adapters/types.d.ts.map +1 -0
  10. package/dist/adapters/types.js +8 -0
  11. package/dist/cache/mallMapCache.types.d.ts +32 -0
  12. package/dist/cache/mallMapCache.types.d.ts.map +1 -0
  13. package/dist/cache/mallMapCache.types.js +1 -0
  14. package/dist/cache/memoryMallMapCache.d.ts +37 -0
  15. package/dist/cache/memoryMallMapCache.d.ts.map +1 -0
  16. package/dist/cache/memoryMallMapCache.js +44 -0
  17. package/dist/catalog/catalogIndexReadPort.d.ts +35 -0
  18. package/dist/catalog/catalogIndexReadPort.d.ts.map +1 -0
  19. package/dist/catalog/catalogIndexReadPort.js +1 -0
  20. package/dist/catalog/catalogReader.d.ts +496 -0
  21. package/dist/catalog/catalogReader.d.ts.map +1 -0
  22. package/dist/catalog/catalogReader.js +1799 -0
  23. package/dist/catalog/index.d.ts +9 -0
  24. package/dist/catalog/index.d.ts.map +1 -0
  25. package/dist/catalog/index.js +6 -0
  26. package/dist/catalog/offerAvailability.d.ts +25 -0
  27. package/dist/catalog/offerAvailability.d.ts.map +1 -0
  28. package/dist/catalog/offerAvailability.js +107 -0
  29. package/dist/controllers/mallController.d.ts +69 -0
  30. package/dist/controllers/mallController.d.ts.map +1 -0
  31. package/dist/controllers/mallController.js +92 -0
  32. package/dist/controllers/mallController.types.d.ts +10 -0
  33. package/dist/controllers/mallController.types.d.ts.map +1 -0
  34. package/dist/controllers/mallController.types.js +1 -0
  35. package/dist/index.d.ts +26 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +22 -0
  38. package/dist/indexer/nodeDataIndexer.types.d.ts +16 -0
  39. package/dist/indexer/nodeDataIndexer.types.d.ts.map +1 -0
  40. package/dist/indexer/nodeDataIndexer.types.js +1 -0
  41. package/dist/models/catalog.d.ts +2 -0
  42. package/dist/models/catalog.d.ts.map +1 -0
  43. package/dist/models/catalog.js +1 -0
  44. package/dist/models/floor.d.ts +16 -0
  45. package/dist/models/floor.d.ts.map +1 -0
  46. package/dist/models/floor.js +1 -0
  47. package/dist/models/mall.d.ts +29 -0
  48. package/dist/models/mall.d.ts.map +1 -0
  49. package/dist/models/mall.js +1 -0
  50. package/dist/parser/index.d.ts +3 -0
  51. package/dist/parser/index.d.ts.map +1 -0
  52. package/dist/parser/index.js +1 -0
  53. package/dist/parser/mapParser.types.d.ts +34 -0
  54. package/dist/parser/mapParser.types.d.ts.map +1 -0
  55. package/dist/parser/mapParser.types.js +1 -0
  56. package/dist/parser/mapParserService.d.ts +8 -0
  57. package/dist/parser/mapParserService.d.ts.map +1 -0
  58. package/dist/parser/mapParserService.js +61 -0
  59. package/dist/prepared/index.d.ts +3 -0
  60. package/dist/prepared/index.d.ts.map +1 -0
  61. package/dist/prepared/index.js +2 -0
  62. package/dist/prepared/preparedGeometryValidation.d.ts +6 -0
  63. package/dist/prepared/preparedGeometryValidation.d.ts.map +1 -0
  64. package/dist/prepared/preparedGeometryValidation.js +76 -0
  65. package/dist/prepared/preparedMapFields.d.ts +36 -0
  66. package/dist/prepared/preparedMapFields.d.ts.map +1 -0
  67. package/dist/prepared/preparedMapFields.js +205 -0
  68. package/dist/prepared/preparedMapReader.d.ts +68 -0
  69. package/dist/prepared/preparedMapReader.d.ts.map +1 -0
  70. package/dist/prepared/preparedMapReader.js +231 -0
  71. package/dist/prepared/preparedMapValidation.d.ts +23 -0
  72. package/dist/prepared/preparedMapValidation.d.ts.map +1 -0
  73. package/dist/prepared/preparedMapValidation.js +216 -0
  74. package/dist/search/catalogEndpointLookup.d.ts +23 -0
  75. package/dist/search/catalogEndpointLookup.d.ts.map +1 -0
  76. package/dist/search/catalogEndpointLookup.js +56 -0
  77. package/dist/search/catalogSearchService.d.ts +182 -0
  78. package/dist/search/catalogSearchService.d.ts.map +1 -0
  79. package/dist/search/catalogSearchService.js +653 -0
  80. package/dist/search/searchProfiles.d.ts +240 -0
  81. package/dist/search/searchProfiles.d.ts.map +1 -0
  82. package/dist/search/searchProfiles.js +364 -0
  83. package/dist/services/mallService.d.ts +82 -0
  84. package/dist/services/mallService.d.ts.map +1 -0
  85. package/dist/services/mallService.js +230 -0
  86. package/dist/services/mallService.types.d.ts +51 -0
  87. package/dist/services/mallService.types.d.ts.map +1 -0
  88. package/dist/services/mallService.types.js +1 -0
  89. package/dist/transport/fetchHttpClient.d.ts +25 -0
  90. package/dist/transport/fetchHttpClient.d.ts.map +1 -0
  91. package/dist/transport/fetchHttpClient.js +170 -0
  92. package/dist/transport/httpClient.types.d.ts +26 -0
  93. package/dist/transport/httpClient.types.d.ts.map +1 -0
  94. package/dist/transport/httpClient.types.js +1 -0
  95. package/dist/transport/httpTransportError.d.ts +25 -0
  96. package/dist/transport/httpTransportError.d.ts.map +1 -0
  97. package/dist/transport/httpTransportError.js +16 -0
  98. package/package.json +33 -3
@@ -0,0 +1,23 @@
1
+ import type { PreparedMapContent, PreparedMapIdentity, PreparedRenderNode, PublicNodeData } from '@wovvmap/contracts';
2
+ /** Safe boundary failure; messages never include source records, credentials or response bodies.
3
+ * Hinglish: Invalid/stale/cancelled candidate reject hoga; error mein private payload nahi aayega. */
4
+ export declare class PreparedMapReadError extends Error {
5
+ readonly code: 'INVALID_PREPARED_MAP' | 'PREPARED_IDENTITY_MISMATCH' | 'EXPIRED_PREPARED_MAP' | 'CANCELLED';
6
+ constructor(code: 'INVALID_PREPARED_MAP' | 'PREPARED_IDENTITY_MISMATCH' | 'EXPIRED_PREPARED_MAP' | 'CANCELLED');
7
+ }
8
+ export interface PreparedReadIndexes {
9
+ readonly content: PreparedMapContent;
10
+ readonly nodesByFloor: ReadonlyMap<number, readonly Readonly<PublicNodeData>[]>;
11
+ readonly storeKeys: ReadonlySet<string>;
12
+ readonly offerKeys: ReadonlySet<string>;
13
+ readonly categoryKeys: ReadonlyMap<string, ReadonlySet<string>>;
14
+ readonly subCategoryKeys: ReadonlyMap<string, ReadonlySet<string>>;
15
+ readonly amenityKeys: ReadonlyMap<string, ReadonlySet<string>>;
16
+ readonly subCategories: ReadonlyMap<string, ReadonlySet<string>>;
17
+ readonly amenityFloors: ReadonlyMap<string, ReadonlySet<number>>;
18
+ readonly groupByKey: ReadonlyMap<string, string>;
19
+ }
20
+ /** Accept only an owned decoded data draft. Validation and immutable lookup hydration share one node visit.
21
+ * Hinglish: Naye JSON ka ownership transfer hai; node ko ek baar check/freeze karo, parser dobara nahi chalao. */
22
+ export declare function readPreparedMapContent(candidate: unknown, expected: PreparedMapIdentity, signal?: AbortSignal, renderReady?: boolean, visitNode?: (key: string, details: PublicNodeData, render: PreparedRenderNode) => PublicNodeData | void): PreparedReadIndexes;
23
+ //# sourceMappingURL=preparedMapValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparedMapValidation.d.ts","sourceRoot":"","sources":["../../src/prepared/preparedMapValidation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAElB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACf,MAAM,oBAAoB,CAAA;AAiB3B;sGACsG;AACtG,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EACX,sBAAsB,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,WAAW;gBADrF,IAAI,EACX,sBAAsB,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,WAAW;CAKjG;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;IACpC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;IAC/E,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/D,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IAClE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9D,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjD;AAgCD;kHACkH;AAClH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,WAAW,EACpB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,CACV,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,kBAAkB,KACvB,cAAc,GAAG,IAAI,GACzB,mBAAmB,CAoMrB"}
@@ -0,0 +1,216 @@
1
+ import { samePreparedMapIdentity } from '@wovvmap/contracts';
2
+ import { checkBounds, checkPreparedShape } from './preparedGeometryValidation.js';
3
+ import { checkFloor, checkIdentity, checkPublicNode, checkRenderNode, checkTaxonomy, finite, hasExactFields, integer, isRecord, object, floorFields, renderFields, } from './preparedMapFields.js';
4
+ /** Safe boundary failure; messages never include source records, credentials or response bodies.
5
+ * Hinglish: Invalid/stale/cancelled candidate reject hoga; error mein private payload nahi aayega. */
6
+ export class PreparedMapReadError extends Error {
7
+ code;
8
+ constructor(code) {
9
+ super(code);
10
+ this.code = code;
11
+ this.name = 'PreparedMapReadError';
12
+ }
13
+ }
14
+ const contentFields = [
15
+ 'identity',
16
+ 'floors',
17
+ 'defaultFloor',
18
+ 'defaultDist',
19
+ 'nodeKeys',
20
+ 'publicNodesByKey',
21
+ 'taxonomy',
22
+ 'memberships',
23
+ 'renderNodesByKey',
24
+ ];
25
+ const membershipFields = [
26
+ 'storeKeys',
27
+ 'byFloor',
28
+ 'byCategory',
29
+ 'bySubCategory',
30
+ 'subCategoriesByCategory',
31
+ 'byAmenity',
32
+ 'amenityFloors',
33
+ 'byGroup',
34
+ 'offersByCategory',
35
+ 'offersBySubCategory',
36
+ 'allOfferKeys',
37
+ ];
38
+ function requireValid(condition) {
39
+ if (!condition)
40
+ throw new PreparedMapReadError('INVALID_PREPARED_MAP');
41
+ }
42
+ function checkCancellation(signal) {
43
+ if (signal?.aborted)
44
+ throw new PreparedMapReadError('CANCELLED');
45
+ }
46
+ /** Accept only an owned decoded data draft. Validation and immutable lookup hydration share one node visit.
47
+ * Hinglish: Naye JSON ka ownership transfer hai; node ko ek baar check/freeze karo, parser dobara nahi chalao. */
48
+ export function readPreparedMapContent(candidate, expected, signal, renderReady = false, visitNode) {
49
+ checkCancellation(signal);
50
+ requireValid(isRecord(candidate) && hasExactFields(candidate, contentFields));
51
+ requireValid(checkIdentity(candidate.identity));
52
+ if (candidate.identity.validUntil !== undefined &&
53
+ Date.now() >= candidate.identity.validUntil)
54
+ throw new PreparedMapReadError('EXPIRED_PREPARED_MAP');
55
+ if (renderReady)
56
+ requireValid(candidate.identity.shapePreparation);
57
+ if (!samePreparedMapIdentity(candidate.identity, expected))
58
+ throw new PreparedMapReadError('PREPARED_IDENTITY_MISMATCH');
59
+ requireValid(Array.isArray(candidate.floors) &&
60
+ integer(candidate.defaultFloor) &&
61
+ finite(candidate.defaultDist));
62
+ requireValid(checkTaxonomy(candidate.taxonomy));
63
+ const floors = new Set();
64
+ const floorCheck = renderReady
65
+ ? object({ ...floorFields, bounds: (value) => value === null || checkBounds(value) })
66
+ : checkFloor;
67
+ for (const floor of candidate.floors) {
68
+ requireValid(floorCheck(floor) && !floors.has(floor.index));
69
+ floors.add(floor.index);
70
+ }
71
+ requireValid(floors.has(candidate.defaultFloor));
72
+ requireValid(Array.isArray(candidate.nodeKeys) &&
73
+ isRecord(candidate.publicNodesByKey) &&
74
+ isRecord(candidate.renderNodesByKey));
75
+ const publicNodes = candidate.publicNodesByKey, renderNodes = candidate.renderNodesByKey;
76
+ requireValid(Object.keys(publicNodes).length === candidate.nodeKeys.length &&
77
+ Object.keys(renderNodes).length === candidate.nodeKeys.length);
78
+ const nodesByFloor = new Map();
79
+ const nodeKeys = new Set();
80
+ const renderCheck = renderReady
81
+ ? object({ ...renderFields, shape: checkPreparedShape })
82
+ : checkRenderNode;
83
+ for (const key of candidate.nodeKeys) {
84
+ checkCancellation(signal);
85
+ requireValid(typeof key === 'string' && key !== '' && !nodeKeys.has(key));
86
+ requireValid(Object.hasOwn(publicNodes, key) && Object.hasOwn(renderNodes, key));
87
+ const node = publicNodes[key], render = renderNodes[key];
88
+ requireValid(checkPublicNode(node) && renderCheck(render));
89
+ const details = node;
90
+ requireValid(details.key === key && floors.has(details.floorIndex));
91
+ requireValid(render.floorGroups.labels ===
92
+ details.floorIndex);
93
+ nodeKeys.add(key);
94
+ let floorNodes = nodesByFloor.get(details.floorIndex);
95
+ if (!floorNodes)
96
+ nodesByFloor.set(details.floorIndex, (floorNodes = []));
97
+ let display = details;
98
+ if (renderReady) {
99
+ const ready = render;
100
+ requireValid(ready.shape === null ||
101
+ ready.shape.type === candidate.identity.shapePreparation?.type);
102
+ display = visitNode?.(key, details, ready) ?? details;
103
+ }
104
+ floorNodes.push(display);
105
+ }
106
+ requireValid(isRecord(candidate.memberships) && hasExactFields(candidate.memberships, membershipFields));
107
+ const memberships = candidate.memberships;
108
+ // Membership validation builds only lookup sets/reverse references, never new classifications or NodePoints.
109
+ // Hinglish: Server ki ready keys use hoti hain; sirf reference check aur O(1) lookup sets yahan bante hain.
110
+ const readKeys = (value, visit) => {
111
+ requireValid(Array.isArray(value));
112
+ const keys = new Set();
113
+ for (const key of value) {
114
+ checkCancellation(signal);
115
+ requireValid(typeof key === 'string' && nodeKeys.has(key) && !keys.has(key));
116
+ visit?.(key);
117
+ keys.add(key);
118
+ }
119
+ Object.freeze(value);
120
+ return keys;
121
+ };
122
+ const readKeyMap = (value, visit) => {
123
+ requireValid(isRecord(value));
124
+ const groups = new Map();
125
+ for (const group of Object.keys(value))
126
+ groups.set(group, readKeys(value[group], (key) => visit?.(key, group)));
127
+ Object.freeze(value);
128
+ return groups;
129
+ };
130
+ const storeKeys = readKeys(memberships.storeKeys);
131
+ const floorPositions = new Map();
132
+ const byFloor = readKeyMap(memberships.byFloor, (key, floor) => {
133
+ requireValid(String(publicNodes[key].floorIndex) === floor);
134
+ const position = floorPositions.get(floor) ?? 0;
135
+ requireValid(nodesByFloor.get(Number(floor))?.[position]?.key === key);
136
+ floorPositions.set(floor, position + 1);
137
+ });
138
+ for (const [floor, keys] of byFloor)
139
+ requireValid(floors.has(Number(floor)) &&
140
+ String(Number(floor)) === floor &&
141
+ keys.size === (nodesByFloor.get(Number(floor))?.length ?? 0));
142
+ for (const [floor, nodes] of nodesByFloor) {
143
+ requireValid(byFloor.get(String(floor))?.size === nodes.length);
144
+ Object.freeze(nodes);
145
+ }
146
+ const categoryKeys = readKeyMap(memberships.byCategory, (key, group) => {
147
+ requireValid(storeKeys.has(key) &&
148
+ String(publicNodes[key].categoryCode).trim() === group);
149
+ });
150
+ const subCategoryKeys = readKeyMap(memberships.bySubCategory, (key, group) => {
151
+ requireValid(storeKeys.has(key) &&
152
+ String(publicNodes[key].subCategoryCode).trim() === group);
153
+ });
154
+ const subCategories = new Map();
155
+ requireValid(isRecord(memberships.subCategoriesByCategory));
156
+ for (const [category, children] of Object.entries(memberships.subCategoriesByCategory)) {
157
+ requireValid(Array.isArray(children));
158
+ const codes = new Set();
159
+ for (const child of children) {
160
+ requireValid(typeof child === 'string' && child !== '' && !codes.has(child));
161
+ codes.add(child);
162
+ }
163
+ subCategories.set(category, codes);
164
+ Object.freeze(children);
165
+ }
166
+ Object.freeze(memberships.subCategoriesByCategory);
167
+ const amenityFloors = new Map();
168
+ const amenityKeys = readKeyMap(memberships.byAmenity, (key, amenity) => {
169
+ let available = amenityFloors.get(amenity);
170
+ if (!available)
171
+ amenityFloors.set(amenity, (available = new Set()));
172
+ available.add(publicNodes[key].floorIndex);
173
+ });
174
+ requireValid(isRecord(memberships.amenityFloors));
175
+ for (const [amenity, available] of Object.entries(memberships.amenityFloors)) {
176
+ requireValid(Array.isArray(available));
177
+ const expectedFloors = amenityFloors.get(amenity);
178
+ requireValid(available.length === (expectedFloors?.size ?? 0));
179
+ let previous = -Infinity;
180
+ for (const floor of available) {
181
+ requireValid(integer(floor) && floor > previous && expectedFloors?.has(floor));
182
+ previous = floor;
183
+ }
184
+ Object.freeze(available);
185
+ }
186
+ for (const amenity of amenityFloors.keys())
187
+ requireValid(Object.hasOwn(memberships.amenityFloors, amenity));
188
+ Object.freeze(memberships.amenityFloors);
189
+ const groupByKey = new Map();
190
+ readKeyMap(memberships.byGroup, (key, group) => {
191
+ requireValid(!groupByKey.has(key));
192
+ groupByKey.set(key, group);
193
+ });
194
+ const offerKeys = readKeys(memberships.allOfferKeys, (key) => requireValid(publicNodes[key].offers?.length));
195
+ readKeyMap(memberships.offersByCategory, (key, category) => requireValid(offerKeys.has(key) && categoryKeys.get(category)?.has(key)));
196
+ readKeyMap(memberships.offersBySubCategory, (key, sub) => requireValid(offerKeys.has(key) && subCategoryKeys.get(sub)?.has(key)));
197
+ checkCancellation(signal);
198
+ Object.freeze(candidate.nodeKeys);
199
+ Object.freeze(candidate.floors);
200
+ Object.freeze(publicNodes);
201
+ Object.freeze(renderNodes);
202
+ Object.freeze(memberships);
203
+ Object.freeze(candidate);
204
+ return {
205
+ content: candidate,
206
+ nodesByFloor,
207
+ storeKeys,
208
+ offerKeys,
209
+ categoryKeys,
210
+ subCategoryKeys,
211
+ amenityKeys,
212
+ subCategories,
213
+ amenityFloors,
214
+ groupByKey,
215
+ };
216
+ }
@@ -0,0 +1,23 @@
1
+ import type { EndpointReference, EndpointContext } from '@wovvmap/contracts';
2
+ import type { CatalogSearchService } from './catalogSearchService.js';
3
+ /** Connect existing prepared indexes; no endpoint policy, extra store, API call or full-map scan.
4
+ * Hinglish: Existing catalog indexes connect hon; endpoint rules/navigation owner mein hi rahein. */
5
+ export declare function createCatalogEndpointLookup(catalog: CatalogSearchService): {
6
+ getIdentity: () => {
7
+ mallId: string;
8
+ revision: string | number;
9
+ } | null;
10
+ resolve(reference: EndpointReference, context: Required<EndpointContext>): {
11
+ availableFloors: readonly number[];
12
+ logoUrl?: string | undefined;
13
+ keys: readonly string[];
14
+ name: string;
15
+ representative: {
16
+ key: string;
17
+ floorIndex: number;
18
+ floorName: string;
19
+ type: string;
20
+ };
21
+ } | null;
22
+ };
23
+ //# sourceMappingURL=catalogEndpointLookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogEndpointLookup.d.ts","sourceRoot":"","sources":["../../src/search/catalogEndpointLookup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAC5F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE;qGACqG;AACrG,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,oBAAoB;;;;;uBAGlD,iBAAiB,WAAW,QAAQ,CAAC,eAAe,CAAC;;;;;;;;;;;;EAqC3E"}
@@ -0,0 +1,56 @@
1
+ import { CatalogReadError } from '../catalog/index.js';
2
+ /** Connect existing prepared indexes; no endpoint policy, extra store, API call or full-map scan.
3
+ * Hinglish: Existing catalog indexes connect hon; endpoint rules/navigation owner mein hi rahein. */
4
+ export function createCatalogEndpointLookup(catalog) {
5
+ return {
6
+ getIdentity: () => catalog.getRevision(),
7
+ resolve(reference, context) {
8
+ catalog.reader.assertCommittedIdentity(context);
9
+ if (reference.kind === 'group') {
10
+ const group = catalog.resolveGroupSelection({ ...reference.request, ...context });
11
+ return group
12
+ ? summary(group.selection.representative, group.keys, group.selection.name, group.selection.availableFloors)
13
+ : null;
14
+ }
15
+ if (reference.kind === 'amenity') {
16
+ // Amenity indexes include non-store nodes; the store-group resolver would drop them.
17
+ // Hinglish: Amenity mein non-store nodes bhi hain; store-group resolver yahan use na ho.
18
+ try {
19
+ const resolved = catalog.resolveDiscoveryFilter({ amenityId: reference.amenityId });
20
+ const amenity = resolved.state?.amenity;
21
+ const node = resolved.keys[0]
22
+ ? catalog.reader.getPublicNodeByKey(resolved.keys[0])
23
+ : undefined;
24
+ return amenity && node
25
+ ? {
26
+ ...summary(node, resolved.keys, amenity.name, amenity.availableFloors),
27
+ ...(amenity.image ? { logoUrl: amenity.image } : {}),
28
+ }
29
+ : null;
30
+ }
31
+ catch (error) {
32
+ if (error instanceof CatalogReadError && error.code === 'AMENITY_NOT_FOUND')
33
+ return null;
34
+ throw error;
35
+ }
36
+ }
37
+ const node = catalog.reader.getPublicNodeByKey(reference.key);
38
+ return node ? summary(node, [node.key]) : null;
39
+ },
40
+ };
41
+ }
42
+ function summary(node, keys, name = node.assets.locationName?.text ?? node.key, availableFloors = [node.floorIndex]) {
43
+ const logoUrl = node.assets.logo ?? node.assets.brandLogo;
44
+ return {
45
+ keys,
46
+ name,
47
+ representative: {
48
+ key: node.key,
49
+ floorIndex: node.floorIndex,
50
+ floorName: node.floorName,
51
+ type: node.type,
52
+ },
53
+ ...(logoUrl ? { logoUrl } : {}),
54
+ availableFloors,
55
+ };
56
+ }
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @file catalogSearchService.ts
3
+ * @description Portable catalog/search composition shared by direct viewers and private HTTP endpoint resolution.
4
+ * Composes `CatalogReader` (`@wovvmap/map-data`), prepared `SearchIndex` instances (`@wovvmap/search-core`),
5
+ * and shared WovVMap search profiles (`searchProfiles.ts`) behind a single revision-safe owner.
6
+ *
7
+ * Hinglish: Har map ka common catalog aur search owner jo `CatalogReader`, prepared `SearchIndex`
8
+ * instances aur shared `searchProfiles` ko compose karke `getCatalog` aur `search` serve karti hai.
9
+ */
10
+ import type { AmenityAvailabilityReadOptions, AmenityFloorAvailability, DiscoveryFilterRequest, CatalogGroupMembersPage, CatalogGroupMembersRequest, CatalogGroupReadOptions, CatalogPage, CatalogReadRequest, CatalogSearchQueryInput, CatalogTarget, PublicAmenityData, PublicCategoryData, PublicNodeData, PublicNodeGroupData, PublicSubCategoryData, NodeGroupSelectionData, NodeGroupSelectionRequest } from '@wovvmap/contracts';
11
+ import { CatalogReader, type CommittedCatalogSource, type PreparedCatalogCommitCandidate } from '../catalog/index.js';
12
+ import type { ParsedMapResult } from '../parser/index.js';
13
+ import type { SearchIndex } from '@wovvmap/search-core';
14
+ /**
15
+ * Construction options for `ViewerCatalogSearchService`.
16
+ *
17
+ * Hinglish: `ViewerCatalogSearchService` initialize karne ke options.
18
+ */
19
+ export interface ViewerCatalogSearchServiceOptions {
20
+ readonly parsedMap?: CommittedCatalogSource | ParsedMapResult;
21
+ readonly revision?: string | number;
22
+ readonly defaultPageLimit?: number;
23
+ readonly maxPageLimit?: number;
24
+ }
25
+ /**
26
+ * Prepared candidate catalog and search indexes ready to be committed atomically once
27
+ * both map parsing and 3D scene element population succeed.
28
+ *
29
+ * Hinglish: Prepared candidate catalog aur search indexes jo map parsing aur 3D scene population
30
+ * dono succeed hone ke baad atomically apply kiye jaate hain.
31
+ */
32
+ export interface PreparedCatalogSearchCandidate {
33
+ readonly readerCandidate: PreparedCatalogCommitCandidate;
34
+ readonly source: CommittedCatalogSource | ParsedMapResult;
35
+ readonly storeIndex: SearchIndex<PublicNodeData>;
36
+ readonly categoryIndex: SearchIndex<PublicCategoryData>;
37
+ readonly subCategoryIndex: SearchIndex<PublicSubCategoryData>;
38
+ readonly amenityIndex: SearchIndex<PublicAmenityData>;
39
+ }
40
+ /**
41
+ * Per-viewer service owning the committed catalog revision and prepared search indexes.
42
+ * Ensures search indexes are built once per committed revision (never per keystroke, floor switch,
43
+ * or camera move) and that failed or superseded map loads never corrupt the committed catalog.
44
+ *
45
+ * Hinglish: Per-viewer service jo committed catalog revision aur prepared search indexes own karti hai;
46
+ * har keystroke, floor switch ya camera move par index rebuild nahi karti aur failed/superseded map load
47
+ * par purana committed catalog safe rakhti hai.
48
+ */
49
+ export declare class CatalogSearchService {
50
+ readonly reader: CatalogReader;
51
+ private committedState;
52
+ private readonly defaultPageLimit;
53
+ private readonly maxPageLimit;
54
+ constructor(options?: ViewerCatalogSearchServiceOptions);
55
+ /**
56
+ * Prepares a candidate catalog state and all four candidate search indexes (`stores`,
57
+ * `categories`, `subcategories`, `amenities`) WITHOUT mutating `this.reader` or `this.committedState`.
58
+ * Allows callers (`WovvMapViewer`) to verify that catalog and search preparation succeeds
59
+ * before clearing or replacing old 3D scene elements.
60
+ *
61
+ * Hinglish: Active catalog ya search state ko mutate kiye bina candidate catalog aur chaaro
62
+ * search indexes prepare karta hai, taaki old 3D scene elements clear karne se pehle preparation verify ho sake.
63
+ */
64
+ prepareMapCommit(source: CommittedCatalogSource | ParsedMapResult, revision?: string | number): PreparedCatalogSearchCandidate;
65
+ /**
66
+ * Atomically swaps the active catalog and search state to a previously prepared candidate.
67
+ *
68
+ * Hinglish: Pehle se prepared candidate catalog aur search indexes ko ek saath active state me swap karta hai.
69
+ */
70
+ applyPreparedMapCommit(candidate: PreparedCatalogSearchCandidate): {
71
+ mallId: string;
72
+ revision: string | number;
73
+ };
74
+ /**
75
+ * Atomically prepares a candidate catalog state and all four candidate search indexes (`stores`,
76
+ * `categories`, `subcategories`, `amenities`) BEFORE swapping the active catalog and search state.
77
+ * If any document extraction or search index preparation step fails, both `this.reader` and
78
+ * `this.committedState` remain untouched on the previous committed map revision.
79
+ *
80
+ * Hinglish: Candidate catalog state aur chaaro candidate search indexes pehle prepare karta hai
81
+ * aur sab kuch succeed hone ke baad hi active catalog aur search state ko ek saath swap karta hai.
82
+ * Agar beech me koi bhi step fail ho to purana committed catalog aur search state safe rehta hai.
83
+ */
84
+ commitMap(source: CommittedCatalogSource | ParsedMapResult, revision?: string | number): {
85
+ mallId: string;
86
+ revision: string | number;
87
+ };
88
+ /**
89
+ * Releases the committed catalog state and clears all owned search indexes on viewer teardown.
90
+ *
91
+ * Hinglish: Viewer teardown par committed catalog aur saare owned search indexes clear karta hai.
92
+ */
93
+ clear(): void;
94
+ /**
95
+ * Returns the currently committed `{ mallId, revision }` or `null` when no map is committed.
96
+ *
97
+ * Hinglish: Currently committed `{ mallId, revision }` return karta hai (map commit na hone par `null`).
98
+ */
99
+ getRevision(): {
100
+ mallId: string;
101
+ revision: string | number;
102
+ } | null;
103
+ /**
104
+ * Reads a bounded public catalog page for `stores`, `categories`, `subcategories`, `amenities`, or `offers`.
105
+ * Uses `CatalogReader` source order when `sortBy` is omitted or `'default'`, and delegates to the prepared
106
+ * search/sort pipeline when an explicit supported sort mode is requested.
107
+ *
108
+ * Hinglish: Requested target ke liye bounded public catalog page return karta hai; default source order ke liye
109
+ * `CatalogReader` use karta hai aur explicit supported sort mode hone par prepared search/sort pipeline chalata hai.
110
+ */
111
+ getCatalog<TTarget extends CatalogTarget = CatalogTarget>(request: CatalogReadRequest<TTarget>, fallbackActiveFloorIndex?: number): CatalogPage<TTarget>;
112
+ /**
113
+ * Executes a bounded, ordered public search across `stores`, `categories`, `subcategories`, or `amenities`
114
+ * using the committed revision's prepared search indexes and canonical multi-location grouping pipeline.
115
+ *
116
+ * Hinglish: Committed revision ke prepared search indexes aur canonical grouping pipeline se
117
+ * `stores`, `categories`, `subcategories` ya `amenities` par bounded public search run karta hai.
118
+ */
119
+ search<TTarget extends CatalogTarget = CatalogTarget>(request: CatalogSearchQueryInput<TTarget>, fallbackActiveFloorIndex?: number): CatalogPage<TTarget>;
120
+ /**
121
+ * Resolves a multi-location store group summary by `groupId` from the committed catalog.
122
+ *
123
+ * Hinglish: Committed catalog se `groupId` ke aadhar par multi-location store group summary return karta hai.
124
+ */
125
+ getStoreGroupById(groupId: string, options?: CatalogGroupReadOptions): PublicNodeGroupData | null;
126
+ /**
127
+ * Reads a bounded page of `PublicNodeData` members for a multi-location store group.
128
+ * When a search `query`, `mode === 'search'`, or non-default `sortBy` is supplied, resolves
129
+ * eligible group keys from the canonical group index and evaluates/orders them through the
130
+ * prepared store `SearchIndex` (supporting fuzzy matching, field weights, paid promotions,
131
+ * and floor-proximity sorting) without scanning the full map.
132
+ *
133
+ * Hinglish: Multi-location store group ke members ka bounded public page return karta hai;
134
+ * `query` ya `sortBy` hone par canonical group index ke eligible keys par prepared store `SearchIndex`
135
+ * (fuzzy match, field weights, paid promotions aur floor sorting ke saath) run karta hai bina full-map scan ke.
136
+ */
137
+ getGroupMembers(request: CatalogGroupMembersRequest, fallbackActiveFloorIndex?: number): CatalogGroupMembersPage | null;
138
+ /** Delegate persistent category membership to the shared catalog evaluator.
139
+ * Hinglish: Filter ke liye catalog ka wahi evaluator use ho; duplicate lookup logic nahi. */
140
+ resolveDiscoveryFilter(request: DiscoveryFilterRequest, activeFloorIndex?: number): {
141
+ state: import("@wovvmap/contracts").DiscoveryState | null;
142
+ keys: readonly string[];
143
+ recommendedFloorIndex?: number | null;
144
+ };
145
+ /** Reuse the exact member-read scope, materializing only a compact public selection summary.
146
+ * Hinglish: Wahi query/filter wale keys use hon; saare public member objects banane ki zarurat nahi. */
147
+ resolveGroupSelection(request: NodeGroupSelectionRequest, fallbackActiveFloorIndex?: number): {
148
+ keys: readonly string[];
149
+ selection: NodeGroupSelectionData;
150
+ } | null;
151
+ /** Read and select share indexed eligibility; pagination affects public details, never membership.
152
+ * Hinglish: Read/select ka eligibility logic ek hai; page size sirf details ko limit karta hai. */
153
+ private resolveGroupMemberKeys;
154
+ /**
155
+ * Evaluates indexed floor availability for an amenity relative to `activeFloorIndex`.
156
+ *
157
+ * Hinglish: `activeFloorIndex` ke hisab se amenity ki floor availability return karta hai.
158
+ */
159
+ getAmenityFloorAvailability(amenityId: string | number, options?: AmenityAvailabilityReadOptions): AmenityFloorAvailability | null;
160
+ private assertValidCommittedState;
161
+ private validateTargetSortCombination;
162
+ private executeTargetSearch;
163
+ private executeStoresSearch;
164
+ /**
165
+ * Shared typed taxonomy search helper for `categories`, `subcategories`, and `amenities`.
166
+ * Reuses the cached `PreparedTaxonomySummary` (`eligibleIdSet` and `recordsById`) without copying
167
+ * membership arrays (`nodePointsKey` / `memberKeys`), and clones public summary DTOs ONLY for the
168
+ * final paginated slice (`offset` to `offset + limit`).
169
+ *
170
+ * Hinglish: `categories`, `subcategories` aur `amenities` ke liye shared typed search helper;
171
+ * ye cached `eligibleIdSet` aur `recordsById` reuse karta hai bina membership arrays copy kiye,
172
+ * aur sirf final paginated slice ke items ko clone karta hai.
173
+ */
174
+ private executeTaxonomySearch;
175
+ }
176
+ /**
177
+ * Factory creating the shared `CatalogSearchService` instance; legacy viewer options keep their public name.
178
+ *
179
+ * Hinglish: Shared catalog/search owner ki factory; existing viewer option type ka naam compatible hai.
180
+ */
181
+ export declare function createCatalogSearchService(options?: ViewerCatalogSearchServiceOptions): CatalogSearchService;
182
+ //# sourceMappingURL=catalogSearchService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogSearchService.d.ts","sourceRoot":"","sources":["../../src/search/catalogSearchService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EAExB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,EACvB,WAAW,EAGX,kBAAkB,EAClB,uBAAuB,EAGvB,aAAa,EACb,iBA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