@superbright/indexeddb-orm 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/adapters/structured-store.cjs +1 -1
- package/dist/adapters/structured-store.cjs.map +1 -1
- package/dist/adapters/structured-store.d.ts +1 -1
- package/dist/adapters/structured-store.mjs +1 -1
- package/dist/adapters/structured-store.mjs.map +1 -1
- package/dist/adapters/zustand-store.cjs +1 -1
- package/dist/adapters/zustand-store.cjs.map +1 -1
- package/dist/adapters/zustand-store.mjs +12 -11
- package/dist/adapters/zustand-store.mjs.map +1 -1
- package/dist/base/property.d.ts +2 -2
- package/dist/base/unit.d.ts +12 -12
- package/dist/base/user.d.ts +4 -4
- package/dist/features/filters/transformers.cjs +2 -0
- package/dist/features/filters/transformers.cjs.map +1 -0
- package/dist/features/filters/transformers.d.ts +31 -0
- package/dist/features/filters/transformers.mjs +110 -0
- package/dist/features/filters/transformers.mjs.map +1 -0
- package/dist/features/units/transformers.cjs +1 -1
- package/dist/features/units/transformers.cjs.map +1 -1
- package/dist/features/units/transformers.d.ts +12 -10
- package/dist/features/units/transformers.mjs +42 -38
- package/dist/features/units/transformers.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +80 -76
- package/dist/index.mjs.map +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +754 -715
- package/dist/schema.mjs +104 -101
- package/dist/schema.mjs.map +1 -1
- package/dist/stores/store.cjs +1 -1
- package/dist/stores/store.cjs.map +1 -1
- package/dist/stores/store.mjs +229 -240
- package/dist/stores/store.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -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,CA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AWxB,EAAkBe,CAAU,GACvCC,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
|
|
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","transformUnitsApiResponseToClientFilters","params"],"mappings":"gFAAO,MAAMA,EAAqB,sBACrBC,EAA4B,mBA6EnCC,EAAsBC,GACrBA,EACEA,EAAU,WAAW,GAAG,EAAIA,EAAY,IAAIA,CAAS,GADrC,GAIZC,EAAkB,CAC7BC,EACAC,EACAC,EAASP,IACE,GAAGO,CAAM,IAAID,CAAY,SAASD,CAAQ,WAE1CG,EAAgB,CAC3BC,EACAC,EAAcT,IAEV,EAACQ,GAAA,MAAAA,EAAO,QAAS,EAACA,GAAA,MAAAA,EAAO,OAAQ,EAACA,GAAA,MAAAA,EAAO,WAAkBC,EACxD,GAAGD,EAAM,KAAK,GAAGA,EAAM,IAAI,GAAGP,EAAmBO,EAAM,SAAS,CAAC,GAGnE,SAASE,EAEdC,EAAqE,CACrE,MAAO,CAAE,KAAMA,CAAA,CACjB,CAEO,SAASC,EAGdD,EACAN,EACAQ,EACyB,SACzB,MAAMP,GAASO,GAAA,YAAAA,EAAS,SAAUd,EAC5Be,GAAmBD,GAAA,YAAAA,EAAS,mBAAoBb,EAEhDe,IACJC,EAAAL,EAAY,OAAZ,YAAAK,EAAkB,IAAKC,GAAQ,SAC7B,MAAMC,EAAUD,EAAI,SAAW,CAAA,EACzBE,EACJ,OAAOD,EAAO,MAAS,SACnBA,EAAO,KACP,OAAOA,EAAO,OAAU,SACtBA,EAAO,MACP,GAWR,MAT4C,CAC1C,GAAIA,EACJ,MAAAC,EACA,KAAMhB,EAAgB,OAAOe,EAAO,MAAQ,EAAE,EAAGb,EAAcC,CAAM,EACrE,SAAUC,EAAcW,EAAO,MAAOJ,CAAgB,EACtD,kBAAmBP,GAAcS,EAAAE,EAAO,mBAAP,YAAAF,EAA0B,GAAIF,CAAgB,EAC/E,iBAAkBP,GAAca,EAAAF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
|
|
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,G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12
12
|
slug?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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",
|
|
2
|
-
|
|
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
|
|
6
|
-
var
|
|
7
|
-
const
|
|
8
|
-
var
|
|
9
|
-
const
|
|
10
|
-
|
|
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:
|
|
14
|
-
imageUrl:
|
|
15
|
-
secondaryImageUrl:
|
|
16
|
-
tertiaryImageUrl:
|
|
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: ((
|
|
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
|
|
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
|
-
},
|
|
35
|
+
}, c = {
|
|
32
36
|
0: "Studio",
|
|
33
37
|
1: "1 Bed",
|
|
34
38
|
2: "2 Bed",
|
|
35
39
|
3: "3+ Bed"
|
|
36
|
-
},
|
|
40
|
+
}, L = new Set(Object.values(c)), x = (t) => {
|
|
37
41
|
if (!t || t.length === 0) return;
|
|
38
|
-
const
|
|
39
|
-
for (const
|
|
40
|
-
if (typeof
|
|
41
|
-
const
|
|
42
|
-
|
|
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
|
|
46
|
-
for (const
|
|
47
|
-
const l = Number.parseInt(
|
|
48
|
-
!Number.isNaN(l) &&
|
|
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
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
(
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
65
|
+
_ as DEFAULT_PLACEHOLDER_IMAGE,
|
|
62
66
|
h as DEFAULT_WEB_ORIGIN,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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,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MC,IAASF,EAAQ,MAAM,GAAG,EAAE,IAAI,CAACG,MAAMA,EAAE,MAAM;AAErD,eAAWC,KAASF,GAAQ;AAC1B,YAAMG,IAAS,OAAO,SAASD,GAAO,EAAE;AACxC,MAAI,CAAC,OAAO,MAAMC,CAAM,KAAKV,EAAkBU,CAAM,IACnDN,EAAO,IAAIJ,EAAkBU,CAAM,CAAC,IAC3BT,EAAc,IAAIQ,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,KADrC,IAInBC,IAAe,CAACC,MAAuC;AAC3D,MAAI,OAAOA,KAAU,SAAU,QAAOA;AACtC,MAAI,OAAOA,KAAU,YAAY,OAAOA,KAAU;AAChD,WAAO,OAAOA,CAAK;AAGvB,GAEMC,IAAuB,CAC3BC,GACAC,MAGEJ,EAAcI,EAAe,YAAY,KACzCJ,EAAcI,EAAe,aAAa,KAC7BD,GAGJE,IAAkB,CAC7BC,GACAC,GACAC,IAASZ,MACE,GAAGY,CAAM,IAAID,CAAY,SAASD,CAAQ,YAE1CG,IAAgB,CAC3BC,GACAC,IAAcd,MAEV,EAACa,KAAA,QAAAA,EAAO,UAAS,EAACA,KAAA,QAAAA,EAAO,SAAQ,EAACA,KAAA,QAAAA,EAAO,aAAkBC,IACxD,GAAGD,EAAM,KAAK,GAAGA,EAAM,IAAI,GAAGZ,EAAmBY,EAAM,SAAS,CAAC;AAGnE,SAASE,EAEdC,GAAqE;AACrE,SAAO,EAAE,MAAMA,EAAA;AACjB;AAEO,SAASC,EAGdD,GACAN,GACAQ,GACyB;AAjIpB,MAAAC,GAAAC;AAkIL,QAAMT,KAASO,KAAA,gBAAAA,EAAS,WAAUnB,GAC5BsB,KAAmBH,KAAA,gBAAAA,EAAS,qBAAoBlB,GAEhDsB,MACJH,IAAAH,EAAY,SAAZ,gBAAAG,EAAkB,IAAI,CAACI,MAAQ;AAtI5B,QAAAJ,GAAAC;AAuID,UAAMb,IAAUgB,EAAI,WAAW,CAAA,GACzBC,IACJ,OAAOjB,EAAO,QAAS,WACnBA,EAAO,OACP,OAAOA,EA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AMC,wBAAa,IAAA;AAEnB,aAAWC,KAAWF,GAAU;AAC9B,QAAI,OAAOE,KAAY,UAAU;AAC/B,YAAMC,IAAQN,EAAkBK,CAAO;AACvC,MAAIC,KAAOF,EAAO,IAAIE,CAAK;AAC3B;AAAA,IACF;AAEA,UAAMC,IAASF,EAAQ,MAAM,GAAG,EAAE,IAAI,CAACG,MAAMA,EAAE,MAAM;AAErD,eAAWjC,KAASgC,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
|
|
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";
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenDBError as t, SchemaMismatchError as o } from "./errors.mjs";
|
|
2
|
-
import { ApiUserSchema as i, AppStoreDataSchema as m, FavoritesSchema as n, FiltersSchema as
|
|
3
|
-
import { getDB as
|
|
4
|
-
import { defaultIdGenerator as
|
|
2
|
+
import { ApiUserSchema as i, AppStoreDataSchema as m, FavoritesSchema as n, FiltersSchema as s, PropertySchema as p, PropertyStoreDataSchema as S, QueryParamsSchema as f, ResultsModeEnum as l, SCHEMA_VERSION as c, SortByEnum as d, TourContactDataSchema as u, UnifiedStoreDataSchema as x, UnitDataSchema as U, UnitFavoriteSchema as h, UnitSchema as M, UserPropertyStateSchema as v, UserSchema as y, UserUnitDataSchema as g, ViewedUnitSchema as E } from "./schema.mjs";
|
|
3
|
+
import { getDB as D, resetDB as F } from "./db.mjs";
|
|
4
|
+
import { defaultIdGenerator as T, ensureUser as R, getUserUUID as I } from "./api/users.mjs";
|
|
5
5
|
import { debugDump as b, exportJSON as k } from "./debug.mjs";
|
|
6
6
|
import { createORMStringStorage as V, kvGet as B, kvRemove as _, kvSet as G } from "./storage.mjs";
|
|
7
7
|
import { getFavoritedUnitsForProperty as L, isUnitFavorited as Q, setFavoriteUnit as N, toggleFavoriteUnit as w } from "./api/favorites.mjs";
|
|
@@ -10,115 +10,119 @@ import { UnifiedStore as q, UnifiedStore as z, store as K } from "./stores/store
|
|
|
10
10
|
import { createUseUnitState as Y, createZustandUnifiedStore as $ } from "./adapters/zustand-store.mjs";
|
|
11
11
|
import { createStructuredStore as re, createStructuredStoreActions as te } from "./adapters/structured-store.mjs";
|
|
12
12
|
import { favorites as ae } from "./units/favorites.mjs";
|
|
13
|
-
import { DEFAULT_PLACEHOLDER_IMAGE as me, DEFAULT_WEB_ORIGIN as ne, buildExploreUrl as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
13
|
+
import { DEFAULT_PLACEHOLDER_IMAGE as me, DEFAULT_WEB_ORIGIN as ne, buildExploreUrl as se, buildImageUrl as pe, transformUnitsApiResponse as Se, transformUnitsApiResponseToClient as fe, transformUnitsApiResponseToClientFilters as le } from "./features/units/transformers.mjs";
|
|
14
|
+
import { defaultSortParamMap as de, transformFiltersToPreferences as ue, transformFiltersToUnitsSearchParams as xe } from "./features/filters/transformers.mjs";
|
|
15
|
+
import { imperialToMm as he, inchesToMm as Me, mmToInches as ve } from "./utils/dimensions.mjs";
|
|
16
|
+
import { configureValidation as ge } from "./validation.mjs";
|
|
17
|
+
import { OverviewImagesOnPropertyModel as Pe } from "./base/overviewimagesonproperty.mjs";
|
|
18
|
+
import { AmenityImagesOnPropertyModel as Fe } from "./base/amenityimagesonproperty.mjs";
|
|
19
|
+
import { FloorPlanModel as Te } from "./base/floorplan.mjs";
|
|
20
|
+
import { MediaModel as Ie } from "./base/media.mjs";
|
|
21
|
+
import { PropertyModel as be } from "./base/property.mjs";
|
|
22
|
+
import { PropertyHighlightModel as Ce } from "./base/propertyhighlight.mjs";
|
|
23
|
+
import { RoomModel as Be } from "./base/room.mjs";
|
|
24
|
+
import { StyleModel as Ge } from "./base/style.mjs";
|
|
25
|
+
import { UnitModel as Le } from "./base/unit.mjs";
|
|
26
|
+
import { Currency as Ne, DeliveryStatus as we, ExternalService as Je, FurnitureAvailability as We, Highlights as Ze, MediaType as je, QueueJobStatus as qe, RenderStatus as ze, Status as Ke, UserRole as Xe } from "./base/enums.mjs";
|
|
27
|
+
import { RenderedStyleModel as $e } from "./base/renderedstyle.mjs";
|
|
28
|
+
import { PropertyAmenityModel as rr } from "./base/propertyamenity.mjs";
|
|
29
|
+
import { FavoriteUnitModel as or } from "./base/favoriteunit.mjs";
|
|
30
|
+
import { UserModel as ir } from "./base/user.mjs";
|
|
31
|
+
import { MixpanelProvider as nr, useMixpanel as sr } from "./features/analytics/MixpanelProvider.mjs";
|
|
32
|
+
import { generateUserUUID as Sr } from "./features/analytics/generateUserUUID.mjs";
|
|
33
|
+
import { QuestionEnumValues as lr, QuestionnaireInteractionValues as cr, SortEnumValues as dr, buildTrackingEvents as ur, useTrackEvent as xr, useTrackingEvents as Ur } from "./features/analytics/analytics.mjs";
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
+
Fe as AmenityImagesOnPropertyModel,
|
|
35
36
|
i as ApiUserSchema,
|
|
36
37
|
m as AppStoreDataSchema,
|
|
37
|
-
|
|
38
|
+
Ne as Currency,
|
|
38
39
|
me as DEFAULT_PLACEHOLDER_IMAGE,
|
|
39
40
|
ne as DEFAULT_WEB_ORIGIN,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
we as DeliveryStatus,
|
|
42
|
+
Je as ExternalService,
|
|
43
|
+
or as FavoriteUnitModel,
|
|
43
44
|
n as FavoritesSchema,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
s as FiltersSchema,
|
|
46
|
+
Te as FloorPlanModel,
|
|
47
|
+
We as FurnitureAvailability,
|
|
48
|
+
Ze as Highlights,
|
|
49
|
+
Ie as MediaModel,
|
|
50
|
+
je as MediaType,
|
|
51
|
+
nr as MixpanelProvider,
|
|
51
52
|
t as OpenDBError,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
Pe as OverviewImagesOnPropertyModel,
|
|
54
|
+
rr as PropertyAmenityModel,
|
|
55
|
+
Ce as PropertyHighlightModel,
|
|
56
|
+
be as PropertyModel,
|
|
57
|
+
p as PropertySchema,
|
|
57
58
|
W as PropertyStore,
|
|
58
59
|
S as PropertyStoreDataSchema,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
f as QueryParamsSchema,
|
|
61
|
+
lr as QuestionEnumValues,
|
|
62
|
+
cr as QuestionnaireInteractionValues,
|
|
63
|
+
qe as QueueJobStatus,
|
|
64
|
+
ze as RenderStatus,
|
|
65
|
+
$e as RenderedStyleModel,
|
|
66
|
+
l as ResultsModeEnum,
|
|
67
|
+
Be as RoomModel,
|
|
68
|
+
c as SCHEMA_VERSION,
|
|
68
69
|
o as SchemaMismatchError,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
d as SortByEnum,
|
|
71
|
+
dr as SortEnumValues,
|
|
72
|
+
Ke as Status,
|
|
72
73
|
q as Store,
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
Ge as StyleModel,
|
|
75
|
+
u as TourContactDataSchema,
|
|
75
76
|
z as UnifiedStore,
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
x as UnifiedStoreDataSchema,
|
|
78
|
+
U as UnitDataSchema,
|
|
78
79
|
h as UnitFavoriteSchema,
|
|
79
|
-
|
|
80
|
+
Le as UnitModel,
|
|
80
81
|
M as UnitSchema,
|
|
81
|
-
|
|
82
|
+
ir as UserModel,
|
|
82
83
|
v as UserPropertyStateSchema,
|
|
83
|
-
|
|
84
|
+
Xe as UserRole,
|
|
84
85
|
y as UserSchema,
|
|
85
86
|
g as UserUnitDataSchema,
|
|
86
87
|
E as ViewedUnitSchema,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
se as buildExploreUrl,
|
|
89
|
+
pe as buildImageUrl,
|
|
90
|
+
ur as buildTrackingEvents,
|
|
91
|
+
ge as configureValidation,
|
|
91
92
|
V as createORMStringStorage,
|
|
92
93
|
re as createStructuredStore,
|
|
93
94
|
te as createStructuredStoreActions,
|
|
94
95
|
Y as createUseUnitState,
|
|
95
96
|
$ as createZustandUnifiedStore,
|
|
96
97
|
b as debugDump,
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
T as defaultIdGenerator,
|
|
99
|
+
de as defaultSortParamMap,
|
|
100
|
+
R as ensureUser,
|
|
99
101
|
k as exportJSON,
|
|
100
102
|
ae as favorites,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
Sr as generateUserUUID,
|
|
104
|
+
D as getDB,
|
|
103
105
|
L as getFavoritedUnitsForProperty,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
I as getUserUUID,
|
|
107
|
+
he as imperialToMm,
|
|
108
|
+
Me as inchesToMm,
|
|
107
109
|
Q as isUnitFavorited,
|
|
108
110
|
B as kvGet,
|
|
109
111
|
_ as kvRemove,
|
|
110
112
|
G as kvSet,
|
|
111
|
-
|
|
113
|
+
ve as mmToInches,
|
|
112
114
|
Z as propertyStore,
|
|
113
115
|
F as resetDB,
|
|
114
116
|
N as setFavoriteUnit,
|
|
115
117
|
K as store,
|
|
116
118
|
w as toggleFavoriteUnit,
|
|
119
|
+
ue as transformFiltersToPreferences,
|
|
120
|
+
xe as transformFiltersToUnitsSearchParams,
|
|
117
121
|
Se as transformUnitsApiResponse,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
fe as transformUnitsApiResponseToClient,
|
|
123
|
+
le as transformUnitsApiResponseToClientFilters,
|
|
124
|
+
sr as useMixpanel,
|
|
125
|
+
xr as useTrackEvent,
|
|
126
|
+
Ur as useTrackingEvents
|
|
123
127
|
};
|
|
124
128
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/schema.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.cjs"),m=1,g=t.object({uuid:t.string().uuid(),createdAt:t.string().datetime().optional()}),u=t.object({isFavorite:t.boolean().optional(),viewedDate:t.string().optional()}),c=u,e=t.union([t.string(),t.number(),t.boolean(),t.record(t.unknown())]),b=t.union([e,t.array(e)]),n=t.object({date_availability:b.nullable().optional(),qty_bedrooms:t.union([t.array(e),t.null()]).optional(),base_price:t.number().nullable().optional(),highlights:t.array(e).optional()}),i=t.enum(["all","bestFit","closestMatch","favorites","loading"]),a=t.enum(["relevance","newest","cost_low_to_high","cost_high_to_low"]),r=t.object({limit:t.number().default(10),page:t.number().default(1),sortBy:a.default("relevance"),base_price:t.number().nullable().optional(),date_availability:t.array(t.string()).optional(),qty_bedrooms:t.array(t.number()).optional(),highlights:t.array(t.string()).optional(),nearBuilding:t.array(t.string()).optional(),nearNeighbourhood:t.array(t.string()).optional()}),y=t.object({data:t.record(c),filters:n,tempFilters:n,apiFilters:r,resultsMode:i,propertySlug:t.string().nullable(),resolvedQuestionnaireValues:t.record(t.array(t.string())),sortBy:a}),o=t.object({id:t.union([t.number().int(),t.string()]).optional(),title:t.string(),slug:t.string().nullable().optional(),qty_bedrooms:t.coerce.number().nullable().optional(),qty_bathrooms:t.coerce.number().nullable().optional(),base_price:t.coerce.number().nullable().optional(),dim_sq_ft:t.coerce.number().nullable().optional(),propertyId:t.union([t.number().int(),t.string()]).optional(),is_available:t.boolean().optional(),createdAt:t.string().datetime().optional(),updatedAt:t.string().datetime().optional(),date_availability:t.string().datetime().nullable().optional(),unitSetAvailableOn:t.string().datetime().nullable().optional(),floorPlanId:t.union([t.number().int(),t.string()]).nullable().optional(),property:t.unknown().optional(),amenities:t.array(t.unknown()).optional(),highlights:t.array(t.unknown()).optional(),floorPlan:t.unknown().nullable().optional(),renderedStyle:t.array(t.unknown()).optional(),video:t.unknown().nullable().optional(),videoThumbnail:t.unknown().nullable().optional(),embedGif:t.unknown().nullable().optional(),userId:t.union([t.number().int(),t.string()]).optional(),user:t.unknown().optional(),status:t.string().optional(),external_id:t.string().nullable().optional(),unitRenderedStyles:t.array(t.unknown()).optional()}),l=t.object({id:t.union([t.number().int(),t.string()]),createdAt:t.string().datetime(),updatedAt:t.string().datetime(),title:t.string(),slug:t.string().nullable().optional(),description:t.string(),contact_name:t.string().nullable().optional(),contact_email:t.string().optional(),contact_phone:t.string().nullable().optional(),notification_email:t.string().nullable().optional(),logo:t.unknown().nullable().optional(),leadMedia:t.unknown().nullable().optional(),overviewImages:t.array(t.unknown()).optional(),amenityImages:t.array(t.unknown()).optional(),address_street:t.string().optional(),address_city:t.string().optional(),address_state:t.string().nullable().optional(),ingestionFileName:t.string().nullable().optional(),address_zip:t.string().optional(),address_country:t.string().optional(),units:t.array(o).optional(),amenities:t.array(t.unknown()).optional(),highlights:t.array(t.unknown()).optional(),externalServices:t.array(t.unknown()).optional(),userId:t.union([t.number().int(),t.string()]).optional(),user:t.unknown().optional(),status:t.string().optional(),floorPlans:t.array(t.unknown()).optional()}),h=t.object({id:t.union([t.number().int(),t.string()]).optional(),email:t.string().email().optional(),first_name:t.string().optional(),last_name:t.string().optional(),password:t.string().optional(),salt:t.string().optional(),role:t.string().optional(),Property:t.array(l).optional(),Unit:t.array(o).optional(),floorPlans:t.array(t.unknown()).optional(),createdAt:t.string().datetime().optional(),updatedAt:t.string().datetime().optional()}),p=t.object({unitId:t.string(),viewedDate:t.string()}),d=t.object({timezone:t.string().optional(),favouriteUnits:t.array(t.coerce.string()).optional(),preferences:t.record(t.unknown()).optional()}),s=t.object({id:t.coerce.string(),slug:t.string(),favoritedUnits:t.array(t.string()),tourContactedOn:t.string().nullable(),viewedUnits:t.array(p),questionnaireResults:t.unknown().nullable().optional(),tourContactData:d.nullable().optional(),data:l.optional()}),S=t.object({data:t.record(s),propertySlug:t.string().nullable(),propertyId:t.string().nullable(),hasPreviouslySearched:t.array(t.string())}),w=t.object({id:t.number().int(),userId:t.number().int(),unitId:t.number().int(),createdAt:t.string().datetime()}),_=t.object({unitIds:t.array(t.string()),updatedAt:t.string().datetime()}),v=t.object({properties:t.record(s),currentPropertyId:t.string().nullable(),currentPropertySlug:t.string().nullable(),hasPreviouslySearched:t.array(t.string()),unitResults:t.array(o),filters:n,tempFilters:n,apiFilters:r,resultsMode:i,resolvedQuestionnaireValues:t.record(t.array(t.string())),sortBy:a});exports.ApiUserSchema=h;exports.AppStoreDataSchema=y;exports.FavoritesSchema=_;exports.FiltersSchema=n;exports.PropertySchema=l;exports.PropertyStoreDataSchema=S;exports.QueryParamsSchema=r;exports.ResultsModeEnum=i;exports.SCHEMA_VERSION=m;exports.SortByEnum=a;exports.TourContactDataSchema=d;exports.UnifiedStoreDataSchema=v;exports.UnitDataSchema=c;exports.UnitFavoriteSchema=w;exports.UnitSchema=o;exports.UserPropertyStateSchema=s;exports.UserSchema=g;exports.UserUnitDataSchema=u;exports.ViewedUnitSchema=p;
|
|
2
2
|
//# sourceMappingURL=schema.cjs.map
|