@superbright/indexeddb-orm 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +5 -5
  2. package/dist/adapters/structured-store.cjs +1 -1
  3. package/dist/adapters/structured-store.cjs.map +1 -1
  4. package/dist/adapters/structured-store.d.ts +1 -1
  5. package/dist/adapters/structured-store.mjs +1 -1
  6. package/dist/adapters/structured-store.mjs.map +1 -1
  7. package/dist/adapters/zustand-store.cjs +1 -1
  8. package/dist/adapters/zustand-store.cjs.map +1 -1
  9. package/dist/adapters/zustand-store.mjs +12 -11
  10. package/dist/adapters/zustand-store.mjs.map +1 -1
  11. package/dist/base/property.d.ts +2 -2
  12. package/dist/base/unit.d.ts +12 -12
  13. package/dist/base/user.d.ts +4 -4
  14. package/dist/features/analytics/MixpanelProvider.cjs +1 -1
  15. package/dist/features/analytics/MixpanelProvider.cjs.map +1 -1
  16. package/dist/features/analytics/MixpanelProvider.mjs +22 -20
  17. package/dist/features/analytics/MixpanelProvider.mjs.map +1 -1
  18. package/dist/features/filters/transformers.cjs +2 -0
  19. package/dist/features/filters/transformers.cjs.map +1 -0
  20. package/dist/features/filters/transformers.d.ts +31 -0
  21. package/dist/features/filters/transformers.mjs +110 -0
  22. package/dist/features/filters/transformers.mjs.map +1 -0
  23. package/dist/features/units/transformers.cjs +1 -1
  24. package/dist/features/units/transformers.cjs.map +1 -1
  25. package/dist/features/units/transformers.d.ts +12 -10
  26. package/dist/features/units/transformers.mjs +42 -38
  27. package/dist/features/units/transformers.mjs.map +1 -1
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.mjs +80 -76
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/schema.cjs +1 -1
  33. package/dist/schema.cjs.map +1 -1
  34. package/dist/schema.d.ts +754 -715
  35. package/dist/schema.mjs +104 -101
  36. package/dist/schema.mjs.map +1 -1
  37. package/dist/stores/store.cjs +1 -1
  38. package/dist/stores/store.cjs.map +1 -1
  39. package/dist/stores/store.mjs +229 -240
  40. package/dist/stores/store.mjs.map +1 -1
  41. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ import type { SortBy } from "../../schema";
2
+ type RawFilters = Record<string, unknown>;
3
+ export interface FilterPreferences {
4
+ base_price: number | null;
5
+ date_availability?: string[];
6
+ qty_bedrooms?: number[];
7
+ highlights?: string[];
8
+ }
9
+ export interface UnitsSearchRequest {
10
+ limit: number;
11
+ page: number;
12
+ sortBy: SortBy;
13
+ base_price?: number | null;
14
+ date_availability?: string[];
15
+ qty_bedrooms?: number[];
16
+ highlights?: string[];
17
+ nearBuilding?: string[];
18
+ nearNeighbourhood?: string[];
19
+ }
20
+ export interface TransformUnitsSearchOptions {
21
+ defaultLimit?: number;
22
+ defaultPage?: number;
23
+ defaultSort?: SortBy;
24
+ sortParamMap?: Record<string, SortBy>;
25
+ }
26
+ export declare const transformFiltersToPreferences: (rawFilters: RawFilters) => FilterPreferences;
27
+ export declare const transformFiltersToUnitsSearchParams: (rawFilters: RawFilters, options?: TransformUnitsSearchOptions) => UnitsSearchRequest;
28
+ export declare const defaultSortParamMap: {
29
+ [x: string]: "relevance" | "newest" | "cost_low_to_high" | "cost_high_to_low";
30
+ };
31
+ export {};
@@ -0,0 +1,110 @@
1
+ const S = {
2
+ priceLowToHigh: "cost_low_to_high",
3
+ priceHighToLow: "cost_high_to_low",
4
+ cost_low_to_high: "cost_low_to_high",
5
+ cost_high_to_low: "cost_high_to_low",
6
+ newest: "newest",
7
+ relevance: "relevance"
8
+ }, F = 10, L = 1, M = "relevance", b = (t) => t != null && typeof t == "object" && "value" in t, N = (t) => Array.isArray(t) ? t.flat() : t != null ? [t] : [], h = (t) => {
9
+ const e = N(t).map((r) => {
10
+ if (r != null) {
11
+ if (typeof r == "string") return r;
12
+ if (typeof r == "number" || typeof r == "boolean")
13
+ return String(r);
14
+ }
15
+ }).filter((r) => typeof r == "string" && r.length > 0);
16
+ return e.length ? Array.from(new Set(e)) : void 0;
17
+ }, T = (t) => {
18
+ const e = N(t).map((r) => {
19
+ if (typeof r == "number" && Number.isFinite(r)) return r;
20
+ if (typeof r == "string" && r.trim() !== "") {
21
+ const o = Number.parseInt(r, 10);
22
+ return Number.isFinite(o) ? o : void 0;
23
+ }
24
+ }).filter((r) => typeof r == "number");
25
+ return e.length ? Array.from(new Set(e)) : void 0;
26
+ }, f = (t) => {
27
+ if (typeof t == "number" && Number.isFinite(t)) return t;
28
+ if (typeof t == "string" && t.trim() !== "") {
29
+ const e = Number.parseFloat(t);
30
+ if (Number.isFinite(e)) return e;
31
+ }
32
+ return null;
33
+ }, A = (t) => {
34
+ const e = t.flatMap((r) => h(r) ?? []).filter((r) => r.length > 0);
35
+ return e.length ? Array.from(new Set(e)) : void 0;
36
+ }, B = (t) => {
37
+ const e = {};
38
+ return Object.entries(t ?? {}).forEach(([r, o]) => {
39
+ if (!["page", "sortBy", "limit"].includes(r))
40
+ if (Array.isArray(o))
41
+ if (o.every((n) => b(n))) {
42
+ const n = o.map((l) => l.value);
43
+ e[r] = n.some(Array.isArray) ? n.flat() : n;
44
+ } else
45
+ e[r] = o.flat();
46
+ else b(o) ? e[r] = o.value : e[r] = r === "base_price" && o == null ? 15e3 : o;
47
+ }), e;
48
+ }, P = (t, { dropSource: e = !0 } = {}) => {
49
+ const r = { ...t };
50
+ return Object.entries(t ?? {}).forEach(([o, n]) => {
51
+ if (!Array.isArray(n)) return;
52
+ const l = n.filter((i) => b(i) && i.bodyKey);
53
+ l.length && (l.forEach((i) => {
54
+ const a = String(i.bodyKey ?? "");
55
+ if (!a || a === o) return;
56
+ const s = Array.isArray(i.value) ? i.value : i.value !== void 0 ? [i.value] : [], g = r[a], d = Array.from(
57
+ /* @__PURE__ */ new Set([
58
+ ...Array.isArray(g) ? g : g != null ? [g] : [],
59
+ ...s
60
+ ])
61
+ );
62
+ r[a] = d;
63
+ }), e && delete r[o]);
64
+ }), r;
65
+ }, O = (t, e, r) => {
66
+ if (typeof t == "string" && t.length > 0) {
67
+ const o = e[t];
68
+ if (o) return o;
69
+ if (t === "relevance" || t === "newest" || t === "cost_low_to_high" || t === "cost_high_to_low")
70
+ return t;
71
+ }
72
+ return r;
73
+ }, U = (t) => {
74
+ const e = B(P(t)), r = A([
75
+ e.date_availability
76
+ ]), o = T(e.qty_bedrooms);
77
+ return {
78
+ base_price: f(e.base_price),
79
+ date_availability: r,
80
+ qty_bedrooms: o,
81
+ highlights: h(e.highlights)
82
+ };
83
+ }, v = (t, e = {}) => {
84
+ const { defaultLimit: r, defaultPage: o, defaultSort: n, sortParamMap: l } = e, i = { ...S, ...l ?? {} }, a = P(t), s = B(a), g = f(t.limit) ?? f(a.limit), d = f(t.page) ?? f(a.page), u = A([
85
+ s.highlights,
86
+ s.preferredEnvironment,
87
+ s.spaceUsage
88
+ ]), y = T(s.qty_bedrooms), w = f(s.base_price), p = A([
89
+ s.date_availability
90
+ ]), E = O(
91
+ t.sortBy,
92
+ i,
93
+ n ?? M
94
+ ), c = {
95
+ limit: g ?? r ?? F,
96
+ page: d ?? o ?? L,
97
+ sortBy: E
98
+ };
99
+ w != null && (c.base_price = w), p && p.length > 0 && (c.date_availability = p), y && y.length > 0 && (c.qty_bedrooms = y), u && u.length > 0 && (c.highlights = u);
100
+ const _ = h(s.nearBuilding);
101
+ _ && _.length > 0 && (c.nearBuilding = _);
102
+ const m = h(s.nearNeighbourhood);
103
+ return m && m.length > 0 && (c.nearNeighbourhood = m), c;
104
+ }, j = { ...S };
105
+ export {
106
+ j as defaultSortParamMap,
107
+ U as transformFiltersToPreferences,
108
+ v as transformFiltersToUnitsSearchParams
109
+ };
110
+ //# sourceMappingURL=transformers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformers.mjs","sources":["../../../src/features/filters/transformers.ts"],"sourcesContent":["import type { SortBy } from \"../../schema\";\n\ntype RawFilters = Record<string, unknown>;\n\nconst DEFAULT_SORT_PARAM_MAP: Record<string, SortBy> = {\n priceLowToHigh: \"cost_low_to_high\",\n priceHighToLow: \"cost_high_to_low\",\n cost_low_to_high: \"cost_low_to_high\",\n cost_high_to_low: \"cost_high_to_low\",\n newest: \"newest\",\n relevance: \"relevance\",\n};\n\nconst DEFAULT_LIMIT = 10;\nconst DEFAULT_PAGE = 1;\nconst DEFAULT_SORT: SortBy = \"relevance\";\n\nconst isObjectWithValue = (\n value: unknown,\n): value is { value: unknown; bodyKey?: unknown } =>\n value != null && typeof value === \"object\" && \"value\" in value;\n\nconst toArray = (value: unknown): unknown[] => {\n if (Array.isArray(value)) return value.flat();\n return value != null ? [value] : [];\n};\n\nconst toStringArray = (value: unknown): string[] | undefined => {\n const mapped = toArray(value)\n .map((item) => {\n if (item == null) return undefined;\n if (typeof item === \"string\") return item;\n if (typeof item === \"number\" || typeof item === \"boolean\") {\n return String(item);\n }\n return undefined;\n })\n .filter((item): item is string => typeof item === \"string\" && item.length > 0);\n return mapped.length ? Array.from(new Set(mapped)) : undefined;\n};\n\nconst toNumberArray = (value: unknown): number[] | undefined => {\n const mapped = toArray(value)\n .map((item) => {\n if (typeof item === \"number\" && Number.isFinite(item)) return item;\n if (typeof item === \"string\" && item.trim() !== \"\") {\n const parsed = Number.parseInt(item, 10);\n return Number.isFinite(parsed) ? parsed : undefined;\n }\n return undefined;\n })\n .filter((item): item is number => typeof item === \"number\");\n return mapped.length ? Array.from(new Set(mapped)) : undefined;\n};\n\nconst toNumberOrNull = (value: unknown): number | null => {\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\n if (typeof value === \"string\" && value.trim() !== \"\") {\n const parsed = Number.parseFloat(value);\n if (Number.isFinite(parsed)) return parsed;\n }\n return null;\n};\n\nconst mergeHighlightSources = (values: unknown[]): string[] | undefined => {\n const merged = values\n .flatMap((value) => toStringArray(value) ?? [])\n .filter((item) => item.length > 0);\n return merged.length ? Array.from(new Set(merged)) : undefined;\n};\n\nconst normalizeRawFilters = (filters: RawFilters): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n\n Object.entries(filters ?? {}).forEach(([key, val]) => {\n if ([\"page\", \"sortBy\", \"limit\"].includes(key)) return;\n if (Array.isArray(val)) {\n if (val.every((v) => isObjectWithValue(v))) {\n const mapped = val.map((v) => (v as { value: unknown }).value);\n result[key] = mapped.some(Array.isArray) ? mapped.flat() : mapped;\n } else {\n result[key] = val.flat();\n }\n } else if (isObjectWithValue(val)) {\n result[key] = val.value;\n } else {\n result[key] = key === \"base_price\" && val == null ? 15000 : val;\n }\n });\n\n return result;\n};\n\nconst redirectByBodyKey = (\n raw: RawFilters,\n { dropSource = true }: { dropSource?: boolean } = {},\n): Record<string, unknown> => {\n const draft: Record<string, unknown> = { ...raw };\n\n Object.entries(raw ?? {}).forEach(([prop, arr]) => {\n if (!Array.isArray(arr)) return;\n\n const items = arr.filter((it) => isObjectWithValue(it) && it.bodyKey);\n if (!items.length) return;\n\n items.forEach((it: any) => {\n const target = String(it.bodyKey ?? \"\");\n if (!target || target === prop) return;\n\n const vals = Array.isArray(it.value)\n ? it.value\n : it.value !== undefined\n ? [it.value]\n : [];\n\n const existing = draft[target];\n const merged = Array.from(\n new Set([\n ...(Array.isArray(existing)\n ? existing\n : existing != null\n ? [existing]\n : []),\n ...vals,\n ]),\n );\n\n draft[target] = merged;\n });\n\n if (dropSource) {\n delete draft[prop];\n }\n });\n\n return draft;\n};\n\nconst resolveSortBy = (\n value: unknown,\n sortParamMap: Record<string, SortBy>,\n defaultSort: SortBy,\n): SortBy => {\n if (typeof value === \"string\" && value.length > 0) {\n const mapped = sortParamMap[value];\n if (mapped) return mapped;\n if (\n value === \"relevance\" ||\n value === \"newest\" ||\n value === \"cost_low_to_high\" ||\n value === \"cost_high_to_low\"\n ) {\n return value;\n }\n }\n return defaultSort;\n};\n\nexport interface FilterPreferences {\n base_price: number | null;\n date_availability?: string[];\n qty_bedrooms?: number[];\n highlights?: string[];\n}\n\nexport interface UnitsSearchRequest {\n limit: number;\n page: number;\n sortBy: SortBy;\n base_price?: number | null;\n date_availability?: string[];\n qty_bedrooms?: number[];\n highlights?: string[];\n nearBuilding?: string[];\n nearNeighbourhood?: string[];\n}\n\nexport interface TransformUnitsSearchOptions {\n defaultLimit?: number;\n defaultPage?: number;\n defaultSort?: SortBy;\n sortParamMap?: Record<string, SortBy>;\n}\n\nexport const transformFiltersToPreferences = (\n rawFilters: RawFilters,\n): FilterPreferences => {\n const normalized = normalizeRawFilters(redirectByBodyKey(rawFilters));\n\n const mergedAvailability = mergeHighlightSources([\n normalized.date_availability,\n ]);\n const mergedBedrooms = toNumberArray(normalized.qty_bedrooms);\n const basePrice = toNumberOrNull(normalized.base_price);\n\n return {\n base_price: basePrice,\n date_availability: mergedAvailability,\n qty_bedrooms: mergedBedrooms,\n highlights: toStringArray(normalized.highlights),\n };\n};\n\nexport const transformFiltersToUnitsSearchParams = (\n rawFilters: RawFilters,\n options: TransformUnitsSearchOptions = {},\n): UnitsSearchRequest => {\n const { defaultLimit, defaultPage, defaultSort, sortParamMap } = options;\n const map = { ...DEFAULT_SORT_PARAM_MAP, ...(sortParamMap ?? {}) };\n const remapped = redirectByBodyKey(rawFilters);\n const normalized = normalizeRawFilters(remapped);\n\n const limitCandidate =\n toNumberOrNull((rawFilters as Record<string, unknown>).limit) ??\n toNumberOrNull(remapped.limit);\n const pageCandidate =\n toNumberOrNull((rawFilters as Record<string, unknown>).page) ??\n toNumberOrNull(remapped.page);\n\n const highlights = mergeHighlightSources([\n normalized.highlights,\n normalized.preferredEnvironment,\n normalized.spaceUsage,\n ]);\n const bedrooms = toNumberArray(normalized.qty_bedrooms);\n const base_price = toNumberOrNull(normalized.base_price);\n const date_availability = mergeHighlightSources([\n normalized.date_availability,\n ]);\n\n const sortBy = resolveSortBy(\n (rawFilters as Record<string, unknown>).sortBy,\n map,\n defaultSort ?? DEFAULT_SORT,\n );\n\n const payload: UnitsSearchRequest = {\n limit: limitCandidate ?? defaultLimit ?? DEFAULT_LIMIT,\n page: pageCandidate ?? defaultPage ?? DEFAULT_PAGE,\n sortBy,\n };\n\n if (base_price != null) {\n payload.base_price = base_price;\n }\n\n if (date_availability && date_availability.length > 0) {\n payload.date_availability = date_availability;\n }\n\n if (bedrooms && bedrooms.length > 0) {\n payload.qty_bedrooms = bedrooms;\n }\n\n if (highlights && highlights.length > 0) {\n payload.highlights = highlights;\n }\n\n const nearBuilding = toStringArray(normalized.nearBuilding);\n if (nearBuilding && nearBuilding.length > 0) {\n payload.nearBuilding = nearBuilding;\n }\n\n const nearNeighbourhood = toStringArray(normalized.nearNeighbourhood);\n if (nearNeighbourhood && nearNeighbourhood.length > 0) {\n payload.nearNeighbourhood = nearNeighbourhood;\n }\n\n return payload;\n};\n\nexport const defaultSortParamMap = { ...DEFAULT_SORT_PARAM_MAP };\n"],"names":["DEFAULT_SORT_PARAM_MAP","DEFAULT_LIMIT","DEFAULT_PAGE","DEFAULT_SORT","isObjectWithValue","value","toArray","toStringArray","mapped","item","toNumberArray","parsed","toNumberOrNull","mergeHighlightSources","values","merged","normalizeRawFilters","filters","result","key","val","v","redirectByBodyKey","raw","dropSource","draft","prop","arr","items","it","target","vals","existing","resolveSortBy","sortParamMap","defaultSort","transformFiltersToPreferences","rawFilters","normalized","mergedAvailability","mergedBedrooms","transformFiltersToUnitsSearchParams","options","defaultLimit","defaultPage","map","remapped","limitCandidate","pageCandidate","highlights","bedrooms","base_price","date_availability","sortBy","payload","nearBuilding","nearNeighbourhood","defaultSortParamMap"],"mappings":"AAIA,MAAMA,IAAiD;AAAA,EACrD,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,WAAW;AACb,GAEMC,IAAgB,IAChBC,IAAe,GACfC,IAAuB,aAEvBC,IAAoB,CACxBC,MAEAA,KAAS,QAAQ,OAAOA,KAAU,YAAY,WAAWA,GAErDC,IAAU,CAACD,MACX,MAAM,QAAQA,CAAK,IAAUA,EAAM,KAAA,IAChC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IAAatB,EAAoB8B,CAAQ,GAEzCC,IACJnC,EAAgByB,EAAuC,KAAK,KAC5DzB,EAAekC,EAAS,KAAK,GACzBE,IACJpC,EAAgByB,EAAuC,IAAI,KAC3DzB,EAAekC,EAAS,IAAI,GAExBG,IAAapC,EAAsB;AAAA,IACvCyB,EAAW;AAAA,IACXA,EAAW;AAAA,IACXA,EAAW;AAAA,EAAA,CACZ,GACKY,IAAWxC,EAAc4B,EAAW,YAAY,GAChDa,IAAavC,EAAe0B,EAAW,UAAU,GACjDc,IAAoBvC,EAAsB;AAAA,IAC9CyB,EAAW;AAAA,EAAA,CACZ,GAEKe,IAASpB;AAAA,IACZI,EAAuC;AAAA,IACxCQ;AAAA,IACAV,KAAehC;AAAA,EAAA,GAGXmD,IAA8B;AAAA,IAClC,OAAOP,KAAkBJ,KAAgB1C;AAAA,IACzC,MAAM+C,KAAiBJ,KAAe1C;AAAA,IACtC,QAAAmD;AAAA,EAAA;AAGF,EAAIF,KAAc,SAChBG,EAAQ,aAAaH,IAGnBC,KAAqBA,EAAkB,SAAS,MAClDE,EAAQ,oBAAoBF,IAG1BF,KAAYA,EAAS,SAAS,MAChCI,EAAQ,eAAeJ,IAGrBD,KAAcA,EAAW,SAAS,MACpCK,EAAQ,aAAaL;AAGvB,QAAMM,IAAehD,EAAc+B,EAAW,YAAY;AAC1D,EAAIiB,KAAgBA,EAAa,SAAS,MACxCD,EAAQ,eAAeC;AAGzB,QAAMC,IAAoBjD,EAAc+B,EAAW,iBAAiB;AACpE,SAAIkB,KAAqBA,EAAkB,SAAS,MAClDF,EAAQ,oBAAoBE,IAGvBF;AACT,GAEaG,IAAsB,EAAE,GAAGzD,EAAA;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c="//web.inresiapp.com",d="/placeholder.jpg",p=t=>t?t.startsWith("?")?t:`?${t}`:"",m=(t,r,e=c)=>`${e}/${r}/unit/${t}/explore`,s=(t,r=d)=>!(t!=null&&t.CFURL)||!(t!=null&&t.name)||!(t!=null&&t.signature)?r:`${t.CFURL}${t.name}${p(t.signature)}`;function v(t){return{data:t}}function y(t,r,e){var u,f;const a=(e==null?void 0:e.origin)??c,n=(e==null?void 0:e.placeholderImage)??d,l=((u=t.hits)==null?void 0:u.map(U=>{var b,h;const o=U._source??{},A=typeof o.name=="string"?o.name:typeof o.title=="string"?o.title:"";return{...o,title:A,slug:m(String(o.slug??""),r,a),imageUrl:s(o.image,n),secondaryImageUrl:s((b=o.additionalImages)==null?void 0:b[0],n),tertiaryImageUrl:s((h=o.additionalImages)==null?void 0:h[1],n)}}))??[];return{total:((f=t.total)==null?void 0:f.value)??l.length,maxScore:t.max_score??null,type:t.type??"units",hits:l}}const I={asap:"ASAP",next_month:"Next Month","2_3_months":"2-3 Months",all:"Just Browsing"},i={0:"Studio",1:"1 Bed",2:"2 Bed",3:"3+ Bed"},E=new Set(Object.values(i)),_=t=>{if(!t||t.length===0)return;const r=new Set;for(const e of t){if(typeof e=="number"){const n=i[e];n&&r.add(n);continue}const a=e.split(",").map(n=>n.trim());for(const n of a){const l=Number.parseInt(n,10);!Number.isNaN(l)&&i[l]?r.add(i[l]):E.has(n)&&r.add(n)}}return r.size>0?Array.from(r):void 0},g=t=>({availability:t.availability&&t.availability.length>0?t.availability.map(e=>I[e]??e):void 0,bedrooms:_(t.bedrooms),cost:t.cost??void 0,highlights:t.highlights??[]});exports.DEFAULT_PLACEHOLDER_IMAGE=d;exports.DEFAULT_WEB_ORIGIN=c;exports.buildExploreUrl=m;exports.buildImageUrl=s;exports.transformUnitsApiResponse=v;exports.transformUnitsApiResponseToClient=y;exports.transformUnitsApiResponseToClientFilters=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f="//web.inresiapp.com",b="/placeholder.jpg",v=t=>t?t.startsWith("?")?t:`?${t}`:"",i=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t)},I=(t,e)=>i(e.propertySlug)??i(e.property_slug)??t,p=(t,e,r=f)=>`${r}/${e}/unit/${t}/explore`,u=(t,e=b)=>!(t!=null&&t.CFURL)||!(t!=null&&t.name)||!(t!=null&&t.signature)?e:`${t.CFURL}${t.name}${v(t.signature)}`;function E(t){return{data:t}}function S(t,e,r){var y,g;const a=(r==null?void 0:r.origin)??f,o=(r==null?void 0:r.placeholderImage)??b,l=((y=t.hits)==null?void 0:y.map(h=>{var _,m;const n=h._source??{},A=typeof n.name=="string"?n.name:typeof n.title=="string"?n.title:"",U=i(n.slug)??i(n.unit_slug)??"",d=i(n.propertySlug)??i(n.property_slug)??I(e,n)??e,s={...n,title:A,slug:p(U,d??"",a),imageUrl:u(n.image,o),secondaryImageUrl:u((_=n.additionalImages)==null?void 0:_[0],o),tertiaryImageUrl:u((m=n.additionalImages)==null?void 0:m[1],o)};return(typeof s.slug!="string"||s.slug.trim()==="")&&(s.slug=p("",e??"",a)),d&&!s.propertySlug&&(s.propertySlug=d),s}))??[];return{total:((g=t.total)==null?void 0:g.value)??l.length,maxScore:t.max_score??null,type:t.type??"units",hits:l}}const L={asap:"ASAP",next_month:"Next Month","2_3_months":"2-3 Months",all:"Just Browsing"},c={0:"Studio",1:"1 Bed",2:"2 Bed",3:"3+ Bed"},C=new Set(Object.values(c)),F=t=>{if(!t||t.length===0)return;const e=new Set;for(const r of t){if(typeof r=="number"){const o=c[r];o&&e.add(o);continue}const a=r.split(",").map(o=>o.trim());for(const o of a){const l=Number.parseInt(o,10);!Number.isNaN(l)&&c[l]?e.add(c[l]):C.has(o)&&e.add(o)}}return e.size>0?Array.from(e):void 0},R=t=>({date_availability:t.date_availability&&t.date_availability.length>0?t.date_availability.map(r=>L[r]??r):void 0,qty_bedrooms:F(t.qty_bedrooms),base_price:t.base_price??void 0,highlights:t.highlights??[]});exports.DEFAULT_PLACEHOLDER_IMAGE=b;exports.DEFAULT_WEB_ORIGIN=f;exports.buildExploreUrl=p;exports.buildImageUrl=u;exports.transformUnitsApiResponse=E;exports.transformUnitsApiResponseToClient=S;exports.transformUnitsApiResponseToClientFilters=R;
2
2
  //# sourceMappingURL=transformers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformers.cjs","sources":["../../../src/features/units/transformers.ts"],"sourcesContent":["export const DEFAULT_WEB_ORIGIN = \"//web.inresiapp.com\";\nexport const DEFAULT_PLACEHOLDER_IMAGE = \"/placeholder.jpg\";\n\nexport interface UnitImageApiResponse {\n CFURL?: string;\n name?: string;\n signature?: string;\n}\n\nexport interface UnitSourceApiResponse extends Record<string, unknown> {\n id?: number | string;\n name?: string;\n title?: string;\n slug?: string;\n cost?: number;\n bedrooms?: number;\n bathrooms?: number;\n totalSqFt?: number;\n amenities?: unknown;\n highlights?: unknown;\n availability?: string | Date | null;\n image?: UnitImageApiResponse;\n additionalImages?: UnitImageApiResponse[];\n}\n\nexport interface UnitHitApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n _index?: string;\n _id?: string;\n _score?: number;\n _source?: Source;\n}\n\nexport interface UnitsTotalInfo {\n value: number;\n relation?: string;\n}\n\nexport interface UnitsDataApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total?: UnitsTotalInfo;\n max_score?: number | null;\n hits?: UnitHitApiResponse<Source>[];\n type?: string;\n}\n\nexport interface UnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n data: UnitsDataApiResponse<Source>;\n}\n\nexport type TransformedUnit<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> = Source & {\n title: string;\n slug: string;\n imageUrl: string;\n secondaryImageUrl?: string;\n tertiaryImageUrl?: string;\n};\n\nexport interface UnitsClientList<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total: number;\n maxScore: number | null;\n type: string;\n hits: TransformedUnit<Source>[];\n}\n\nexport interface TransformUnitsOptions {\n origin?: string;\n placeholderImage?: string;\n}\n\nconst normalizeSignature = (signature?: string): string => {\n if (!signature) return \"\";\n return signature.startsWith(\"?\") ? signature : `?${signature}`;\n};\n\nexport const buildExploreUrl = (\n unitSlug: string,\n propertySlug: string,\n origin = DEFAULT_WEB_ORIGIN,\n): string => `${origin}/${propertySlug}/unit/${unitSlug}/explore`;\n\nexport const buildImageUrl = (\n image?: UnitImageApiResponse,\n placeholder = DEFAULT_PLACEHOLDER_IMAGE,\n): string => {\n if (!image?.CFURL || !image?.name || !image?.signature) return placeholder;\n return `${image.CFURL}${image.name}${normalizeSignature(image.signature)}`;\n};\n\nexport function transformUnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(apiResponse: UnitsDataApiResponse<Source>): UnitsApiResponse<Source> {\n return { data: apiResponse };\n}\n\nexport function transformUnitsApiResponseToClient<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(\n apiResponse: UnitsDataApiResponse<Source>,\n propertySlug: string,\n options?: TransformUnitsOptions,\n): UnitsClientList<Source> {\n const origin = options?.origin ?? DEFAULT_WEB_ORIGIN;\n const placeholderImage = options?.placeholderImage ?? DEFAULT_PLACEHOLDER_IMAGE;\n\n const hits =\n apiResponse.hits?.map((hit) => {\n const source = (hit._source ?? {}) as Source & UnitSourceApiResponse;\n const title =\n typeof source.name === \"string\"\n ? source.name\n : typeof source.title === \"string\"\n ? source.title\n : \"\";\n\n const normalized: TransformedUnit<Source> = {\n ...(source as Source),\n title,\n slug: buildExploreUrl(String(source.slug ?? \"\"), propertySlug, origin),\n imageUrl: buildImageUrl(source.image, placeholderImage),\n secondaryImageUrl: buildImageUrl(source.additionalImages?.[0], placeholderImage),\n tertiaryImageUrl: buildImageUrl(source.additionalImages?.[1], placeholderImage),\n };\n\n return normalized;\n }) ?? [];\n\n return {\n total: apiResponse.total?.value ?? hits.length,\n maxScore: apiResponse.max_score ?? null,\n type: apiResponse.type ?? \"units\",\n hits,\n };\n}\n\nexport interface UnitsFilterParams {\n availability?: string[];\n bedrooms?: (number | string)[];\n cost?: number | null;\n highlights?: string[];\n}\n\nexport interface UnitsClientFilters {\n availability?: string[];\n bedrooms?: string[];\n cost?: number;\n highlights: string[];\n}\n\nconst reverseAvailabilityMap: Record<string, string> = {\n asap: \"ASAP\",\n next_month: \"Next Month\",\n \"2_3_months\": \"2-3 Months\",\n all: \"Just Browsing\",\n};\n\nconst reverseBedroomMap: Record<number, string> = {\n 0: \"Studio\",\n 1: \"1 Bed\",\n 2: \"2 Bed\",\n 3: \"3+ Bed\",\n};\n\nconst bedroomLabels = new Set(Object.values(reverseBedroomMap));\n\nconst normalizeBedrooms = (\n bedrooms?: (number | string)[],\n): string[] | undefined => {\n if (!bedrooms || bedrooms.length === 0) return undefined;\n\n const result = new Set<string>();\n\n for (const bedroom of bedrooms) {\n if (typeof bedroom === \"number\") {\n const label = reverseBedroomMap[bedroom];\n if (label) result.add(label);\n continue;\n }\n\n const values = bedroom.split(\",\").map((v) => v.trim());\n\n for (const value of values) {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isNaN(parsed) && reverseBedroomMap[parsed]) {\n result.add(reverseBedroomMap[parsed]);\n } else if (bedroomLabels.has(value)) {\n result.add(value);\n }\n }\n }\n\n return result.size > 0 ? Array.from(result) : undefined;\n};\n\nexport const transformUnitsApiResponseToClientFilters = (\n params: UnitsFilterParams,\n): UnitsClientFilters => {\n const availability =\n params.availability && params.availability.length > 0\n ? params.availability.map(\n (value) => reverseAvailabilityMap[value] ?? value,\n )\n : undefined;\n\n return {\n availability,\n bedrooms: normalizeBedrooms(params.bedrooms),\n cost: params.cost ?? undefined,\n highlights: params.highlights ?? [],\n };\n};\n"],"names":["DEFAULT_WEB_ORIGIN","DEFAULT_PLACEHOLDER_IMAGE","normalizeSignature","signature","buildExploreUrl","unitSlug","propertySlug","origin","buildImageUrl","image","placeholder","transformUnitsApiResponse","apiResponse","transformUnitsApiResponseToClient","options","placeholderImage","hits","_a","hit","source","title","_b","reverseAvailabilityMap","reverseBedroomMap","bedroomLabels","normalizeBedrooms","bedrooms","result","bedroom","label","values","v","value","parsed","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,OACxC,SAAUJ,EAAY,WAAa,KACnC,KAAMA,EAAY,MAAQ,QAC1B,KAAAI,CAAA,CAEJ,CAgBA,MAAMM,EAAiD,CACrD,KAAM,OACN,WAAY,aACZ,aAAc,aACd,IAAK,eACP,EAEMC,EAA4C,CAChD,EAAG,SACH,EAAG,QACH,EAAG,QACH,EAAG,QACL,EAEMC,EAAgB,IAAI,IAAI,OAAO,OAAOD,CAAiB,CAAC,EAExDE,EACJC,GACyB,CACzB,GAAI,CAACA,GAAYA,EAAS,SAAW,EAAG,OAExC,MAAMC,MAAa,IAEnB,UAAWC,KAAWF,EAAU,CAC9B,GAAI,OAAOE,GAAY,SAAU,CAC/B,MAAMC,EAAQN,EAAkBK,CAAO,EACnCC,GAAOF,EAAO,IAAIE,CAAK,EAC3B,QACF,CAEA,MAAMC,EAASF,EAAQ,MAAM,GAAG,EAAE,IAAKG,GAAMA,EAAE,MAAM,EAErD,UAAWC,KAASF,EAAQ,CAC1B,MAAMG,EAAS,OAAO,SAASD,EAAO,EAAE,EACpC,CAAC,OAAO,MAAMC,CAAM,GAAKV,EAAkBU,CAAM,EACnDN,EAAO,IAAIJ,EAAkBU,CAAM,CAAC,EAC3BT,EAAc,IAAIQ,CAAK,GAChCL,EAAO,IAAIK,CAAK,CAEpB,CACF,CAEA,OAAOL,EAAO,KAAO,EAAI,MAAM,KAAKA,CAAM,EAAI,MAChD,EAEaO,EACXC,IASO,CACL,aAPAA,EAAO,cAAgBA,EAAO,aAAa,OAAS,EAChDA,EAAO,aAAa,IACjBH,GAAUV,EAAuBU,CAAK,GAAKA,CAAA,EAE9C,OAIJ,SAAUP,EAAkBU,EAAO,QAAQ,EAC3C,KAAMA,EAAO,MAAQ,OACrB,WAAYA,EAAO,YAAc,CAAA,CAAC"}
1
+ {"version":3,"file":"transformers.cjs","sources":["../../../src/features/units/transformers.ts"],"sourcesContent":["export const DEFAULT_WEB_ORIGIN = \"//web.inresiapp.com\";\nexport const DEFAULT_PLACEHOLDER_IMAGE = \"/placeholder.jpg\";\n\nexport interface UnitImageApiResponse {\n CFURL?: string;\n name?: string;\n signature?: string;\n}\n\nexport interface UnitSourceApiResponse extends Record<string, unknown> {\n id?: number | string;\n name?: string;\n title?: string;\n slug?: string;\n base_price?: number;\n qty_bedrooms?: number | string;\n qty_bathrooms?: number | string;\n totalSqFt?: number;\n dim_sq_ft?: number | string;\n amenities?: unknown;\n highlights?: unknown;\n date_availability?: string | Date | null;\n unitSetAvailableOn?: string | Date | null;\n image?: UnitImageApiResponse;\n additionalImages?: UnitImageApiResponse[];\n}\n\nexport interface UnitHitApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n _index?: string;\n _id?: string;\n _score?: number;\n _source?: Source;\n}\n\nexport interface UnitsTotalInfo {\n value: number;\n relation?: string;\n}\n\nexport interface UnitsDataApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total?: UnitsTotalInfo;\n max_score?: number | null;\n hits?: UnitHitApiResponse<Source>[];\n type?: string;\n}\n\nexport interface UnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n data: UnitsDataApiResponse<Source>;\n}\n\nexport type TransformedUnit<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> = Source & {\n title: string;\n slug: string;\n imageUrl: string;\n secondaryImageUrl?: string;\n tertiaryImageUrl?: string;\n};\n\nexport interface UnitsClientList<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total: number;\n maxScore: number | null;\n type: string;\n hits: TransformedUnit<Source>[];\n}\n\nexport interface TransformUnitsOptions {\n origin?: string;\n placeholderImage?: string;\n}\n\nconst normalizeSignature = (signature?: string): string => {\n if (!signature) return \"\";\n return signature.startsWith(\"?\") ? signature : `?${signature}`;\n};\n\nconst coerceString = (value: unknown): string | undefined => {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n return undefined;\n};\n\nconst propertySlugFallback = (\n defaultSlug: string,\n source: UnitSourceApiResponse,\n): string | undefined => {\n const slug =\n coerceString((source as any).propertySlug) ??\n coerceString((source as any).property_slug);\n return slug ?? defaultSlug;\n};\n\nexport const buildExploreUrl = (\n unitSlug: string,\n propertySlug: string,\n origin = DEFAULT_WEB_ORIGIN,\n): string => `${origin}/${propertySlug}/unit/${unitSlug}/explore`;\n\nexport const buildImageUrl = (\n image?: UnitImageApiResponse,\n placeholder = DEFAULT_PLACEHOLDER_IMAGE,\n): string => {\n if (!image?.CFURL || !image?.name || !image?.signature) return placeholder;\n return `${image.CFURL}${image.name}${normalizeSignature(image.signature)}`;\n};\n\nexport function transformUnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(apiResponse: UnitsDataApiResponse<Source>): UnitsApiResponse<Source> {\n return { data: apiResponse };\n}\n\nexport function transformUnitsApiResponseToClient<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(\n apiResponse: UnitsDataApiResponse<Source>,\n propertySlug: string,\n options?: TransformUnitsOptions,\n): UnitsClientList<Source> {\n const origin = options?.origin ?? DEFAULT_WEB_ORIGIN;\n const placeholderImage = options?.placeholderImage ?? DEFAULT_PLACEHOLDER_IMAGE;\n\n const hits =\n apiResponse.hits?.map((hit) => {\n const source = (hit._source ?? {}) as Source & UnitSourceApiResponse;\n const title =\n typeof source.name === \"string\"\n ? source.name\n : typeof source.title === \"string\"\n ? source.title\n : \"\";\n\n const slugCandidate =\n coerceString(source.slug) ?? coerceString((source as any).unit_slug) ?? \"\";\n const resolvedPropertySlug =\n coerceString((source as any).propertySlug) ??\n coerceString((source as any).property_slug) ??\n propertySlugFallback(propertySlug, source) ??\n propertySlug;\n\n const normalized: TransformedUnit<Source> = {\n ...(source as Source),\n title,\n slug: buildExploreUrl(slugCandidate, resolvedPropertySlug ?? \"\", origin),\n imageUrl: buildImageUrl(source.image, placeholderImage),\n secondaryImageUrl: buildImageUrl(source.additionalImages?.[0], placeholderImage),\n tertiaryImageUrl: buildImageUrl(source.additionalImages?.[1], placeholderImage),\n };\n\n if (typeof normalized.slug !== \"string\" || normalized.slug.trim() === \"\") {\n normalized.slug = buildExploreUrl(\"\", propertySlug ?? \"\", origin);\n }\n\n if (\n resolvedPropertySlug &&\n !(normalized as Record<string, unknown>).propertySlug\n ) {\n (normalized as Record<string, unknown>).propertySlug = resolvedPropertySlug;\n }\n\n return normalized;\n }) ?? [];\n\n return {\n total: apiResponse.total?.value ?? hits.length,\n maxScore: apiResponse.max_score ?? null,\n type: apiResponse.type ?? \"units\",\n hits,\n };\n}\n\nexport interface UnitsFilterParams {\n date_availability?: string[];\n qty_bedrooms?: (number | string)[];\n base_price?: number | null;\n highlights?: string[];\n}\n\nexport interface UnitsClientFilters {\n date_availability?: string[];\n qty_bedrooms?: string[];\n base_price?: number;\n highlights: string[];\n}\n\nconst reverseAvailabilityMap: Record<string, string> = {\n asap: \"ASAP\",\n next_month: \"Next Month\",\n \"2_3_months\": \"2-3 Months\",\n all: \"Just Browsing\",\n};\n\nconst reverseBedroomMap: Record<number, string> = {\n 0: \"Studio\",\n 1: \"1 Bed\",\n 2: \"2 Bed\",\n 3: \"3+ Bed\",\n};\n\nconst bedroomLabels = new Set(Object.values(reverseBedroomMap));\n\nconst normalizeBedrooms = (\n bedrooms?: (number | string)[],\n): string[] | undefined => {\n if (!bedrooms || bedrooms.length === 0) return undefined;\n\n const result = new Set<string>();\n\n for (const bedroom of bedrooms) {\n if (typeof bedroom === \"number\") {\n const label = reverseBedroomMap[bedroom];\n if (label) result.add(label);\n continue;\n }\n\n const values = bedroom.split(\",\").map((v) => v.trim());\n\n for (const value of values) {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isNaN(parsed) && reverseBedroomMap[parsed]) {\n result.add(reverseBedroomMap[parsed]);\n } else if (bedroomLabels.has(value)) {\n result.add(value);\n }\n }\n }\n\n return result.size > 0 ? Array.from(result) : undefined;\n};\n\nexport const transformUnitsApiResponseToClientFilters = (\n params: UnitsFilterParams,\n): UnitsClientFilters => {\n const dateAvailabilityLabels =\n params.date_availability && params.date_availability.length > 0\n ? params.date_availability.map(\n (value) => reverseAvailabilityMap[value] ?? value,\n )\n : undefined;\n\n return {\n date_availability: dateAvailabilityLabels,\n qty_bedrooms: normalizeBedrooms(params.qty_bedrooms),\n base_price: params.base_price ?? undefined,\n highlights: params.highlights ?? [],\n };\n};\n"],"names":["DEFAULT_WEB_ORIGIN","DEFAULT_PLACEHOLDER_IMAGE","normalizeSignature","signature","coerceString","value","propertySlugFallback","defaultSlug","source","buildExploreUrl","unitSlug","propertySlug","origin","buildImageUrl","image","placeholder","transformUnitsApiResponse","apiResponse","transformUnitsApiResponseToClient","options","placeholderImage","hits","_a","hit","title","slugCandidate","resolvedPropertySlug","normalized","_b","reverseAvailabilityMap","reverseBedroomMap","bedroomLabels","normalizeBedrooms","bedrooms","result","bedroom","label","values","v","parsed","transformUnitsApiResponseToClientFilters","params"],"mappings":"gFAAO,MAAMA,EAAqB,sBACrBC,EAA4B,mBA+EnCC,EAAsBC,GACrBA,EACEA,EAAU,WAAW,GAAG,EAAIA,EAAY,IAAIA,CAAS,GADrC,GAInBC,EAAgBC,GAAuC,CAC3D,GAAI,OAAOA,GAAU,SAAU,OAAOA,EACtC,GAAI,OAAOA,GAAU,UAAY,OAAOA,GAAU,UAChD,OAAO,OAAOA,CAAK,CAGvB,EAEMC,EAAuB,CAC3BC,EACAC,IAGEJ,EAAcI,EAAe,YAAY,GACzCJ,EAAcI,EAAe,aAAa,GAC7BD,EAGJE,EAAkB,CAC7BC,EACAC,EACAC,EAASZ,IACE,GAAGY,CAAM,IAAID,CAAY,SAASD,CAAQ,WAE1CG,EAAgB,CAC3BC,EACAC,EAAcd,IAEV,EAACa,GAAA,MAAAA,EAAO,QAAS,EAACA,GAAA,MAAAA,EAAO,OAAQ,EAACA,GAAA,MAAAA,EAAO,WAAkBC,EACxD,GAAGD,EAAM,KAAK,GAAGA,EAAM,IAAI,GAAGZ,EAAmBY,EAAM,SAAS,CAAC,GAGnE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ACZ,aAAc,aACd,IAAK,eACP,EAEMC,EAA4C,CAChD,EAAG,SACH,EAAG,QACH,EAAG,QACH,EAAG,QACL,EAEMC,EAAgB,IAAI,IAAI,OAAO,OAAOD,CAAiB,CAAC,EAExDE,EACJC,GACyB,CACzB,GAAI,CAACA,GAAYA,EAAS,SAAW,EAAG,OAExC,MAAMC,MAAa,IAEnB,UAAWC,KAAWF,EAAU,CAC9B,GAAI,OAAOE,GAAY,SAAU,CAC/B,MAAMC,EAAQN,EAAkBK,CAAO,EACnCC,GAAOF,EAAO,IAAIE,CAAK,EAC3B,QACF,CAEA,MAAMC,EAASF,EAAQ,MAAM,GAAG,EAAE,IAAKG,GAAMA,EAAE,MAAM,EAErD,UAAWjC,KAASgC,EAAQ,CAC1B,MAAME,EAAS,OAAO,SAASlC,EAAO,EAAE,EACpC,CAAC,OAAO,MAAMkC,CAAM,GAAKT,EAAkBS,CAAM,EACnDL,EAAO,IAAIJ,EAAkBS,CAAM,CAAC,EAC3BR,EAAc,IAAI1B,CAAK,GAChC6B,EAAO,IAAI7B,CAAK,CAEpB,CACF,CAEA,OAAO6B,EAAO,KAAO,EAAI,MAAM,KAAKA,CAAM,EAAI,MAChD,EAEaM,EACXC,IASO,CACL,kBAPAA,EAAO,mBAAqBA,EAAO,kBAAkB,OAAS,EAC1DA,EAAO,kBAAkB,IACtBpC,GAAUwB,EAAuBxB,CAAK,GAAKA,CAAA,EAE9C,OAIJ,aAAc2B,EAAkBS,EAAO,YAAY,EACnD,WAAYA,EAAO,YAAc,OACjC,WAAYA,EAAO,YAAc,CAAA,CAAC"}
@@ -10,13 +10,15 @@ export interface UnitSourceApiResponse extends Record<string, unknown> {
10
10
  name?: string;
11
11
  title?: string;
12
12
  slug?: string;
13
- cost?: number;
14
- bedrooms?: number;
15
- bathrooms?: number;
13
+ base_price?: number;
14
+ qty_bedrooms?: number | string;
15
+ qty_bathrooms?: number | string;
16
16
  totalSqFt?: number;
17
+ dim_sq_ft?: number | string;
17
18
  amenities?: unknown;
18
19
  highlights?: unknown;
19
- availability?: string | Date | null;
20
+ date_availability?: string | Date | null;
21
+ unitSetAvailableOn?: string | Date | null;
20
22
  image?: UnitImageApiResponse;
21
23
  additionalImages?: UnitImageApiResponse[];
22
24
  }
@@ -61,15 +63,15 @@ export declare const buildImageUrl: (image?: UnitImageApiResponse, placeholder?:
61
63
  export declare function transformUnitsApiResponse<Source extends Record<string, unknown> = UnitSourceApiResponse>(apiResponse: UnitsDataApiResponse<Source>): UnitsApiResponse<Source>;
62
64
  export declare function transformUnitsApiResponseToClient<Source extends Record<string, unknown> = UnitSourceApiResponse>(apiResponse: UnitsDataApiResponse<Source>, propertySlug: string, options?: TransformUnitsOptions): UnitsClientList<Source>;
63
65
  export interface UnitsFilterParams {
64
- availability?: string[];
65
- bedrooms?: (number | string)[];
66
- cost?: number | null;
66
+ date_availability?: string[];
67
+ qty_bedrooms?: (number | string)[];
68
+ base_price?: number | null;
67
69
  highlights?: string[];
68
70
  }
69
71
  export interface UnitsClientFilters {
70
- availability?: string[];
71
- bedrooms?: string[];
72
- cost?: number;
72
+ date_availability?: string[];
73
+ qty_bedrooms?: string[];
74
+ base_price?: number;
73
75
  highlights: string[];
74
76
  }
75
77
  export declare const transformUnitsApiResponseToClientFilters: (params: UnitsFilterParams) => UnitsClientFilters;
@@ -1,69 +1,73 @@
1
- const h = "//web.inresiapp.com", b = "/placeholder.jpg", y = (t) => t ? t.startsWith("?") ? t : `?${t}` : "", U = (t, r, e = h) => `${e}/${r}/unit/${t}/explore`, a = (t, r = b) => !(t != null && t.CFURL) || !(t != null && t.name) || !(t != null && t.signature) ? r : `${t.CFURL}${t.name}${y(t.signature)}`;
2
- function g(t) {
1
+ const h = "//web.inresiapp.com", _ = "/placeholder.jpg", S = (t) => t ? t.startsWith("?") ? t : `?${t}` : "", i = (t) => {
2
+ if (typeof t == "string") return t;
3
+ if (typeof t == "number" || typeof t == "boolean")
4
+ return String(t);
5
+ }, U = (t, e) => i(e.propertySlug) ?? i(e.property_slug) ?? t, g = (t, e, r = h) => `${r}/${e}/unit/${t}/explore`, d = (t, e = _) => !(t != null && t.CFURL) || !(t != null && t.name) || !(t != null && t.signature) ? e : `${t.CFURL}${t.name}${S(t.signature)}`;
6
+ function B(t) {
3
7
  return { data: t };
4
8
  }
5
- function x(t, r, e) {
6
- var c, d;
7
- const i = (e == null ? void 0 : e.origin) ?? h, n = (e == null ? void 0 : e.placeholderImage) ?? b, l = ((c = t.hits) == null ? void 0 : c.map((m) => {
8
- var u, f;
9
- const o = m._source ?? {}, v = typeof o.name == "string" ? o.name : typeof o.title == "string" ? o.title : "";
10
- return {
11
- ...o,
9
+ function E(t, e, r) {
10
+ var f, y;
11
+ const a = (r == null ? void 0 : r.origin) ?? h, o = (r == null ? void 0 : r.placeholderImage) ?? _, l = ((f = t.hits) == null ? void 0 : f.map((m) => {
12
+ var p, b;
13
+ const n = m._source ?? {}, v = typeof n.name == "string" ? n.name : typeof n.title == "string" ? n.title : "", A = i(n.slug) ?? i(n.unit_slug) ?? "", u = i(n.propertySlug) ?? i(n.property_slug) ?? U(e, n) ?? e, s = {
14
+ ...n,
12
15
  title: v,
13
- slug: U(String(o.slug ?? ""), r, i),
14
- imageUrl: a(o.image, n),
15
- secondaryImageUrl: a((u = o.additionalImages) == null ? void 0 : u[0], n),
16
- tertiaryImageUrl: a((f = o.additionalImages) == null ? void 0 : f[1], n)
16
+ slug: g(A, u ?? "", a),
17
+ imageUrl: d(n.image, o),
18
+ secondaryImageUrl: d((p = n.additionalImages) == null ? void 0 : p[0], o),
19
+ tertiaryImageUrl: d((b = n.additionalImages) == null ? void 0 : b[1], o)
17
20
  };
21
+ return (typeof s.slug != "string" || s.slug.trim() === "") && (s.slug = g("", e ?? "", a)), u && !s.propertySlug && (s.propertySlug = u), s;
18
22
  })) ?? [];
19
23
  return {
20
- total: ((d = t.total) == null ? void 0 : d.value) ?? l.length,
24
+ total: ((y = t.total) == null ? void 0 : y.value) ?? l.length,
21
25
  maxScore: t.max_score ?? null,
22
26
  type: t.type ?? "units",
23
27
  hits: l
24
28
  };
25
29
  }
26
- const A = {
30
+ const I = {
27
31
  asap: "ASAP",
28
32
  next_month: "Next Month",
29
33
  "2_3_months": "2-3 Months",
30
34
  all: "Just Browsing"
31
- }, s = {
35
+ }, c = {
32
36
  0: "Studio",
33
37
  1: "1 Bed",
34
38
  2: "2 Bed",
35
39
  3: "3+ Bed"
36
- }, I = new Set(Object.values(s)), p = (t) => {
40
+ }, L = new Set(Object.values(c)), x = (t) => {
37
41
  if (!t || t.length === 0) return;
38
- const r = /* @__PURE__ */ new Set();
39
- for (const e of t) {
40
- if (typeof e == "number") {
41
- const n = s[e];
42
- n && r.add(n);
42
+ const e = /* @__PURE__ */ new Set();
43
+ for (const r of t) {
44
+ if (typeof r == "number") {
45
+ const o = c[r];
46
+ o && e.add(o);
43
47
  continue;
44
48
  }
45
- const i = e.split(",").map((n) => n.trim());
46
- for (const n of i) {
47
- const l = Number.parseInt(n, 10);
48
- !Number.isNaN(l) && s[l] ? r.add(s[l]) : I.has(n) && r.add(n);
49
+ const a = r.split(",").map((o) => o.trim());
50
+ for (const o of a) {
51
+ const l = Number.parseInt(o, 10);
52
+ !Number.isNaN(l) && c[l] ? e.add(c[l]) : L.has(o) && e.add(o);
49
53
  }
50
54
  }
51
- return r.size > 0 ? Array.from(r) : void 0;
52
- }, B = (t) => ({
53
- availability: t.availability && t.availability.length > 0 ? t.availability.map(
54
- (e) => A[e] ?? e
55
+ return e.size > 0 ? Array.from(e) : void 0;
56
+ }, $ = (t) => ({
57
+ date_availability: t.date_availability && t.date_availability.length > 0 ? t.date_availability.map(
58
+ (r) => I[r] ?? r
55
59
  ) : void 0,
56
- bedrooms: p(t.bedrooms),
57
- cost: t.cost ?? void 0,
60
+ qty_bedrooms: x(t.qty_bedrooms),
61
+ base_price: t.base_price ?? void 0,
58
62
  highlights: t.highlights ?? []
59
63
  });
60
64
  export {
61
- b as DEFAULT_PLACEHOLDER_IMAGE,
65
+ _ as DEFAULT_PLACEHOLDER_IMAGE,
62
66
  h as DEFAULT_WEB_ORIGIN,
63
- U as buildExploreUrl,
64
- a as buildImageUrl,
65
- g as transformUnitsApiResponse,
66
- x as transformUnitsApiResponseToClient,
67
- B as transformUnitsApiResponseToClientFilters
67
+ g as buildExploreUrl,
68
+ d as buildImageUrl,
69
+ B as transformUnitsApiResponse,
70
+ E as transformUnitsApiResponseToClient,
71
+ $ as transformUnitsApiResponseToClientFilters
68
72
  };
69
73
  //# sourceMappingURL=transformers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformers.mjs","sources":["../../../src/features/units/transformers.ts"],"sourcesContent":["export const DEFAULT_WEB_ORIGIN = \"//web.inresiapp.com\";\nexport const DEFAULT_PLACEHOLDER_IMAGE = \"/placeholder.jpg\";\n\nexport interface UnitImageApiResponse {\n CFURL?: string;\n name?: string;\n signature?: string;\n}\n\nexport interface UnitSourceApiResponse extends Record<string, unknown> {\n id?: number | string;\n name?: string;\n title?: string;\n slug?: string;\n cost?: number;\n bedrooms?: number;\n bathrooms?: number;\n totalSqFt?: number;\n amenities?: unknown;\n highlights?: unknown;\n availability?: string | Date | null;\n image?: UnitImageApiResponse;\n additionalImages?: UnitImageApiResponse[];\n}\n\nexport interface UnitHitApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n _index?: string;\n _id?: string;\n _score?: number;\n _source?: Source;\n}\n\nexport interface UnitsTotalInfo {\n value: number;\n relation?: string;\n}\n\nexport interface UnitsDataApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total?: UnitsTotalInfo;\n max_score?: number | null;\n hits?: UnitHitApiResponse<Source>[];\n type?: string;\n}\n\nexport interface UnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n data: UnitsDataApiResponse<Source>;\n}\n\nexport type TransformedUnit<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> = Source & {\n title: string;\n slug: string;\n imageUrl: string;\n secondaryImageUrl?: string;\n tertiaryImageUrl?: string;\n};\n\nexport interface UnitsClientList<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total: number;\n maxScore: number | null;\n type: string;\n hits: TransformedUnit<Source>[];\n}\n\nexport interface TransformUnitsOptions {\n origin?: string;\n placeholderImage?: string;\n}\n\nconst normalizeSignature = (signature?: string): string => {\n if (!signature) return \"\";\n return signature.startsWith(\"?\") ? signature : `?${signature}`;\n};\n\nexport const buildExploreUrl = (\n unitSlug: string,\n propertySlug: string,\n origin = DEFAULT_WEB_ORIGIN,\n): string => `${origin}/${propertySlug}/unit/${unitSlug}/explore`;\n\nexport const buildImageUrl = (\n image?: UnitImageApiResponse,\n placeholder = DEFAULT_PLACEHOLDER_IMAGE,\n): string => {\n if (!image?.CFURL || !image?.name || !image?.signature) return placeholder;\n return `${image.CFURL}${image.name}${normalizeSignature(image.signature)}`;\n};\n\nexport function transformUnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(apiResponse: UnitsDataApiResponse<Source>): UnitsApiResponse<Source> {\n return { data: apiResponse };\n}\n\nexport function transformUnitsApiResponseToClient<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(\n apiResponse: UnitsDataApiResponse<Source>,\n propertySlug: string,\n options?: TransformUnitsOptions,\n): UnitsClientList<Source> {\n const origin = options?.origin ?? DEFAULT_WEB_ORIGIN;\n const placeholderImage = options?.placeholderImage ?? DEFAULT_PLACEHOLDER_IMAGE;\n\n const hits =\n apiResponse.hits?.map((hit) => {\n const source = (hit._source ?? {}) as Source & UnitSourceApiResponse;\n const title =\n typeof source.name === \"string\"\n ? source.name\n : typeof source.title === \"string\"\n ? source.title\n : \"\";\n\n const normalized: TransformedUnit<Source> = {\n ...(source as Source),\n title,\n slug: buildExploreUrl(String(source.slug ?? \"\"), propertySlug, origin),\n imageUrl: buildImageUrl(source.image, placeholderImage),\n secondaryImageUrl: buildImageUrl(source.additionalImages?.[0], placeholderImage),\n tertiaryImageUrl: buildImageUrl(source.additionalImages?.[1], placeholderImage),\n };\n\n return normalized;\n }) ?? [];\n\n return {\n total: apiResponse.total?.value ?? hits.length,\n maxScore: apiResponse.max_score ?? null,\n type: apiResponse.type ?? \"units\",\n hits,\n };\n}\n\nexport interface UnitsFilterParams {\n availability?: string[];\n bedrooms?: (number | string)[];\n cost?: number | null;\n highlights?: string[];\n}\n\nexport interface UnitsClientFilters {\n availability?: string[];\n bedrooms?: string[];\n cost?: number;\n highlights: string[];\n}\n\nconst reverseAvailabilityMap: Record<string, string> = {\n asap: \"ASAP\",\n next_month: \"Next Month\",\n \"2_3_months\": \"2-3 Months\",\n all: \"Just Browsing\",\n};\n\nconst reverseBedroomMap: Record<number, string> = {\n 0: \"Studio\",\n 1: \"1 Bed\",\n 2: \"2 Bed\",\n 3: \"3+ Bed\",\n};\n\nconst bedroomLabels = new Set(Object.values(reverseBedroomMap));\n\nconst normalizeBedrooms = (\n bedrooms?: (number | string)[],\n): string[] | undefined => {\n if (!bedrooms || bedrooms.length === 0) return undefined;\n\n const result = new Set<string>();\n\n for (const bedroom of bedrooms) {\n if (typeof bedroom === \"number\") {\n const label = reverseBedroomMap[bedroom];\n if (label) result.add(label);\n continue;\n }\n\n const values = bedroom.split(\",\").map((v) => v.trim());\n\n for (const value of values) {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isNaN(parsed) && reverseBedroomMap[parsed]) {\n result.add(reverseBedroomMap[parsed]);\n } else if (bedroomLabels.has(value)) {\n result.add(value);\n }\n }\n }\n\n return result.size > 0 ? Array.from(result) : undefined;\n};\n\nexport const transformUnitsApiResponseToClientFilters = (\n params: UnitsFilterParams,\n): UnitsClientFilters => {\n const availability =\n params.availability && params.availability.length > 0\n ? params.availability.map(\n (value) => reverseAvailabilityMap[value] ?? value,\n )\n : undefined;\n\n return {\n availability,\n bedrooms: normalizeBedrooms(params.bedrooms),\n cost: params.cost ?? undefined,\n highlights: params.highlights ?? [],\n };\n};\n"],"names":["DEFAULT_WEB_ORIGIN","DEFAULT_PLACEHOLDER_IMAGE","normalizeSignature","signature","buildExploreUrl","unitSlug","propertySlug","origin","buildImageUrl","image","placeholder","transformUnitsApiResponse","apiResponse","transformUnitsApiResponseToClient","options","_a","_b","placeholderImage","hits","hit","source","title","reverseAvailabilityMap","reverseBedroomMap","bedroomLabels","normalizeBedrooms","bedrooms","result","bedroom","label","values","v","value","parsed","transformUnitsApiResponseToClientFilters","params"],"mappings":"AAAO,MAAMA,IAAqB,uBACrBC,IAA4B,oBA6EnCC,IAAqB,CAACC,MACrBA,IACEA,EAAU,WAAW,GAAG,IAAIA,IAAY,IAAIA,CAAS,KADrC,IAIZC,IAAkB,CAC7BC,GACAC,GACAC,IAASP,MACE,GAAGO,CAAM,IAAID,CAAY,SAASD,CAAQ,YAE1CG,IAAgB,CAC3BC,GACAC,IAAcT,MAEV,EAACQ,KAAA,QAAAA,EAAO,UAAS,EAACA,KAAA,QAAAA,EAAO,SAAQ,EAACA,KAAA,QAAAA,EAAO,aAAkBC,IACxD,GAAGD,EAAM,KAAK,GAAGA,EAAM,IAAI,GAAGP,EAAmBO,EAAM,SAAS,CAAC;AAGnE,SAASE,EAEdC,GAAqE;AACrE,SAAO,EAAE,MAAMA,EAAA;AACjB;AAEO,SAASC,EAGdD,GACAN,GACAQ,GACyB;AA7GpB,MAAAC,GAAAC;AA8GL,QAAMT,KAASO,KAAA,gBAAAA,EAAS,WAAUd,GAC5BiB,KAAmBH,KAAA,gBAAAA,EAAS,qBAAoBb,GAEhDiB,MACJH,IAAAH,EAAY,SAAZ,gBAAAG,EAAkB,IAAI,CAACI,MAAQ;AAlH5B,QAAAJ,GAAAC;AAmHD,UAAMI,IAAUD,EAAI,WAAW,CAAA,GACzBE,IACJ,OAAOD,EAAO,QAAS,WACnBA,EAAO,OACP,OAAOA,EAAO,SAAU,WACtBA,EAAO,QACP;AAWR,WAT4C;AAAA,MAC1C,GAAIA;AAAA,MACJ,OAAAC;AAAA,MACA,MAAMjB,EAAgB,OA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,CAAK,KAChCL,EAAO,IAAIK,CAAK;AAAA,IAEpB;AAAA,EACF;AAEA,SAAOL,EAAO,OAAO,IAAI,MAAM,KAAKA,CAAM,IAAI;AAChD,GAEaO,IAA2C,CACtDC,OASO;AAAA,EACL,cAPAA,EAAO,gBAAgBA,EAAO,aAAa,SAAS,IAChDA,EAAO,aAAa;AAAA,IAClB,CAACH,MAAUV,EAAuBU,CAAK,KAAKA;AAAA,EAAA,IAE9C;AAAA,EAIJ,UAAUP,EAAkBU,EAAO,QAAQ;AAAA,EAC3C,MAAMA,EAAO,QAAQ;AAAA,EACrB,YAAYA,EAAO,cAAc,CAAA;AAAC;"}
1
+ {"version":3,"file":"transformers.mjs","sources":["../../../src/features/units/transformers.ts"],"sourcesContent":["export const DEFAULT_WEB_ORIGIN = \"//web.inresiapp.com\";\nexport const DEFAULT_PLACEHOLDER_IMAGE = \"/placeholder.jpg\";\n\nexport interface UnitImageApiResponse {\n CFURL?: string;\n name?: string;\n signature?: string;\n}\n\nexport interface UnitSourceApiResponse extends Record<string, unknown> {\n id?: number | string;\n name?: string;\n title?: string;\n slug?: string;\n base_price?: number;\n qty_bedrooms?: number | string;\n qty_bathrooms?: number | string;\n totalSqFt?: number;\n dim_sq_ft?: number | string;\n amenities?: unknown;\n highlights?: unknown;\n date_availability?: string | Date | null;\n unitSetAvailableOn?: string | Date | null;\n image?: UnitImageApiResponse;\n additionalImages?: UnitImageApiResponse[];\n}\n\nexport interface UnitHitApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n _index?: string;\n _id?: string;\n _score?: number;\n _source?: Source;\n}\n\nexport interface UnitsTotalInfo {\n value: number;\n relation?: string;\n}\n\nexport interface UnitsDataApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total?: UnitsTotalInfo;\n max_score?: number | null;\n hits?: UnitHitApiResponse<Source>[];\n type?: string;\n}\n\nexport interface UnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n data: UnitsDataApiResponse<Source>;\n}\n\nexport type TransformedUnit<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> = Source & {\n title: string;\n slug: string;\n imageUrl: string;\n secondaryImageUrl?: string;\n tertiaryImageUrl?: string;\n};\n\nexport interface UnitsClientList<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n> {\n total: number;\n maxScore: number | null;\n type: string;\n hits: TransformedUnit<Source>[];\n}\n\nexport interface TransformUnitsOptions {\n origin?: string;\n placeholderImage?: string;\n}\n\nconst normalizeSignature = (signature?: string): string => {\n if (!signature) return \"\";\n return signature.startsWith(\"?\") ? signature : `?${signature}`;\n};\n\nconst coerceString = (value: unknown): string | undefined => {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n return undefined;\n};\n\nconst propertySlugFallback = (\n defaultSlug: string,\n source: UnitSourceApiResponse,\n): string | undefined => {\n const slug =\n coerceString((source as any).propertySlug) ??\n coerceString((source as any).property_slug);\n return slug ?? defaultSlug;\n};\n\nexport const buildExploreUrl = (\n unitSlug: string,\n propertySlug: string,\n origin = DEFAULT_WEB_ORIGIN,\n): string => `${origin}/${propertySlug}/unit/${unitSlug}/explore`;\n\nexport const buildImageUrl = (\n image?: UnitImageApiResponse,\n placeholder = DEFAULT_PLACEHOLDER_IMAGE,\n): string => {\n if (!image?.CFURL || !image?.name || !image?.signature) return placeholder;\n return `${image.CFURL}${image.name}${normalizeSignature(image.signature)}`;\n};\n\nexport function transformUnitsApiResponse<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(apiResponse: UnitsDataApiResponse<Source>): UnitsApiResponse<Source> {\n return { data: apiResponse };\n}\n\nexport function transformUnitsApiResponseToClient<\n Source extends Record<string, unknown> = UnitSourceApiResponse,\n>(\n apiResponse: UnitsDataApiResponse<Source>,\n propertySlug: string,\n options?: TransformUnitsOptions,\n): UnitsClientList<Source> {\n const origin = options?.origin ?? DEFAULT_WEB_ORIGIN;\n const placeholderImage = options?.placeholderImage ?? DEFAULT_PLACEHOLDER_IMAGE;\n\n const hits =\n apiResponse.hits?.map((hit) => {\n const source = (hit._source ?? {}) as Source & UnitSourceApiResponse;\n const title =\n typeof source.name === \"string\"\n ? source.name\n : typeof source.title === \"string\"\n ? source.title\n : \"\";\n\n const slugCandidate =\n coerceString(source.slug) ?? coerceString((source as any).unit_slug) ?? \"\";\n const resolvedPropertySlug =\n coerceString((source as any).propertySlug) ??\n coerceString((source as any).property_slug) ??\n propertySlugFallback(propertySlug, source) ??\n propertySlug;\n\n const normalized: TransformedUnit<Source> = {\n ...(source as Source),\n title,\n slug: buildExploreUrl(slugCandidate, resolvedPropertySlug ?? \"\", origin),\n imageUrl: buildImageUrl(source.image, placeholderImage),\n secondaryImageUrl: buildImageUrl(source.additionalImages?.[0], placeholderImage),\n tertiaryImageUrl: buildImageUrl(source.additionalImages?.[1], placeholderImage),\n };\n\n if (typeof normalized.slug !== \"string\" || normalized.slug.trim() === \"\") {\n normalized.slug = buildExploreUrl(\"\", propertySlug ?? \"\", origin);\n }\n\n if (\n resolvedPropertySlug &&\n !(normalized as Record<string, unknown>).propertySlug\n ) {\n (normalized as Record<string, unknown>).propertySlug = resolvedPropertySlug;\n }\n\n return normalized;\n }) ?? [];\n\n return {\n total: apiResponse.total?.value ?? hits.length,\n maxScore: apiResponse.max_score ?? null,\n type: apiResponse.type ?? \"units\",\n hits,\n };\n}\n\nexport interface UnitsFilterParams {\n date_availability?: string[];\n qty_bedrooms?: (number | string)[];\n base_price?: number | null;\n highlights?: string[];\n}\n\nexport interface UnitsClientFilters {\n date_availability?: string[];\n qty_bedrooms?: string[];\n base_price?: number;\n highlights: string[];\n}\n\nconst reverseAvailabilityMap: Record<string, string> = {\n asap: \"ASAP\",\n next_month: \"Next Month\",\n \"2_3_months\": \"2-3 Months\",\n all: \"Just Browsing\",\n};\n\nconst reverseBedroomMap: Record<number, string> = {\n 0: \"Studio\",\n 1: \"1 Bed\",\n 2: \"2 Bed\",\n 3: \"3+ Bed\",\n};\n\nconst bedroomLabels = new Set(Object.values(reverseBedroomMap));\n\nconst normalizeBedrooms = (\n bedrooms?: (number | string)[],\n): string[] | undefined => {\n if (!bedrooms || bedrooms.length === 0) return undefined;\n\n const result = new Set<string>();\n\n for (const bedroom of bedrooms) {\n if (typeof bedroom === \"number\") {\n const label = reverseBedroomMap[bedroom];\n if (label) result.add(label);\n continue;\n }\n\n const values = bedroom.split(\",\").map((v) => v.trim());\n\n for (const value of values) {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isNaN(parsed) && reverseBedroomMap[parsed]) {\n result.add(reverseBedroomMap[parsed]);\n } else if (bedroomLabels.has(value)) {\n result.add(value);\n }\n }\n }\n\n return result.size > 0 ? Array.from(result) : undefined;\n};\n\nexport const transformUnitsApiResponseToClientFilters = (\n params: UnitsFilterParams,\n): UnitsClientFilters => {\n const dateAvailabilityLabels =\n params.date_availability && params.date_availability.length > 0\n ? params.date_availability.map(\n (value) => reverseAvailabilityMap[value] ?? value,\n )\n : undefined;\n\n return {\n date_availability: dateAvailabilityLabels,\n qty_bedrooms: normalizeBedrooms(params.qty_bedrooms),\n base_price: params.base_price ?? undefined,\n highlights: params.highlights ?? [],\n };\n};\n"],"names":["DEFAULT_WEB_ORIGIN","DEFAULT_PLACEHOLDER_IMAGE","normalizeSignature","signature","coerceString","value","propertySlugFallback","defaultSlug","source","buildExploreUrl","unitSlug","propertySlug","origin","buildImageUrl","image","placeholder","transformUnitsApiResponse","apiResponse","transformUnitsApiResponseToClient","options","_a","_b","placeholderImage","hits","hit","title","slugCandidate","resolvedPropertySlug","normalized","reverseAvailabilityMap","reverseBedroomMap","bedroomLabels","normalizeBedrooms","bedrooms","result","bedroom","label","values","v","parsed","transformUnitsApiResponseToClientFilters","params"],"mappings":"AAAO,MAAMA,IAAqB,uBACrBC,IAA4B,oBA+EnCC,IAAqB,CAACC,MACrBA,IACEA,EAAU,WAAW,GAAG,IAAIA,IAAY,IAAIA,CAAS,KADr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C,GAAQ;AAC1B,YAAME,IAAS,OAAO,SAASlC,GAAO,EAAE;AACxC,MAAI,CAAC,OAAO,MAAMkC,CAAM,KAAKT,EAAkBS,CAAM,IACnDL,EAAO,IAAIJ,EAAkBS,CAAM,CAAC,IAC3BR,EAAc,IAAI1B,CAAK,KAChC6B,EAAO,IAAI7B,CAAK;AAAA,IAEpB;AAAA,EACF;AAEA,SAAO6B,EAAO,OAAO,IAAI,MAAM,KAAKA,CAAM,IAAI;AAChD,GAEaM,IAA2C,CACtDC,OASO;AAAA,EACL,mBAPAA,EAAO,qBAAqBA,EAAO,kBAAkB,SAAS,IAC1DA,EAAO,kBAAkB;AAAA,IACvB,CAACpC,MAAUwB,EAAuBxB,CAAK,KAAKA;AAAA,EAAA,IAE9C;AAAA,EAIJ,cAAc2B,EAAkBS,EAAO,YAAY;AAAA,EACnD,YAAYA,EAAO,cAAc;AAAA,EACjC,YAAYA,EAAO,cAAc,CAAA;AAAC;"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./errors.cjs"),e=require("./schema.cjs"),l=require("./db.cjs"),n=require("./api/users.cjs"),S=require("./debug.cjs"),i=require("./storage.cjs"),a=require("./api/favorites.cjs"),m=require("./api/properties.cjs"),s=require("./stores/store.cjs"),d=require("./adapters/zustand-store.cjs"),U=require("./adapters/structured-store.cjs"),y=require("./units/favorites.cjs"),t=require("./features/units/transformers.cjs"),u=require("./utils/dimensions.cjs"),h=require("./validation.cjs"),v=require("./base/overviewimagesonproperty.cjs"),M=require("./base/amenityimagesonproperty.cjs"),g=require("./base/floorplan.cjs"),E=require("./base/media.cjs"),D=require("./base/property.cjs"),q=require("./base/propertyhighlight.cjs"),P=require("./base/room.cjs"),A=require("./base/style.cjs"),F=require("./base/unit.cjs"),r=require("./base/enums.cjs"),R=require("./base/renderedstyle.cjs"),f=require("./base/propertyamenity.cjs"),I=require("./base/favoriteunit.cjs"),T=require("./base/user.cjs"),p=require("./features/analytics/MixpanelProvider.cjs"),O=require("./features/analytics/generateUserUUID.cjs"),o=require("./features/analytics/analytics.cjs");exports.OpenDBError=c.OpenDBError;exports.SchemaMismatchError=c.SchemaMismatchError;exports.ApiUserSchema=e.ApiUserSchema;exports.AppStoreDataSchema=e.AppStoreDataSchema;exports.FavoritesSchema=e.FavoritesSchema;exports.FiltersSchema=e.FiltersSchema;exports.PropertySchema=e.PropertySchema;exports.PropertyStoreDataSchema=e.PropertyStoreDataSchema;exports.QueryParamsSchema=e.QueryParamsSchema;exports.ResultsModeEnum=e.ResultsModeEnum;exports.SCHEMA_VERSION=e.SCHEMA_VERSION;exports.SortByEnum=e.SortByEnum;exports.TourContactDataSchema=e.TourContactDataSchema;exports.UnifiedStoreDataSchema=e.UnifiedStoreDataSchema;exports.UnitDataSchema=e.UnitDataSchema;exports.UnitFavoriteSchema=e.UnitFavoriteSchema;exports.UnitSchema=e.UnitSchema;exports.UserPropertyStateSchema=e.UserPropertyStateSchema;exports.UserSchema=e.UserSchema;exports.UserUnitDataSchema=e.UserUnitDataSchema;exports.ViewedUnitSchema=e.ViewedUnitSchema;exports.getDB=l.getDB;exports.resetDB=l.resetDB;exports.defaultIdGenerator=n.defaultIdGenerator;exports.ensureUser=n.ensureUser;exports.getUserUUID=n.getUserUUID;exports.debugDump=S.debugDump;exports.exportJSON=S.exportJSON;exports.createORMStringStorage=i.createORMStringStorage;exports.kvGet=i.kvGet;exports.kvRemove=i.kvRemove;exports.kvSet=i.kvSet;exports.getFavoritedUnitsForProperty=a.getFavoritedUnitsForProperty;exports.isUnitFavorited=a.isUnitFavorited;exports.setFavoriteUnit=a.setFavoriteUnit;exports.toggleFavoriteUnit=a.toggleFavoriteUnit;exports.PropertyStore=m.PropertyStore;exports.propertyStore=m.propertyStore;exports.Store=s.UnifiedStore;exports.UnifiedStore=s.UnifiedStore;exports.store=s.store;exports.createUseUnitState=d.createUseUnitState;exports.createZustandUnifiedStore=d.createZustandUnifiedStore;exports.createStructuredStore=U.createStructuredStore;exports.createStructuredStoreActions=U.createStructuredStoreActions;exports.favorites=y.favorites;exports.DEFAULT_PLACEHOLDER_IMAGE=t.DEFAULT_PLACEHOLDER_IMAGE;exports.DEFAULT_WEB_ORIGIN=t.DEFAULT_WEB_ORIGIN;exports.buildExploreUrl=t.buildExploreUrl;exports.buildImageUrl=t.buildImageUrl;exports.transformUnitsApiResponse=t.transformUnitsApiResponse;exports.transformUnitsApiResponseToClient=t.transformUnitsApiResponseToClient;exports.transformUnitsApiResponseToClientFilters=t.transformUnitsApiResponseToClientFilters;exports.imperialToMm=u.imperialToMm;exports.inchesToMm=u.inchesToMm;exports.mmToInches=u.mmToInches;exports.configureValidation=h.configureValidation;exports.OverviewImagesOnPropertyModel=v.OverviewImagesOnPropertyModel;exports.AmenityImagesOnPropertyModel=M.AmenityImagesOnPropertyModel;exports.FloorPlanModel=g.FloorPlanModel;exports.MediaModel=E.MediaModel;exports.PropertyModel=D.PropertyModel;exports.PropertyHighlightModel=q.PropertyHighlightModel;exports.RoomModel=P.RoomModel;exports.StyleModel=A.StyleModel;exports.UnitModel=F.UnitModel;exports.Currency=r.Currency;exports.DeliveryStatus=r.DeliveryStatus;exports.ExternalService=r.ExternalService;exports.FurnitureAvailability=r.FurnitureAvailability;exports.Highlights=r.Highlights;exports.MediaType=r.MediaType;exports.QueueJobStatus=r.QueueJobStatus;exports.RenderStatus=r.RenderStatus;exports.Status=r.Status;exports.UserRole=r.UserRole;exports.RenderedStyleModel=R.RenderedStyleModel;exports.PropertyAmenityModel=f.PropertyAmenityModel;exports.FavoriteUnitModel=I.FavoriteUnitModel;exports.UserModel=T.UserModel;exports.MixpanelProvider=p.MixpanelProvider;exports.useMixpanel=p.useMixpanel;exports.generateUserUUID=O.generateUserUUID;exports.QuestionEnumValues=o.QuestionEnumValues;exports.QuestionnaireInteractionValues=o.QuestionnaireInteractionValues;exports.SortEnumValues=o.SortEnumValues;exports.buildTrackingEvents=o.buildTrackingEvents;exports.useTrackEvent=o.useTrackEvent;exports.useTrackingEvents=o.useTrackingEvents;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./errors.cjs"),e=require("./schema.cjs"),S=require("./db.cjs"),n=require("./api/users.cjs"),m=require("./debug.cjs"),i=require("./storage.cjs"),a=require("./api/favorites.cjs"),d=require("./api/properties.cjs"),s=require("./stores/store.cjs"),U=require("./adapters/zustand-store.cjs"),p=require("./adapters/structured-store.cjs"),y=require("./units/favorites.cjs"),t=require("./features/units/transformers.cjs"),u=require("./features/filters/transformers.cjs"),c=require("./utils/dimensions.cjs"),M=require("./validation.cjs"),v=require("./base/overviewimagesonproperty.cjs"),g=require("./base/amenityimagesonproperty.cjs"),E=require("./base/floorplan.cjs"),P=require("./base/media.cjs"),f=require("./base/property.cjs"),q=require("./base/propertyhighlight.cjs"),D=require("./base/room.cjs"),F=require("./base/style.cjs"),T=require("./base/unit.cjs"),r=require("./base/enums.cjs"),A=require("./base/renderedstyle.cjs"),R=require("./base/propertyamenity.cjs"),I=require("./base/favoriteunit.cjs"),O=require("./base/user.cjs"),h=require("./features/analytics/MixpanelProvider.cjs"),b=require("./features/analytics/generateUserUUID.cjs"),o=require("./features/analytics/analytics.cjs");exports.OpenDBError=l.OpenDBError;exports.SchemaMismatchError=l.SchemaMismatchError;exports.ApiUserSchema=e.ApiUserSchema;exports.AppStoreDataSchema=e.AppStoreDataSchema;exports.FavoritesSchema=e.FavoritesSchema;exports.FiltersSchema=e.FiltersSchema;exports.PropertySchema=e.PropertySchema;exports.PropertyStoreDataSchema=e.PropertyStoreDataSchema;exports.QueryParamsSchema=e.QueryParamsSchema;exports.ResultsModeEnum=e.ResultsModeEnum;exports.SCHEMA_VERSION=e.SCHEMA_VERSION;exports.SortByEnum=e.SortByEnum;exports.TourContactDataSchema=e.TourContactDataSchema;exports.UnifiedStoreDataSchema=e.UnifiedStoreDataSchema;exports.UnitDataSchema=e.UnitDataSchema;exports.UnitFavoriteSchema=e.UnitFavoriteSchema;exports.UnitSchema=e.UnitSchema;exports.UserPropertyStateSchema=e.UserPropertyStateSchema;exports.UserSchema=e.UserSchema;exports.UserUnitDataSchema=e.UserUnitDataSchema;exports.ViewedUnitSchema=e.ViewedUnitSchema;exports.getDB=S.getDB;exports.resetDB=S.resetDB;exports.defaultIdGenerator=n.defaultIdGenerator;exports.ensureUser=n.ensureUser;exports.getUserUUID=n.getUserUUID;exports.debugDump=m.debugDump;exports.exportJSON=m.exportJSON;exports.createORMStringStorage=i.createORMStringStorage;exports.kvGet=i.kvGet;exports.kvRemove=i.kvRemove;exports.kvSet=i.kvSet;exports.getFavoritedUnitsForProperty=a.getFavoritedUnitsForProperty;exports.isUnitFavorited=a.isUnitFavorited;exports.setFavoriteUnit=a.setFavoriteUnit;exports.toggleFavoriteUnit=a.toggleFavoriteUnit;exports.PropertyStore=d.PropertyStore;exports.propertyStore=d.propertyStore;exports.Store=s.UnifiedStore;exports.UnifiedStore=s.UnifiedStore;exports.store=s.store;exports.createUseUnitState=U.createUseUnitState;exports.createZustandUnifiedStore=U.createZustandUnifiedStore;exports.createStructuredStore=p.createStructuredStore;exports.createStructuredStoreActions=p.createStructuredStoreActions;exports.favorites=y.favorites;exports.DEFAULT_PLACEHOLDER_IMAGE=t.DEFAULT_PLACEHOLDER_IMAGE;exports.DEFAULT_WEB_ORIGIN=t.DEFAULT_WEB_ORIGIN;exports.buildExploreUrl=t.buildExploreUrl;exports.buildImageUrl=t.buildImageUrl;exports.transformUnitsApiResponse=t.transformUnitsApiResponse;exports.transformUnitsApiResponseToClient=t.transformUnitsApiResponseToClient;exports.transformUnitsApiResponseToClientFilters=t.transformUnitsApiResponseToClientFilters;exports.defaultSortParamMap=u.defaultSortParamMap;exports.transformFiltersToPreferences=u.transformFiltersToPreferences;exports.transformFiltersToUnitsSearchParams=u.transformFiltersToUnitsSearchParams;exports.imperialToMm=c.imperialToMm;exports.inchesToMm=c.inchesToMm;exports.mmToInches=c.mmToInches;exports.configureValidation=M.configureValidation;exports.OverviewImagesOnPropertyModel=v.OverviewImagesOnPropertyModel;exports.AmenityImagesOnPropertyModel=g.AmenityImagesOnPropertyModel;exports.FloorPlanModel=E.FloorPlanModel;exports.MediaModel=P.MediaModel;exports.PropertyModel=f.PropertyModel;exports.PropertyHighlightModel=q.PropertyHighlightModel;exports.RoomModel=D.RoomModel;exports.StyleModel=F.StyleModel;exports.UnitModel=T.UnitModel;exports.Currency=r.Currency;exports.DeliveryStatus=r.DeliveryStatus;exports.ExternalService=r.ExternalService;exports.FurnitureAvailability=r.FurnitureAvailability;exports.Highlights=r.Highlights;exports.MediaType=r.MediaType;exports.QueueJobStatus=r.QueueJobStatus;exports.RenderStatus=r.RenderStatus;exports.Status=r.Status;exports.UserRole=r.UserRole;exports.RenderedStyleModel=A.RenderedStyleModel;exports.PropertyAmenityModel=R.PropertyAmenityModel;exports.FavoriteUnitModel=I.FavoriteUnitModel;exports.UserModel=O.UserModel;exports.MixpanelProvider=h.MixpanelProvider;exports.useMixpanel=h.useMixpanel;exports.generateUserUUID=b.generateUserUUID;exports.QuestionEnumValues=o.QuestionEnumValues;exports.QuestionnaireInteractionValues=o.QuestionnaireInteractionValues;exports.SortEnumValues=o.SortEnumValues;exports.buildTrackingEvents=o.buildTrackingEvents;exports.useTrackEvent=o.useTrackEvent;exports.useTrackingEvents=o.useTrackingEvents;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { createZustandUnifiedStore, createUseUnitState, type ZustandUnifiedStore
11
11
  export { createStructuredStore, createStructuredStoreActions, type StructuredStore, type StructuredStoreActions } from "./adapters/structured-store";
12
12
  export { favorites } from "./units/favorites";
13
13
  export * from "./features/units/transformers";
14
+ export * from "./features/filters/transformers";
14
15
  export * from "./utils/dimensions";
15
16
  export { configureValidation, type ValidationMode } from "./validation";
16
17
  export * from "./base";