@superbright/indexeddb-orm 0.1.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.cjs +2 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.mjs +9 -0
- package/dist/_virtual/_commonjsHelpers.mjs.map +1 -0
- package/dist/_virtual/dexie.min.cjs +2 -0
- package/dist/_virtual/dexie.min.cjs.map +1 -0
- package/dist/_virtual/dexie.min.mjs +5 -0
- package/dist/_virtual/dexie.min.mjs.map +1 -0
- package/dist/adapters/dexie.cjs +2 -0
- package/dist/adapters/dexie.cjs.map +1 -0
- package/dist/adapters/dexie.mjs +14 -0
- package/dist/adapters/dexie.mjs.map +1 -0
- package/dist/adapters/structured-store.cjs +2 -0
- package/dist/adapters/structured-store.cjs.map +1 -0
- package/dist/adapters/structured-store.mjs +50 -0
- package/dist/adapters/structured-store.mjs.map +1 -0
- package/dist/adapters/zustand-store.cjs +2 -0
- package/dist/adapters/zustand-store.cjs.map +1 -0
- package/dist/adapters/zustand-store.mjs +169 -0
- package/dist/adapters/zustand-store.mjs.map +1 -0
- package/dist/api/favorites.cjs +2 -0
- package/dist/api/favorites.cjs.map +1 -0
- package/dist/api/favorites.mjs +34 -0
- package/dist/api/favorites.mjs.map +1 -0
- package/dist/api/properties.cjs +2 -0
- package/dist/api/properties.cjs.map +1 -0
- package/dist/api/properties.mjs +197 -0
- package/dist/api/properties.mjs.map +1 -0
- package/dist/api/users.cjs +2 -0
- package/dist/api/users.cjs.map +1 -0
- package/dist/api/users.mjs +54 -0
- package/dist/api/users.mjs.map +1 -0
- package/dist/db.cjs +2 -0
- package/dist/db.cjs.map +1 -0
- package/dist/db.mjs +116 -0
- package/dist/db.mjs.map +1 -0
- package/dist/debug.cjs +2 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.mjs +18 -0
- package/dist/debug.mjs.map +1 -0
- package/dist/errors.cjs +2 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.mjs +15 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/features/analytics/analytics.d.ts +520 -397
- package/dist/features/units/transformers.cjs +2 -0
- package/dist/features/units/transformers.cjs.map +1 -0
- package/dist/features/units/transformers.mjs +69 -0
- package/dist/features/units/transformers.mjs.map +1 -0
- package/dist/index.cjs +1 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +72 -14861
- package/dist/index.mjs.map +1 -1
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/dist/dexie.min.cjs +4 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/dist/dexie.min.cjs.map +1 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/dist/dexie.min.mjs +3048 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/dist/dexie.min.mjs.map +1 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/import-wrapper-prod.cjs +2 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/import-wrapper-prod.cjs.map +1 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/import-wrapper-prod.mjs +33 -0
- package/dist/node_modules/.pnpm/dexie@4.2.0/node_modules/dexie/import-wrapper-prod.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.mjs +88 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.mjs +10 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.mjs +8 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.mjs +98 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.mjs +95 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.mjs +62 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.mjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.cjs +2 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.cjs.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.mjs +2401 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.mjs.map +1 -0
- package/dist/schema.cjs +2 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.ts +165 -0
- package/dist/schema.mjs +209 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/storage.cjs +2 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.mjs +54 -0
- package/dist/storage.mjs.map +1 -0
- package/dist/stores/store.cjs +2 -0
- package/dist/stores/store.cjs.map +1 -0
- package/dist/stores/store.mjs +607 -0
- package/dist/stores/store.mjs.map +1 -0
- package/dist/units/favorites.cjs +2 -0
- package/dist/units/favorites.cjs.map +1 -0
- package/dist/units/favorites.mjs +19 -0
- package/dist/units/favorites.mjs.map +1 -0
- package/dist/utils/casing.d.ts +6 -0
- package/dist/utils/collections.d.ts +1 -0
- package/dist/utils/dimensions.cjs +2 -0
- package/dist/utils/dimensions.cjs.map +1 -0
- package/dist/utils/dimensions.d.ts +26 -0
- package/dist/utils/dimensions.mjs +26 -0
- package/dist/utils/dimensions.mjs.map +1 -0
- package/dist/validation.cjs +2 -0
- package/dist/validation.cjs.map +1 -0
- package/dist/validation.mjs +18 -0
- package/dist/validation.mjs.map +1 -0
- package/package.json +23 -4
|
@@ -0,0 +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;
|
|
2
|
+
//# sourceMappingURL=transformers.cjs.map
|
|
@@ -0,0 +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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AW,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"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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) {
|
|
3
|
+
return { data: t };
|
|
4
|
+
}
|
|
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,
|
|
12
|
+
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)
|
|
17
|
+
};
|
|
18
|
+
})) ?? [];
|
|
19
|
+
return {
|
|
20
|
+
total: ((d = t.total) == null ? void 0 : d.value) ?? l.length,
|
|
21
|
+
maxScore: t.max_score ?? null,
|
|
22
|
+
type: t.type ?? "units",
|
|
23
|
+
hits: l
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const A = {
|
|
27
|
+
asap: "ASAP",
|
|
28
|
+
next_month: "Next Month",
|
|
29
|
+
"2_3_months": "2-3 Months",
|
|
30
|
+
all: "Just Browsing"
|
|
31
|
+
}, s = {
|
|
32
|
+
0: "Studio",
|
|
33
|
+
1: "1 Bed",
|
|
34
|
+
2: "2 Bed",
|
|
35
|
+
3: "3+ Bed"
|
|
36
|
+
}, I = new Set(Object.values(s)), p = (t) => {
|
|
37
|
+
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);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
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
|
+
}
|
|
50
|
+
}
|
|
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
|
+
) : void 0,
|
|
56
|
+
bedrooms: p(t.bedrooms),
|
|
57
|
+
cost: t.cost ?? void 0,
|
|
58
|
+
highlights: t.highlights ?? []
|
|
59
|
+
});
|
|
60
|
+
export {
|
|
61
|
+
b as DEFAULT_PLACEHOLDER_IMAGE,
|
|
62
|
+
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
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=transformers.mjs.map
|
|
@@ -0,0 +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,IAA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