@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,3 @@
1
+ export { createPreparedMapReader, PreparedMapReader } from './preparedMapReader.js';
2
+ export { PreparedMapReadError } from './preparedMapValidation.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prepared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { createPreparedMapReader, PreparedMapReader } from './preparedMapReader.js';
2
+ export { PreparedMapReadError } from './preparedMapValidation.js';
@@ -0,0 +1,6 @@
1
+ import type { PreparedBounds, PreparedShape } from '@wovvmap/contracts';
2
+ /** Geometry checks run at receipt, alongside node validation, never per render frame.
3
+ * Hinglish: Ready buffers ek baar check/freeze honge; polygon se geometry dobara nahi banti. */
4
+ export declare const checkBounds: (value: unknown) => value is PreparedBounds;
5
+ export declare const checkPreparedShape: (value: unknown) => value is PreparedShape | null;
6
+ //# sourceMappingURL=preparedGeometryValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparedGeometryValidation.d.ts","sourceRoot":"","sources":["../../src/prepared/preparedGeometryValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAYvE;gGACgG;AAChG,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,cAMrD,CAAA;AA6DD,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,aAAa,GAAG,IAO5E,CAAA"}
@@ -0,0 +1,76 @@
1
+ import { array, finite, integer, isRecord, object, text } from './preparedMapFields.js';
2
+ const point = object({ x: finite, y: finite, z: finite });
3
+ const boundsStructure = object({ min: point, max: point });
4
+ const groupStructure = object({ start: integer, count: integer, materialIndex: integer });
5
+ const float32 = (value) => finite(value) && Math.abs(value) <= 3.4028234663852886e38;
6
+ const numericArray = array(float32);
7
+ const nullable = (check) => (value) => value === null || check(value);
8
+ /** Geometry checks run at receipt, alongside node validation, never per render frame.
9
+ * Hinglish: Ready buffers ek baar check/freeze honge; polygon se geometry dobara nahi banti. */
10
+ export const checkBounds = (value) => {
11
+ if (!boundsStructure(value))
12
+ return false;
13
+ const bounds = value;
14
+ return (bounds.min.x <= bounds.max.x && bounds.min.y <= bounds.max.y && bounds.min.z <= bounds.max.z);
15
+ };
16
+ const checkGeometry = (value) => {
17
+ if (!isRecord(value))
18
+ return false;
19
+ let vertexCount = 0;
20
+ let entryCount = 0;
21
+ return object({
22
+ positions: (positions) => {
23
+ if (!numericArray(positions) ||
24
+ !Array.isArray(positions) ||
25
+ positions.length % 3 !== 0 ||
26
+ positions.length === 0)
27
+ return false;
28
+ vertexCount = positions.length / 3;
29
+ entryCount = vertexCount;
30
+ return true;
31
+ },
32
+ normals: (normals) => numericArray(normals) && Array.isArray(normals) && normals.length === vertexCount * 3,
33
+ uvs: (uvs) => uvs === null || (numericArray(uvs) && Array.isArray(uvs) && uvs.length === vertexCount * 2),
34
+ indices: (indices) => {
35
+ if (indices === null)
36
+ return entryCount % 3 === 0;
37
+ if (!Array.isArray(indices) ||
38
+ indices.length % 3 !== 0 ||
39
+ !array((index) => integer(index) && index >= 0 && index < vertexCount)(indices))
40
+ return false;
41
+ entryCount = indices.length;
42
+ return true;
43
+ },
44
+ groups: array((group) => {
45
+ if (!groupStructure(group))
46
+ return false;
47
+ const record = group;
48
+ return (record.start >= 0 &&
49
+ record.count >= 0 &&
50
+ record.start + record.count <= entryCount &&
51
+ record.materialIndex >= 0 &&
52
+ record.materialIndex <= 1);
53
+ }),
54
+ edgePositions: (edges) => numericArray(edges) && Array.isArray(edges) && edges.length % 6 === 0,
55
+ bounds: nullable(checkBounds),
56
+ })(value);
57
+ };
58
+ const shapeStructure = object({
59
+ type: (type) => type === 'extruded' || type === 'flat',
60
+ color: text,
61
+ originalDepth: nullable(finite),
62
+ isFloorBase: (flag) => typeof flag === 'boolean',
63
+ position: point,
64
+ rotation: point,
65
+ geometry: checkGeometry,
66
+ });
67
+ export const checkPreparedShape = (value) => {
68
+ if (value === null)
69
+ return true;
70
+ if (!shapeStructure(value))
71
+ return false;
72
+ const shape = value;
73
+ return shape.type === 'flat'
74
+ ? shape.originalDepth === null
75
+ : typeof shape.originalDepth === 'number';
76
+ };
@@ -0,0 +1,36 @@
1
+ type Check = (value: unknown) => boolean;
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
3
+ export declare const text: Check;
4
+ export declare const finite: Check;
5
+ export declare const integer: Check;
6
+ export declare function array(check: Check): Check;
7
+ export declare function record(check: Check): Check;
8
+ export declare function object<T>(fields: {
9
+ [K in keyof T]-?: Check;
10
+ }): Check;
11
+ export declare const checkDepth: Check;
12
+ export declare const checkIdentity: Check;
13
+ export declare const floorFields: {
14
+ index: Check;
15
+ id: Check;
16
+ FloorName: Check;
17
+ FloorUrl: Check;
18
+ ShortName: Check;
19
+ FloorNumber: Check;
20
+ SubFloor: Check;
21
+ viewState: Check;
22
+ };
23
+ export declare const checkFloor: Check;
24
+ export declare const checkPublicNode: Check;
25
+ export declare const renderFields: {
26
+ position: Check;
27
+ floorGroups: Check;
28
+ surface: Check;
29
+ locationName: Check;
30
+ pointImage: Check;
31
+ };
32
+ export declare const checkRenderNode: Check;
33
+ export declare const checkTaxonomy: Check;
34
+ export declare function hasExactFields(value: Record<string, unknown>, fields: readonly string[]): boolean;
35
+ export {};
36
+ //# sourceMappingURL=preparedMapFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparedMapFields.d.ts","sourceRoot":"","sources":["../../src/prepared/preparedMapFields.ts"],"names":[],"mappings":"AAcA,KAAK,KAAK,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;AAIxC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzE;AAED,eAAO,MAAM,IAAI,EAAE,KAA4C,CAAA;AAC/D,eAAO,MAAM,MAAM,EAAE,KAAsE,CAAA;AAC3F,eAAO,MAAM,OAAO,EAAE,KAA2D,CAAA;AAYjF,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAOzC;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAO1C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,GAAG,KAAK,CAYpE;AAWD,eAAO,MAAM,UAAU,OAcrB,CAAA;AACF,eAAO,MAAM,aAAa,OAiBxB,CAAA;AACF,eAAO,MAAM,WAAW;;;;;;;;;CASvB,CAAA;AACD,eAAO,MAAM,UAAU,OAA4D,CAAA;AAuBnF,eAAO,MAAM,eAAe,OA0B1B,CAAA;AAYF,eAAO,MAAM,YAAY;;;;;;CAgBxB,CAAA;AACD,eAAO,MAAM,eAAe,OAAuE,CAAA;AACnG,eAAO,MAAM,aAAa,OA4BxB,CAAA;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAGjG"}
@@ -0,0 +1,205 @@
1
+ import { PREPARED_MAP_FORMAT_VERSION, } from '@wovvmap/contracts';
2
+ // Exact data-field checks freeze accepted JSON in the same visit; no second deep-clone/freeze pass.
3
+ // Hinglish: Receive hua JSON isi visit mein check/freeze hoga; raw/private extra fields reject hain.
4
+ export function isRecord(value) {
5
+ if (!value || typeof value !== 'object' || Array.isArray(value))
6
+ return false;
7
+ const prototype = Object.getPrototypeOf(value);
8
+ return prototype === Object.prototype || prototype === null;
9
+ }
10
+ export const text = (value) => typeof value === 'string';
11
+ export const finite = (value) => typeof value === 'number' && Number.isFinite(value);
12
+ export const integer = (value) => finite(value) && Number.isInteger(value);
13
+ const boolean = (value) => typeof value === 'boolean';
14
+ const id = (value) => text(value) || finite(value);
15
+ const optional = (check) => (value) => value === undefined || check(value);
16
+ const nullable = (check) => (value) => value === null || check(value);
17
+ export function array(check) {
18
+ return (value) => {
19
+ if (!Array.isArray(value))
20
+ return false;
21
+ for (const entry of value)
22
+ if (!check(entry))
23
+ return false;
24
+ Object.freeze(value);
25
+ return true;
26
+ };
27
+ }
28
+ export function record(check) {
29
+ return (value) => {
30
+ if (!isRecord(value))
31
+ return false;
32
+ for (const key of Object.keys(value))
33
+ if (!check(value[key]))
34
+ return false;
35
+ Object.freeze(value);
36
+ return true;
37
+ };
38
+ }
39
+ export function object(fields) {
40
+ const entries = Object.entries(fields);
41
+ const allowed = new Set(entries.map(([key]) => key));
42
+ return (value) => {
43
+ if (!isRecord(value))
44
+ return false;
45
+ for (const key of Object.keys(value))
46
+ if (!allowed.has(key))
47
+ return false;
48
+ for (const [key, check] of entries) {
49
+ if (!check(Object.hasOwn(value, key) ? value[key] : undefined))
50
+ return false;
51
+ }
52
+ Object.freeze(value);
53
+ return true;
54
+ };
55
+ }
56
+ const point2 = object({ x: finite, y: finite });
57
+ const point3 = object({ x: finite, y: finite, z: finite });
58
+ const camera = object({
59
+ x: finite,
60
+ y: finite,
61
+ z: finite,
62
+ zoom: optional(finite),
63
+ });
64
+ const deviceView = object({ camera, controls: point3 });
65
+ export const checkDepth = object({
66
+ floorBaseDepth: finite,
67
+ defaultUnitDepth: finite,
68
+ depthMultiplier: optional(finite),
69
+ customDepths: optional(record(finite)),
70
+ modeDepths: optional(record(object({
71
+ unitDepth: finite,
72
+ extraDepthPlane: finite,
73
+ extraDepthSprite: finite,
74
+ }))),
75
+ });
76
+ export const checkIdentity = object({
77
+ formatVersion: (value) => value === PREPARED_MAP_FORMAT_VERSION,
78
+ mallId: (value) => typeof value === 'string' && value.trim() !== '',
79
+ environment: (value) => typeof value === 'string' && value.trim() !== '',
80
+ sourceVersion: (value) => value === 'v1' || value === 'v2',
81
+ sourceRevision: (value) => typeof value === 'string' && value.trim() !== '',
82
+ preparationVersion: (value) => typeof value === 'string' && value.trim() !== '',
83
+ brandEnvironment: (value) => value === 'sit' || value === 'prod',
84
+ depthConfig: checkDepth,
85
+ validUntil: optional(finite),
86
+ shapePreparation: optional(object({
87
+ version: (value) => value === '1',
88
+ type: (value) => value === 'extruded' || value === 'flat',
89
+ scale: (value) => finite(value) && value > 0,
90
+ })),
91
+ });
92
+ export const floorFields = {
93
+ index: integer,
94
+ id: text,
95
+ FloorName: text,
96
+ FloorUrl: text,
97
+ ShortName: text,
98
+ FloorNumber: finite,
99
+ SubFloor: optional(boolean),
100
+ viewState: nullable(object({ pc: optional(deviceView), mobile: optional(deviceView) })),
101
+ };
102
+ export const checkFloor = object(floorFields);
103
+ const offer = object({
104
+ 'offer_mst.id': optional(id),
105
+ 'offer_mst.offer_name': optional(text),
106
+ offer_remark: optional(nullable(text)),
107
+ offer_short_desc: optional(nullable(text)),
108
+ 'offer_mst.valid_from': optional(id),
109
+ 'offer_mst.valid_to': optional(id),
110
+ brand_logo: optional(text),
111
+ partyc_cat_code: optional(id),
112
+ brand_code: optional(id),
113
+ brand_name: optional(text),
114
+ });
115
+ const dayHours = object({ open: optional(text), close: optional(text) });
116
+ const weeklyHours = object({
117
+ sun: optional(dayHours),
118
+ mon: optional(dayHours),
119
+ tue: optional(dayHours),
120
+ wed: optional(dayHours),
121
+ thu: optional(dayHours),
122
+ fri: optional(dayHours),
123
+ sat: optional(dayHours),
124
+ });
125
+ export const checkPublicNode = object({
126
+ key: text,
127
+ type: text,
128
+ floorIndex: integer,
129
+ floorName: text,
130
+ categoryCode: optional(id),
131
+ subCategoryCode: optional(id),
132
+ categoryName: optional(text),
133
+ subCategoryName: optional(text),
134
+ weeklyHours: optional(weeklyHours),
135
+ amenitiesId: optional(id),
136
+ offers: optional(array(offer)),
137
+ paidPromotion: optional(record((value) => finite(value) && value > 0)),
138
+ contactInfo: object({
139
+ description: text,
140
+ phone_no: text,
141
+ website: text,
142
+ email: text,
143
+ address: text,
144
+ }),
145
+ assets: object({
146
+ locationName: nullable(object({ text })),
147
+ logo: nullable(text),
148
+ brandLogo: nullable(text),
149
+ brandImages: array(text),
150
+ }),
151
+ });
152
+ const locationName = object({
153
+ text,
154
+ area: optional(point2),
155
+ pinpoint: optional(point2),
156
+ rotate: optional(finite),
157
+ textColor: optional(text),
158
+ textSize: optional(text),
159
+ textStyle: optional(text),
160
+ width: optional(finite),
161
+ height: optional(finite),
162
+ });
163
+ export const renderFields = {
164
+ position: point3,
165
+ floorGroups: object({ shapes: finite, images: finite, labels: integer }),
166
+ surface: object({ depth: finite, floorBash: boolean, shapeType: optional(text) }),
167
+ locationName: nullable(locationName),
168
+ pointImage: nullable(object({
169
+ src: text,
170
+ x: optional(finite),
171
+ y: optional(finite),
172
+ width: optional(finite),
173
+ height: optional(finite),
174
+ rotation: optional(finite),
175
+ opacity: optional(finite),
176
+ })),
177
+ };
178
+ export const checkRenderNode = object(renderFields);
179
+ export const checkTaxonomy = object({
180
+ categories: record(object({
181
+ code: id,
182
+ name: text,
183
+ image: nullable(text),
184
+ subCategoryCodes: array(id),
185
+ })),
186
+ subCategories: record(object({
187
+ code: id,
188
+ name: text,
189
+ image: nullable(text),
190
+ description: text,
191
+ categoryCode: id,
192
+ })),
193
+ amenities: record(object({
194
+ id,
195
+ fieldCode: id,
196
+ name: text,
197
+ image: nullable(text),
198
+ status: finite,
199
+ wayfindingId: optional(nullable(id)),
200
+ })),
201
+ });
202
+ export function hasExactFields(value, fields) {
203
+ const keys = Object.keys(value);
204
+ return keys.length === fields.length && fields.every((key) => Object.hasOwn(value, key));
205
+ }
@@ -0,0 +1,68 @@
1
+ import { NodePoint, type PublicMapAsset, type PreparedMapData, type PreparedMapIdentity, type PreparedRenderNode, type PublicNodeData } from '@wovvmap/contracts';
2
+ import type { CatalogIndexReadPort } from '../catalog/catalogIndexReadPort.js';
3
+ import type { IndexerContextSnapshot } from '../indexer/nodeDataIndexer.types.js';
4
+ /** Immutable, per-candidate reader over validated public records and prepared memberships.
5
+ * Takes ownership of decoded JSON. No fetch, source parser, canonical NodePoint or writable map store.
6
+ * Hinglish: Receive JSON ek baar validate/freeze hoga; React aur WebView same read-only reader use karenge. */
7
+ export declare class PreparedMapReader implements CatalogIndexReadPort {
8
+ private readonly indexes;
9
+ private readonly context;
10
+ readonly nodes: NodePoint[];
11
+ private readonly viewerNodes;
12
+ private readonly assets;
13
+ private readonly labelTexts;
14
+ private readonly displayNodes?;
15
+ constructor(candidate: unknown, expectedIdentity: PreparedMapIdentity, options?: {
16
+ signal?: AbortSignal;
17
+ renderReady?: boolean;
18
+ assetBaseUrl?: string;
19
+ assetSourceBaseUrl?: string | null;
20
+ });
21
+ private addAsset;
22
+ /** Already validated immutable packet/manifest; no second map or geometry traversal.
23
+ * Hinglish: Accepted reader ka wahi packet aur unique assets reuse hon; raw NodePoint copy nahi. */
24
+ get preparedData(): PreparedMapData;
25
+ get publicAssets(): readonly PublicMapAsset[];
26
+ get fontCharacters(): string;
27
+ get identity(): PreparedMapIdentity;
28
+ get floors(): readonly Omit<import("@wovvmap/contracts").PreparedFloor, "bounds">[];
29
+ get defaultFloor(): number;
30
+ get defaultDist(): number;
31
+ get nodeKeys(): readonly string[];
32
+ getPublicNodeByKey(key: string): PublicNodeData | undefined;
33
+ getNodeByKey(key: string): PublicNodeData | undefined;
34
+ getRenderNodeByKey(key: string): Omit<PreparedRenderNode, "shape"> | undefined;
35
+ getViewerNodeByKey(key: string): NodePoint | undefined;
36
+ get preparedFloors(): readonly PreparedMapData['floors'][number][];
37
+ getNodesByFloor(floor: number): readonly Readonly<PublicNodeData>[];
38
+ getContext(_options?: {
39
+ includeMemberships?: boolean;
40
+ }): IndexerContextSnapshot;
41
+ getStoreNodeKeys(): readonly string[];
42
+ getNodeKeysByCategory(code: string | number): readonly string[];
43
+ getNodeKeysBySubCategory(code: string | number): readonly string[];
44
+ getSubCategoryCodesByCategory(code: string | number): readonly string[];
45
+ getNodeKeysByAmenity(id: string | number): readonly string[];
46
+ getAmenityFloors(id: string | number): readonly number[];
47
+ hasAmenityOnFloor(id: string | number, floor: number): boolean;
48
+ getGroupNodeKeys(group: string): readonly string[];
49
+ getGroupIdByNodeKey(key: string): string | undefined;
50
+ getOfferNodeKeysByCategory(code: string | number): readonly string[];
51
+ getOfferNodeKeysBySubCategory(code: string | number): readonly string[];
52
+ getAllOfferNodeKeys(): readonly string[];
53
+ isIndexedStoreKey(key: string): boolean;
54
+ hasNodeInCategory(code: string | number, key: string): boolean;
55
+ hasNodeInSubCategory(code: string | number, key: string): boolean;
56
+ hasSubCategoryInCategory(code: string | number, sub: string | number): boolean;
57
+ hasNodeInAmenity(id: string | number, key: string): boolean;
58
+ hasActiveOfferOnNode(key: string): boolean;
59
+ }
60
+ /** Create a validated reader without publishing it into an active viewer.
61
+ * Hinglish: Candidate banega; existing map/catalog replace karna caller ka explicit next integration step hai. */
62
+ export declare function createPreparedMapReader(candidate: unknown, expectedIdentity: PreparedMapIdentity, options?: {
63
+ signal?: AbortSignal;
64
+ renderReady?: boolean;
65
+ assetBaseUrl?: string;
66
+ assetSourceBaseUrl?: string | null;
67
+ }): PreparedMapReader;
68
+ //# sourceMappingURL=preparedMapReader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparedMapReader.d.ts","sourceRoot":"","sources":["../../src/prepared/preparedMapReader.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,231 @@
1
+ import { NodePoint, hasActiveOffer, resolvePublicImageUrl, } from '@wovvmap/contracts';
2
+ import { readPreparedMapContent } from './preparedMapValidation.js';
3
+ const emptyKeys = Object.freeze([]);
4
+ const emptyFloors = Object.freeze([]);
5
+ const emptyNodes = Object.freeze([]);
6
+ const lookupKey = (value) => String(value).trim();
7
+ const own = (record, key) => Object.hasOwn(record, key) ? record[key] : undefined;
8
+ /** Immutable, per-candidate reader over validated public records and prepared memberships.
9
+ * Takes ownership of decoded JSON. No fetch, source parser, canonical NodePoint or writable map store.
10
+ * Hinglish: Receive JSON ek baar validate/freeze hoga; React aur WebView same read-only reader use karenge. */
11
+ export class PreparedMapReader {
12
+ indexes;
13
+ context;
14
+ nodes = [];
15
+ viewerNodes = new Map();
16
+ assets = new Map();
17
+ labelTexts = [];
18
+ displayNodes;
19
+ constructor(candidate, expectedIdentity, options) {
20
+ const image = (url) => url && options?.assetBaseUrl
21
+ ? `${options.assetBaseUrl}/images/${encodeURIComponent(new URL(resolvePublicImageUrl(url), options.assetSourceBaseUrl ?? undefined).href)}`
22
+ : url;
23
+ if (options?.assetBaseUrl)
24
+ this.displayNodes = new Map();
25
+ this.indexes = readPreparedMapContent(candidate, expectedIdentity, options?.signal, options?.renderReady, (key, details, render) => {
26
+ this.addAsset(render.pointImage?.src, true);
27
+ this.addAsset(details.assets.logo, true);
28
+ this.addAsset(details.assets.brandLogo, true);
29
+ const gallery = this.displayNodes ? [] : null;
30
+ for (const url of details.assets.brandImages) {
31
+ this.addAsset(url, false);
32
+ gallery?.push(image(url));
33
+ }
34
+ if (render.locationName?.text)
35
+ this.labelTexts.push(render.locationName.text);
36
+ if (gallery)
37
+ Object.freeze(gallery);
38
+ // Project resource URLs during the existing validation visit, never in a second node loop.
39
+ // Hinglish: Saved packet original rahe; UI aur renderer ko same local image URLs milen.
40
+ const display = this.displayNodes
41
+ ? Object.freeze({
42
+ ...details,
43
+ assets: Object.freeze({
44
+ ...details.assets,
45
+ logo: image(details.assets.logo) ?? null,
46
+ brandLogo: image(details.assets.brandLogo) ?? null,
47
+ brandImages: gallery,
48
+ }),
49
+ })
50
+ : details;
51
+ this.displayNodes?.set(key, display);
52
+ const node = createViewerNode(key, display, options?.assetBaseUrl && render.pointImage
53
+ ? {
54
+ ...render,
55
+ pointImage: { ...render.pointImage, src: image(render.pointImage.src) },
56
+ }
57
+ : render);
58
+ this.nodes.push(node);
59
+ this.viewerNodes.set(key, node);
60
+ return display;
61
+ });
62
+ this.context = prepareCatalogContext(this.indexes.content, (url) => this.addAsset(url, true), image);
63
+ }
64
+ addAsset(url, required) {
65
+ if (!url?.trim())
66
+ return;
67
+ url = resolvePublicImageUrl(url);
68
+ if (!this.assets.has(url) || required)
69
+ this.assets.set(url, Object.freeze({ url, required, kind: 'image' }));
70
+ }
71
+ /** Already validated immutable packet/manifest; no second map or geometry traversal.
72
+ * Hinglish: Accepted reader ka wahi packet aur unique assets reuse hon; raw NodePoint copy nahi. */
73
+ get preparedData() {
74
+ return this.indexes.content;
75
+ }
76
+ get publicAssets() {
77
+ return Object.freeze([...this.assets.values()]);
78
+ }
79
+ get fontCharacters() {
80
+ return [...new Set(this.labelTexts.join(''))].join('');
81
+ }
82
+ get identity() {
83
+ return this.indexes.content.identity;
84
+ }
85
+ get floors() {
86
+ return this.indexes.content.floors;
87
+ }
88
+ get defaultFloor() {
89
+ return this.indexes.content.defaultFloor;
90
+ }
91
+ get defaultDist() {
92
+ return this.indexes.content.defaultDist;
93
+ }
94
+ get nodeKeys() {
95
+ return this.indexes.content.nodeKeys;
96
+ }
97
+ getPublicNodeByKey(key) {
98
+ return this.displayNodes?.get(key) ?? own(this.indexes.content.publicNodesByKey, key);
99
+ }
100
+ getNodeByKey(key) {
101
+ return this.getPublicNodeByKey(key);
102
+ }
103
+ getRenderNodeByKey(key) {
104
+ return own(this.indexes.content.renderNodesByKey, key);
105
+ }
106
+ getViewerNodeByKey(key) {
107
+ return this.viewerNodes.get(key);
108
+ }
109
+ get preparedFloors() {
110
+ return this.indexes.content.floors;
111
+ }
112
+ getNodesByFloor(floor) {
113
+ return this.indexes.nodesByFloor.get(floor) ?? emptyNodes;
114
+ }
115
+ // Catalog consumes definitions only; full membership projections stay key-based in the reader.
116
+ // Hinglish: Catalog ko sirf definitions chahiye; har category mein public node array dobara nahi banta.
117
+ getContext(_options) {
118
+ return this.context;
119
+ }
120
+ getStoreNodeKeys() {
121
+ return this.indexes.content.memberships.storeKeys;
122
+ }
123
+ getNodeKeysByCategory(code) {
124
+ return own(this.indexes.content.memberships.byCategory, lookupKey(code)) ?? emptyKeys;
125
+ }
126
+ getNodeKeysBySubCategory(code) {
127
+ return own(this.indexes.content.memberships.bySubCategory, lookupKey(code)) ?? emptyKeys;
128
+ }
129
+ getSubCategoryCodesByCategory(code) {
130
+ return (own(this.indexes.content.memberships.subCategoriesByCategory, lookupKey(code)) ?? emptyKeys);
131
+ }
132
+ getNodeKeysByAmenity(id) {
133
+ return own(this.indexes.content.memberships.byAmenity, lookupKey(id)) ?? emptyKeys;
134
+ }
135
+ getAmenityFloors(id) {
136
+ return own(this.indexes.content.memberships.amenityFloors, lookupKey(id)) ?? emptyFloors;
137
+ }
138
+ hasAmenityOnFloor(id, floor) {
139
+ return this.indexes.amenityFloors.get(lookupKey(id))?.has(floor) ?? false;
140
+ }
141
+ getGroupNodeKeys(group) {
142
+ if (!group.trim())
143
+ return emptyKeys;
144
+ return own(this.indexes.content.memberships.byGroup, group) ?? emptyKeys;
145
+ }
146
+ getGroupIdByNodeKey(key) {
147
+ return this.indexes.groupByKey.get(key);
148
+ }
149
+ getOfferNodeKeysByCategory(code) {
150
+ return own(this.indexes.content.memberships.offersByCategory, lookupKey(code)) ?? emptyKeys;
151
+ }
152
+ getOfferNodeKeysBySubCategory(code) {
153
+ return own(this.indexes.content.memberships.offersBySubCategory, lookupKey(code)) ?? emptyKeys;
154
+ }
155
+ getAllOfferNodeKeys() {
156
+ return this.indexes.content.memberships.allOfferKeys;
157
+ }
158
+ isIndexedStoreKey(key) {
159
+ return this.indexes.storeKeys.has(key);
160
+ }
161
+ hasNodeInCategory(code, key) {
162
+ return this.indexes.categoryKeys.get(lookupKey(code))?.has(key) ?? false;
163
+ }
164
+ hasNodeInSubCategory(code, key) {
165
+ return this.indexes.subCategoryKeys.get(lookupKey(code))?.has(key) ?? false;
166
+ }
167
+ hasSubCategoryInCategory(code, sub) {
168
+ return this.indexes.subCategories.get(lookupKey(code))?.has(lookupKey(sub)) ?? false;
169
+ }
170
+ hasNodeInAmenity(id, key) {
171
+ return this.indexes.amenityKeys.get(lookupKey(id))?.has(key) ?? false;
172
+ }
173
+ hasActiveOfferOnNode(key) {
174
+ return this.indexes.offerKeys.has(key) && hasActiveOffer(this.getPublicNodeByKey(key)?.offers);
175
+ }
176
+ }
177
+ /** Create a validated reader without publishing it into an active viewer.
178
+ * Hinglish: Candidate banega; existing map/catalog replace karna caller ka explicit next integration step hai. */
179
+ export function createPreparedMapReader(candidate, expectedIdentity, options) {
180
+ return new PreparedMapReader(candidate, expectedIdentity, options);
181
+ }
182
+ /** Assemble placement records from already prepared values during the validation visit.
183
+ * Hinglish: Yahan raw source parsing/classification/shape creation nahi hai; ready fields connect hote hain. */
184
+ function createViewerNode(key, details, render) {
185
+ const node = new NodePoint();
186
+ Object.assign(node, details, render.position);
187
+ node.shapeDetail = {
188
+ shape: [],
189
+ ...render.surface,
190
+ color: render.shape?.color ?? '',
191
+ prepared: render.shape,
192
+ };
193
+ node.assets = {
194
+ ...details.assets,
195
+ locationName: render.locationName,
196
+ pointImages: render.pointImage,
197
+ };
198
+ return node;
199
+ }
200
+ function prepareCatalogContext(content, asset, image) {
201
+ const { taxonomy } = content;
202
+ const context = {
203
+ brandEnvironment: content.identity.brandEnvironment,
204
+ categories: Object.fromEntries(Object.entries(taxonomy.categories).map(([key, value]) => {
205
+ asset(value.image);
206
+ return [key, Object.freeze({ ...value, image: image(value.image) ?? undefined })];
207
+ })),
208
+ subCategories: Object.fromEntries(Object.entries(taxonomy.subCategories).map(([key, value]) => {
209
+ asset(value.image);
210
+ return [key, Object.freeze({ ...value, image: image(value.image) ?? undefined })];
211
+ })),
212
+ amenities: Object.fromEntries(Object.entries(taxonomy.amenities).map(([key, value]) => {
213
+ asset(value.image);
214
+ return [
215
+ key,
216
+ Object.freeze({
217
+ id: value.id,
218
+ fieldCode: value.fieldCode,
219
+ name: value.name,
220
+ image: image(value.image) ?? '',
221
+ status: value.status,
222
+ ...(value.wayfindingId !== undefined ? { wayfinding_id: value.wayfindingId } : {}),
223
+ }),
224
+ ];
225
+ })),
226
+ };
227
+ Object.freeze(context.categories);
228
+ Object.freeze(context.subCategories);
229
+ Object.freeze(context.amenities);
230
+ return Object.freeze(context);
231
+ }