@bpd-library/utilities 2.0.11 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/api/http.d.ts +9 -8
  2. package/dist/api/http.js.map +1 -1
  3. package/dist/api-utilities/api-utilities.types.d.ts +4 -4
  4. package/dist/api-utilities/api-utilities.types.js +1 -0
  5. package/dist/api-utilities/decimal-range/merge-specification-range.d.ts +1 -1
  6. package/dist/api-utilities/get/coordinates.js.map +1 -1
  7. package/dist/debounce.d.ts +2 -2
  8. package/dist/extended-api-models/extended-area.js.map +1 -1
  9. package/dist/extended-api-models/status/apartment-building-status.d.ts +1 -1
  10. package/dist/extended-api-models/status/apartment-building-status.js.map +1 -1
  11. package/dist/extended-api-models/status/construction-number-status.js +2 -1
  12. package/dist/extended-api-models/status/construction-number-status.js.map +1 -1
  13. package/dist/extended-api-models/status/property-type-status.d.ts +1 -1
  14. package/dist/extended-api-models/status/property-type-status.js.map +1 -1
  15. package/dist/extended-api-models/utilities/apartment-building-view.js +4 -1
  16. package/dist/extended-api-models/utilities/apartment-building-view.js.map +1 -1
  17. package/dist/extended-api-models/utilities/is-apartment.js.map +1 -1
  18. package/dist/function-is-true.js +1 -1
  19. package/dist/function-is-true.js.map +1 -1
  20. package/dist/generated/bpd-client.d.ts +80 -80
  21. package/dist/geometry/geometry.d.ts +4 -1
  22. package/dist/hooks/use-click-outside.d.ts +3 -3
  23. package/dist/hooks/use-lazy.d.ts +7 -2
  24. package/dist/hooks/use-scroll-position.d.ts +3 -3
  25. package/dist/hooks/use-scroll-to.js +2 -2
  26. package/dist/hooks/use-scroll-to.js.map +1 -1
  27. package/dist/is-touch.js +4 -7
  28. package/dist/is-touch.js.map +1 -1
  29. package/dist/media-query/media-query.types.d.ts +4 -4
  30. package/dist/media-query/media-query.types.js +1 -0
  31. package/dist/store/generators/create-local-storage-store.js.map +1 -1
  32. package/dist/store/polyfill/index.d.ts +1 -1
  33. package/dist/store/store.js.map +1 -1
  34. package/dist/store/store.types.d.ts +9 -9
  35. package/dist/store/store.types.js +1 -0
  36. package/dist/to-currency.d.ts +1 -1
  37. package/package.json +4 -11
@@ -10,18 +10,19 @@ export declare class HttpError extends Error {
10
10
  body?: any;
11
11
  constructor(input: HttpErrorInput);
12
12
  }
13
- export declare type AbortFunction = () => void;
14
- declare type RequestFn = <T = any, I = any>(url: string, data: I, config?: RequestConfig) => Promise<T>;
15
- declare type RequestGetFn = <T = any, I = any>(url: string, data?: I, config?: RequestConfig) => Promise<T>;
16
- declare type BeforeHook = (client: HttpClient) => Promise<void> | void;
17
- declare type ErrorHook = <T = any>(err: HttpError, request: () => Promise<T>) => any;
18
- declare type HttpClientInit = RequestInit & {
13
+ export type AbortFunction = () => void;
14
+ type Token = string | undefined;
15
+ type RequestFn = <T = any, I = any>(url: string, data: I, config?: RequestConfig) => Promise<T>;
16
+ type RequestGetFn = <T = any, I = any>(url: string, data?: I, config?: RequestConfig) => Promise<T>;
17
+ type BeforeHook = (client: HttpClient) => Promise<void> | void;
18
+ type ErrorHook = <T = any>(err: HttpError, request: () => Promise<T>) => any;
19
+ type HttpClientInit = RequestInit & {
19
20
  baseUrl?: string;
20
21
  returnType?: 'json' | 'text' | 'blob';
21
22
  beforeHook?: BeforeHook;
22
23
  onError?: ErrorHook;
23
24
  };
24
- export declare type RequestConfig = HttpClientInit & {
25
+ export type RequestConfig = HttpClientInit & {
25
26
  createAbort?: (abortFunction: AbortFunction) => void;
26
27
  };
27
28
  export declare class HttpClient {
@@ -35,7 +36,7 @@ export declare class HttpClient {
35
36
  put: RequestFn;
36
37
  patch: RequestFn;
37
38
  delete: RequestFn;
38
- setToken: (token: string | undefined) => string | undefined;
39
+ setToken: (token: Token) => Token;
39
40
  setBaseUrl: (baseUrl: string) => string;
40
41
  setSecurityHeaders: (name: string, value: string) => void;
41
42
  private setAuthenticationHeaders;
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":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AC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import qs from 'qs';\n\nexport interface HttpErrorInput {\n message: string;\n statusCode: number;\n response?: Response;\n body?: any;\n}\n\nexport class HttpError extends Error {\n statusCode: number;\n response?: Response;\n body?: any;\n\n constructor(input: HttpErrorInput) {\n super(input.message);\n this.response = input.response;\n this.statusCode = input.statusCode;\n this.body = input.body;\n this.name = 'HttpError';\n }\n}\n\nexport type AbortFunction = () => void;\ntype Token = string | undefined;\ntype RequestFn = <T = any, I = any>(url: string, data: I, config?: RequestConfig) => Promise<T>;\ntype RequestGetFn = <T = any, I = any>(url: string, data?: I, config?: RequestConfig) => Promise<T>;\ntype BeforeHook = (client: HttpClient) => Promise<void> | void;\ntype ErrorHook = <T = any>(err: HttpError, request: () => Promise<T>) => any;\ntype HttpClientInit = RequestInit & {\n baseUrl?: string;\n returnType?: 'json' | 'text' | 'blob';\n /** This function is called before every request. This is where you would check if your token is still valid */\n beforeHook?: BeforeHook;\n /** Function that is called if an error occurs */\n onError?: ErrorHook;\n};\nexport type RequestConfig = HttpClientInit & {\n createAbort?: (abortFunction: AbortFunction) => void;\n};\n\n/**\n * Wrapper around fetch\n */\nexport class HttpClient {\n private defaultConfig: RequestConfig = {\n returnType: 'json',\n };\n\n private config: RequestConfig = {};\n private token: Token;\n\n constructor(config: HttpClientInit = {}) {\n this.config = {\n ...this.defaultConfig,\n ...config,\n };\n }\n\n /**\n *\n *\n * @private\n * @param {'GET'} method\n * @returns {RequestGetFn}\n * @memberof HttpClient\n */\n private createRequest(method: 'GET'): RequestGetFn;\n private createRequest(method: string): RequestFn;\n private createRequest(method: 'GET' | string): RequestFn {\n return (url, data, config) => {\n if (method === 'GET') {\n let getUrl = url;\n if (data) {\n getUrl = url + '?' + qs.stringify(data);\n }\n\n return this.request(getUrl, {\n ...config,\n method: 'GET',\n });\n }\n\n const contentType = config && config.headers && (config.headers as any)['Content-Type'];\n\n return this.request(url, {\n ...config,\n method,\n body: this.createBody(data, contentType),\n });\n };\n }\n\n public get = this.createRequest('GET');\n public post = this.createRequest('POST');\n public put = this.createRequest('PUT');\n public patch = this.createRequest('PATCH');\n public delete = this.createRequest('DELETE');\n\n public setToken = (token: Token) => (this.token = token);\n public setBaseUrl = (baseUrl: string) => (this.config.baseUrl = baseUrl);\n public setSecurityHeaders = (name: string, value: string) => {\n if (this.config?.headers) {\n this.config.headers = {...this.config.headers, [name]: value}\n }\n }\n\n private setAuthenticationHeaders(config: RequestConfig) {\n // if authenticated set bearer token\n if (this.token) {\n config.headers = {\n ...config.headers,\n Authorization: `Bearer ${this.token}`,\n };\n }\n }\n\n /**\n *\n *\n * @private\n * @memberof HttpClient\n */\n private setAbortController = (config: RequestConfig) => {\n const { createAbort } = config;\n if (createAbort) {\n if (typeof AbortController !== undefined) {\n const controller = new AbortController();\n const { signal } = controller;\n config.signal = signal;\n createAbort(controller.abort.bind(controller));\n } else {\n createAbort(() =>\n console.log('The AbortController api isnt available in your browser'),\n );\n }\n }\n };\n\n /**\n *\n *\n * @template T\n * @param {(string | URL)} url\n * @param {RequestConfig} [requestConfig={}]\n * @returns {Promise<T>}\n * @memberof HttpClient\n */\n public async request<T>(url: string | URL, requestConfig: RequestConfig = {}): Promise<T> {\n const { beforeHook } = this.config;\n\n const config: RequestConfig = {\n ...this.config,\n ...requestConfig,\n };\n\n const { baseUrl = '' } = config;\n\n this.setAbortController(config);\n\n if (beforeHook) {\n await beforeHook(this);\n }\n\n this.setAuthenticationHeaders(config);\n\n const requestFn = fetch(baseUrl + url, config)\n .then(this.handleError)\n .then((res) => this.handleSuccess(res, config)) as Promise<T>;\n\n return requestFn.catch((err) =>\n this.onError<T>(err, () => this.request(url, requestConfig)),\n );\n }\n\n /**\n *\n *\n * @private\n * @param {Response} res\n * @param {RequestConfig} config\n * @returns\n * @memberof HttpClient\n */\n private handleSuccess(res: Response, config: RequestConfig) {\n const { returnType = 'json' } = config;\n\n if (res.status === 204 || res.status === 201 || !res[returnType]) {\n return res;\n }\n\n return res[returnType]();\n }\n\n private async onError<T = any>(err: HttpError, requestFn: () => Promise<T>) {\n const { onError } = this.config;\n\n if (onError) {\n return onError(err, requestFn);\n }\n\n throw err;\n }\n\n /**\n * createBody is responsible for creating a body based on the content type\n *\n * @param body The body\n * @param contentType The content type\n */\n private createBody(body: any, contentType: string): any {\n switch (contentType) {\n case 'application/json':\n return JSON.stringify(body);\n case 'application/x-www-form-urlencoded':\n return new URLSearchParams(body);\n default:\n return JSON.stringify(body);\n }\n }\n\n /**\n * Handles the errors if the fetch request fails and throws a HttpError\n * @param response\n */\n private async handleError(response: Response) {\n if (response.ok) {\n return response;\n }\n\n const responseBody = await response.text();\n let body: any = response;\n\n try {\n body = JSON.parse(responseBody);\n } catch (err) {\n body = responseBody;\n }\n\n const error = {\n message: `HttpError: ${response.status} - ${response.statusText}`,\n statusCode: response.status,\n response,\n body,\n };\n\n console.error(error);\n throw new HttpError(error);\n }\n}\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AASpB,MAAM,OAAO,SAAU,SAAQ,KAAK;IAKhC,YAAY,KAAqB;QAC7B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;CACJ;AAuBD,MAAM,OAAO,UAAU;IAQnB,YAAY,SAAyB,EAAE;QAP/B,kBAAa,GAAkB;YACnC,UAAU,EAAE,MAAM;SACrB,CAAC;QAEM,WAAM,GAAkB,EAAE,CAAC;QA4C5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,IAAI,CAAC,CAAC;YAChC,KAAK,mCAAmC;gBACpC,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;YACrC;gBACI,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SACnC;IACL,CAAC;IAMO,KAAK,CAAC,WAAW,CAAC,QAAkB;QACxC,IAAI,QAAQ,CAAC,EAAE,EAAE;YACb,OAAO,QAAQ,CAAC;SACnB;QAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,IAAI,GAAQ,QAAQ,CAAC;QAEzB,IAAI;YACA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACV,IAAI,GAAG,YAAY,CAAC;SACvB;QAED,MAAM,KAAK,GAAG;YACV,OAAO,EAAE,cAAc,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,UAAU,EAAE;YACjE,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,QAAQ;YACR,IAAI;SACP,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import qs from 'qs';\n\nexport interface HttpErrorInput {\n message: string;\n statusCode: number;\n response?: Response;\n body?: any;\n}\n\nexport class HttpError extends Error {\n statusCode: number;\n response?: Response;\n body?: any;\n\n constructor(input: HttpErrorInput) {\n super(input.message);\n this.response = input.response;\n this.statusCode = input.statusCode;\n this.body = input.body;\n this.name = 'HttpError';\n }\n}\n\nexport type AbortFunction = () => void;\ntype Token = string | undefined;\ntype RequestFn = <T = any, I = any>(url: string, data: I, config?: RequestConfig) => Promise<T>;\ntype RequestGetFn = <T = any, I = any>(url: string, data?: I, config?: RequestConfig) => Promise<T>;\ntype BeforeHook = (client: HttpClient) => Promise<void> | void;\ntype ErrorHook = <T = any>(err: HttpError, request: () => Promise<T>) => any;\ntype HttpClientInit = RequestInit & {\n baseUrl?: string;\n returnType?: 'json' | 'text' | 'blob';\n /** This function is called before every request. This is where you would check if your token is still valid */\n beforeHook?: BeforeHook;\n /** Function that is called if an error occurs */\n onError?: ErrorHook;\n};\nexport type RequestConfig = HttpClientInit & {\n createAbort?: (abortFunction: AbortFunction) => void;\n};\n\n/**\n * Wrapper around fetch\n */\nexport class HttpClient {\n private defaultConfig: RequestConfig = {\n returnType: 'json',\n };\n\n private config: RequestConfig = {};\n private token: Token;\n\n constructor(config: HttpClientInit = {}) {\n this.config = {\n ...this.defaultConfig,\n ...config,\n };\n }\n\n /**\n *\n *\n * @private\n * @param {'GET'} method\n * @returns {RequestGetFn}\n * @memberof HttpClient\n */\n private createRequest(method: 'GET'): RequestGetFn;\n private createRequest(method: string): RequestFn;\n private createRequest(method: 'GET' | string): RequestFn {\n return (url, data, config) => {\n if (method === 'GET') {\n let getUrl = url;\n if (data) {\n getUrl = url + '?' + qs.stringify(data);\n }\n\n return this.request(getUrl, {\n ...config,\n method: 'GET',\n });\n }\n\n const contentType = config && config.headers && (config.headers as any)['Content-Type'];\n\n return this.request(url, {\n ...config,\n method,\n body: this.createBody(data, contentType),\n });\n };\n }\n\n public get = this.createRequest('GET');\n public post = this.createRequest('POST');\n public put = this.createRequest('PUT');\n public patch = this.createRequest('PATCH');\n public delete = this.createRequest('DELETE');\n\n public setToken = (token: Token) => (this.token = token);\n public setBaseUrl = (baseUrl: string) => (this.config.baseUrl = baseUrl);\n public setSecurityHeaders = (name: string, value: string) => {\n if (this.config?.headers) {\n this.config.headers = {...this.config.headers, [name]: value}\n }\n }\n\n private setAuthenticationHeaders(config: RequestConfig) {\n // if authenticated set bearer token\n if (this.token) {\n config.headers = {\n ...config.headers,\n Authorization: `Bearer ${this.token}`,\n };\n }\n }\n\n /**\n *\n *\n * @private\n * @memberof HttpClient\n */\n private setAbortController = (config: RequestConfig) => {\n const { createAbort } = config;\n if (createAbort) {\n if (typeof AbortController !== undefined) {\n const controller = new AbortController();\n const { signal } = controller;\n config.signal = signal;\n createAbort(controller.abort.bind(controller));\n } else {\n createAbort(() =>\n console.log('The AbortController api isnt available in your browser'),\n );\n }\n }\n };\n\n /**\n *\n *\n * @template T\n * @param {(string | URL)} url\n * @param {RequestConfig} [requestConfig={}]\n * @returns {Promise<T>}\n * @memberof HttpClient\n */\n public async request<T>(url: string | URL, requestConfig: RequestConfig = {}): Promise<T> {\n const { beforeHook } = this.config;\n\n const config: RequestConfig = {\n ...this.config,\n ...requestConfig,\n };\n\n const { baseUrl = '' } = config;\n\n this.setAbortController(config);\n\n if (beforeHook) {\n await beforeHook(this);\n }\n\n this.setAuthenticationHeaders(config);\n\n const requestFn = fetch(baseUrl + url, config)\n .then(this.handleError)\n .then((res) => this.handleSuccess(res, config)) as Promise<T>;\n\n return requestFn.catch((err) =>\n this.onError<T>(err, () => this.request(url, requestConfig)),\n );\n }\n\n /**\n *\n *\n * @private\n * @param {Response} res\n * @param {RequestConfig} config\n * @returns\n * @memberof HttpClient\n */\n private handleSuccess(res: Response, config: RequestConfig) {\n const { returnType = 'json' } = config;\n\n if (res.status === 204 || res.status === 201 || !res[returnType]) {\n return res;\n }\n\n return res[returnType]();\n }\n\n private async onError<T = any>(err: HttpError, requestFn: () => Promise<T>) {\n const { onError } = this.config;\n\n if (onError) {\n return onError(err, requestFn);\n }\n\n throw err;\n }\n\n /**\n * createBody is responsible for creating a body based on the content type\n *\n * @param body The body\n * @param contentType The content type\n */\n private createBody(body: any, contentType: string): any {\n switch (contentType) {\n case 'application/json':\n return JSON.stringify(body);\n case 'application/x-www-form-urlencoded':\n return new URLSearchParams(body);\n default:\n return JSON.stringify(body);\n }\n }\n\n /**\n * Handles the errors if the fetch request fails and throws a HttpError\n * @param response\n */\n private async handleError(response: Response) {\n if (response.ok) {\n return response;\n }\n\n const responseBody = await response.text();\n let body: any = response;\n\n try {\n body = JSON.parse(responseBody);\n } catch (err) {\n body = responseBody;\n }\n\n const error = {\n message: `HttpError: ${response.status} - ${response.statusText}`,\n statusCode: response.status,\n response,\n body,\n };\n\n console.error(error);\n throw new HttpError(error);\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { MapDataItem } from '@bpd-library/types';
2
2
  import { INCLUDED_PROPERTIES } from '../extended-api-models/included-properties';
3
3
  import { ApartmentBuildingModel, AreaProjectModel, AreaStatus, ConstructionNumberModel, DistrictModel, ProjectPhaseModel, ProjectPhaseStatus, PropertyTypeModel } from '../generated';
4
- declare type PropertyTypeStatus = 'InPreparation' | 'SaleSoon' | 'SaleStarted' | 'AssigningOn' | 'AmountAvailable' | 'InOption' | 'Sold' | 'UnderConstruction' | 'ForRent' | 'Rented';
5
- declare type ApartmentBuildingStatus = 'InPreparation' | 'SaleSoon' | 'SaleStarted' | 'AssigningOn' | 'AmountAvailable' | 'Available' | 'ForRent' | 'InOption' | 'Sold' | 'Rented' | 'UnderConstruction';
6
- declare type GeneratedConstructionNumberStatus = 'InPreparation' | 'InOption' | 'Available' | 'AssigningOn' | 'Sold' | 'Rented' | 'Reserved' | 'UnderConstruction';
4
+ type PropertyTypeStatus = 'InPreparation' | 'SaleSoon' | 'SaleStarted' | 'AssigningOn' | 'AmountAvailable' | 'InOption' | 'Sold' | 'UnderConstruction' | 'ForRent' | 'Rented';
5
+ type ApartmentBuildingStatus = 'InPreparation' | 'SaleSoon' | 'SaleStarted' | 'AssigningOn' | 'AmountAvailable' | 'Available' | 'ForRent' | 'InOption' | 'Sold' | 'Rented' | 'UnderConstruction';
6
+ type GeneratedConstructionNumberStatus = 'InPreparation' | 'InOption' | 'Available' | 'AssigningOn' | 'Sold' | 'Rented' | 'Reserved' | 'UnderConstruction';
7
7
  interface ExtendedConstructionNumber extends Pick<ConstructionNumberModel, 'id' | typeof INCLUDED_PROPERTIES.constructionNumber[number]> {
8
8
  areaProject?: ExtendedAreaProject;
9
9
  propertyType?: ExtendedPropertyType;
@@ -45,5 +45,5 @@ interface ExtendedAreaProject extends Pick<AreaProjectModel, 'id' | typeof INCLU
45
45
  mapDataItems?: MapDataItem[];
46
46
  objectType: 'areaProject';
47
47
  }
48
- declare type ExtendedApiObject = ExtendedConstructionNumber | ExtendedApartmentBuilding | ExtendedPropertyType | ExtendedProjectPhase | ExtendedDistrict | ExtendedAreaProject;
48
+ type ExtendedApiObject = ExtendedConstructionNumber | ExtendedApartmentBuilding | ExtendedPropertyType | ExtendedProjectPhase | ExtendedDistrict | ExtendedAreaProject;
49
49
  export { ExtendedConstructionNumber, ExtendedPropertyType, ExtendedApartmentBuilding, ExtendedProjectPhase, ExtendedDistrict, ExtendedAreaProject, ExtendedApiObject, PropertyTypeStatus, ApartmentBuildingStatus, GeneratedConstructionNumberStatus, };
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=api-utilities.types.js.map
@@ -1,5 +1,5 @@
1
1
  import { ConstructionNumberModel, ConstructionNumberSpecifications, DecimalRange, ProjectPhaseModel, PropertySpecifications, PropertyTypeModel } from '../../generated';
2
- declare type PropertyKeys = keyof PropertySpecifications;
2
+ type PropertyKeys = keyof PropertySpecifications;
3
3
  interface MergeSpecificationRange {
4
4
  (obj: {
5
5
  propertyTypes: PropertyTypeModel[];
@@ -1 +1 @@
1
- {"version":3,"file":"coordinates.js","sourceRoot":"","sources":["../../../src/api-utilities/get/coordinates.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,mBAAmB,GAAG,CAAC,WAAwB,EAAE,EAAE;IACrD,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/C,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE;QACvC,OAAO,SAAS,GAAG,GAAG,IAAI,SAAS,GAAG,CAAC,GAAG,IAAI,QAAQ,GAAG,CAAC,EAAE,IAAI,QAAQ,GAAG,EAAE,CAAC;IACl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,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import { Coordinate, Coordinates } from '@bpd-library/types';\n\nimport {\n AreaProjectModel,\n ConstructionNumberModel,\n DistrictModel,\n ProjectPhaseModel,\n PropertyTypeModel,\n} from '../../generated';\nimport { calculateCenter } from '../../geometry';\n\nconst validateCoordinates = (coordinates: Coordinates) => {\n const validates = coordinates.every((coordinate) =>\n coordinate.every(([longitude, latitude]) => {\n return longitude < 180 && longitude > -180 && latitude > -90 && latitude < 90;\n }),\n );\n\n return validates;\n};\n\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n): Coordinates | false;\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n options?: { as?: 'coordinates' },\n): Coordinates | false;\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n options?: { as?: 'coordinate' },\n): Coordinate | false;\n\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n options?: { as?: 'coordinates' | 'coordinate' },\n) {\n const { location } = apiObject;\n\n let coordinates: Coordinates | undefined;\n\n if (location) {\n coordinates = [[location as Coordinate]];\n } else if (getApiObjectCoordinates(apiObject)) {\n coordinates = getApiObjectCoordinates(apiObject);\n coordinates = coordinates ? [[calculateCenter(coordinates)]] : undefined;\n }\n\n if (!coordinates || !validateCoordinates(coordinates)) return false;\n\n if (options?.as === 'coordinate') return coordinates[0][0];\n\n return coordinates;\n}\n\nconst getApiObjectCoordinates = ({\n geometry,\n}: DistrictModel | ProjectPhaseModel | PropertyTypeModel | ConstructionNumberModel):\n | Coordinates\n | undefined => {\n if (!geometry?.length) return;\n\n const coordinates = geometry\n .filter(({ coordinates }) => !!coordinates)\n .map(({ coordinates }) => coordinates as Coordinate[]);\n\n return coordinates?.length ? coordinates : undefined;\n};\n\nexport { validateCoordinates, getApiObjectCenter, getApiObjectCoordinates };\n"]}
1
+ {"version":3,"file":"coordinates.js","sourceRoot":"","sources":["../../../src/api-utilities/get/coordinates.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,mBAAmB,GAAG,CAAC,WAAwB,EAAE,EAAE;IACrD,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/C,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE;QACvC,OAAO,SAAS,GAAG,GAAG,IAAI,SAAS,GAAG,CAAC,GAAG,IAAI,QAAQ,GAAG,CAAC,EAAE,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClF,CAAC,CAAC,CACL,CAAC;IAEF,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAcF,SAAS,kBAAkB,CACvB,SAA+D,EAC/D,OAA+C;IAE/C,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAE/B,IAAI,WAAoC,CAAC;IAEzC,IAAI,QAAQ,EAAE;QACV,WAAW,GAAG,CAAC,CAAC,QAAsB,CAAC,CAAC,CAAC;KAC5C;SAAM,IAAI,uBAAuB,CAAC,SAAS,CAAC,EAAE;QAC3C,WAAW,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACjD,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;KAC5E;IAED,IAAI,CAAC,WAAW,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpE,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,MAAK,YAAY;QAAE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3D,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,MAAM,uBAAuB,GAAG,CAAC,EAC7B,QAAQ,GACsE,EAElE,EAAE;IACd,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAA;QAAE,OAAO;IAE9B,MAAM,WAAW,GAAG,QAAQ;SACvB,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;SAC1C,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAA2B,CAAC,CAAC;IAE3D,OAAO,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import { Coordinate, Coordinates } from '@bpd-library/types';\n\nimport {\n AreaProjectModel,\n ConstructionNumberModel,\n DistrictModel,\n ProjectPhaseModel,\n PropertyTypeModel,\n} from '../../generated';\nimport { calculateCenter } from '../../geometry';\n\nconst validateCoordinates = (coordinates: Coordinates) => {\n const validates = coordinates.every((coordinate) =>\n coordinate.every(([longitude, latitude]) => {\n return longitude < 180 && longitude > -180 && latitude > -90 && latitude < 90;\n }),\n );\n\n return validates;\n};\n\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n): Coordinates | false;\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n options?: { as?: 'coordinates' },\n): Coordinates | false;\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n options?: { as?: 'coordinate' },\n): Coordinate | false;\n\nfunction getApiObjectCenter(\n apiObject: AreaProjectModel | ProjectPhaseModel | DistrictModel,\n options?: { as?: 'coordinates' | 'coordinate' },\n) {\n const { location } = apiObject;\n\n let coordinates: Coordinates | undefined;\n\n if (location) {\n coordinates = [[location as Coordinate]];\n } else if (getApiObjectCoordinates(apiObject)) {\n coordinates = getApiObjectCoordinates(apiObject);\n coordinates = coordinates ? [[calculateCenter(coordinates)]] : undefined;\n }\n\n if (!coordinates || !validateCoordinates(coordinates)) return false;\n\n if (options?.as === 'coordinate') return coordinates[0][0];\n\n return coordinates;\n}\n\nconst getApiObjectCoordinates = ({\n geometry,\n}: DistrictModel | ProjectPhaseModel | PropertyTypeModel | ConstructionNumberModel):\n | Coordinates\n | undefined => {\n if (!geometry?.length) return;\n\n const coordinates = geometry\n .filter(({ coordinates }) => !!coordinates)\n .map(({ coordinates }) => coordinates as Coordinate[]);\n\n return coordinates?.length ? coordinates : undefined;\n};\n\nexport { validateCoordinates, getApiObjectCenter, getApiObjectCoordinates };\n"]}
@@ -1,5 +1,5 @@
1
- export declare type Procedure = (...args: any[]) => void;
2
- export declare type DebounceOptions = {
1
+ export type Procedure = (...args: any[]) => void;
2
+ export type DebounceOptions = {
3
3
  isImmediate: boolean;
4
4
  };
5
5
  export declare function debounce<F extends Procedure>(func: F, waitMilliseconds?: number, options?: DebounceOptions): (this: ThisParameterType<F>, ...args: Parameters<F>) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"extended-area.js","sourceRoot":"","sources":["../../src/extended-api-models/extended-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAEH,sBAAsB,EACtB,kBAAkB,EAGlB,uBAAuB,EAEvB,aAAa,EAEb,iBAAiB,EAEjB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,0BAA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c;iBACrB,CAAC,CAAC;aACN;YAED,kBAAkB,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,wBACjE,CAAC,CAAC,qBAAqB,0CAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,IAAC,CAC3D,CAAC;YAEF,kBAAkB,CAAC,MAAM,GAAG,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;YAEzE,kBAAkB,CAAC,UAAU,GAAG,oBAAoB,CAAC;QACzD,CAAC,CAAC,CAAC;QAKH,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC3B,QAAQ,CAAC,MAAM,GAAG,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;YAC7D,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,WAAW,CAAC,UAAU,GAAG,aAAa,CAAC;QAEvC,OAAO;YACH,mBAAmB;YACnB,aAAa;YACb,kBAAkB;YAClB,aAAa;YACb,SAAS;YACT,WAAW;SACd,CAAC;IACN,CAAC;IAED,OAAO;QACH,OAAO;QACP,kBAAkB;KACrB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,yBAAyB,EAAE,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAsB,CAAC","sourcesContent":["import {\n ExtendedApartmentBuilding,\n ExtendedAreaProject,\n ExtendedConstructionNumber,\n ExtendedDistrict,\n ExtendedProjectPhase,\n ExtendedPropertyType,\n filterConstructionNumbers,\n filterPropertyTypes,\n findProjectPhase,\n findPropertyType,\n getDistrictStatus,\n} from '../api-utilities';\nimport { environmentDetails } from '../environment';\nimport {\n ApartmentBuildingModel,\n apartmentBuildingQuery,\n areaProjectGetById,\n AreaProjectModel,\n ConstructionNumberModel,\n constructionNumberQuery,\n DistrictModel,\n districtQuery,\n ProjectPhaseModel,\n projectPhaseQuery,\n PropertyTypeModel,\n propertyTypeQuery,\n} from '../generated';\nimport { COMPOSED_INCLUDE_STRINGS } from './included-properties';\nimport { getApartmentBuildingStatus } from './status/apartment-building-status';\nimport { constructionNumberStatus } from './status/construction-number-status';\nimport { getPropertyTypeStatus } from './status/property-type-status';\n\ninterface OriginalAreaModels {\n constructionNumbers: ConstructionNumberModel[];\n propertyTypes: PropertyTypeModel[];\n apartmentBuildings: ApartmentBuildingModel[];\n projectPhases: ProjectPhaseModel[];\n districts: DistrictModel[];\n areaProject: AreaProjectModel;\n}\n\ninterface ExtendedAreaModels {\n constructionNumbers: ExtendedConstructionNumber[];\n propertyTypes: ExtendedPropertyType[];\n apartmentBuildings: ExtendedApartmentBuilding[];\n projectPhases: ExtendedProjectPhase[];\n districts: ExtendedDistrict[];\n areaProject: ExtendedAreaProject;\n}\n\ninterface FilterFunctions {\n constructionNumber?: (constructionNumber: ConstructionNumberModel) => boolean;\n propertyType?: (propertyType: PropertyTypeModel) => boolean;\n apartmentBuilding?: (apartmentBuilding: ApartmentBuildingModel) => boolean;\n projectPhase?: (projectPhase: ProjectPhaseModel) => boolean;\n district?: (district: DistrictModel) => boolean;\n}\n\nconst ExtendedAreaModelsUtility = () => {\n const areaState: {\n [areaId: string]: {\n extendedData?: ExtendedAreaModels;\n resolveArray: Function[];\n filterFunctions?: FilterFunctions;\n };\n } = {};\n\n async function controller(areaId: string) {\n let originalData = fetchSessionStorageData(areaId);\n\n if (!originalData) {\n originalData = await fetchData(areaId);\n setSessionStorageData(areaId, originalData);\n }\n\n // Objects without images, should not be shown on the website\n originalData = filterObjectsWithImages(originalData);\n\n areaState[areaId].extendedData = extendModels(originalData);\n\n setLoaded(areaId);\n }\n\n async function getData(areaId: string): Promise<ExtendedAreaModels> {\n if (!areaState[areaId]) {\n areaState[areaId] = {\n resolveArray: [],\n };\n\n // Controller handles fetching + extending of data\n controller(areaId);\n }\n\n const state = areaState[areaId];\n\n if (!state.extendedData) {\n /*\n if no extendedData is found, it means it's being fetched.\n Promises will be resolved after data is loaded\n */\n return new Promise((res) => {\n state.resolveArray.push(res);\n });\n } else {\n // if no extendedData is found, it comes from sessionStorage\n return state.extendedData;\n }\n }\n\n async function getCurrentAreaData(): Promise<ExtendedAreaModels> {\n return getData(environmentDetails.areaId!);\n }\n\n function setLoaded(areaId: string) {\n areaState[areaId].resolveArray.forEach((res) => {\n res(areaState[areaId].extendedData);\n });\n }\n\n function filterObjectsWithImages(data: OriginalAreaModels): OriginalAreaModels {\n return {\n ...data,\n constructionNumbers: data.constructionNumbers.filter(\n ({ mainImage }) => !!mainImage?.url,\n ),\n propertyTypes: data.propertyTypes.filter(({ mainImage }) => !!mainImage?.url),\n apartmentBuildings: data.apartmentBuildings.filter(({ image }) => !!image?.url),\n };\n }\n\n function sessionStorageId(areaId: string) {\n return `AreaObjects::${areaId}`;\n }\n\n function fetchSessionStorageData(areaId: string) {\n const storageData = sessionStorage.getItem(sessionStorageId(areaId));\n if (!!storageData) {\n return JSON.parse(storageData) as OriginalAreaModels;\n } else {\n return;\n }\n }\n\n function setSessionStorageData(areaId: string, originalData: OriginalAreaModels) {\n try {\n sessionStorage.setItem(sessionStorageId(areaId), JSON.stringify(originalData));\n } catch (error) {\n console.warn('[extended-area] -- failed to save data to storage', error);\n }\n }\n\n async function fetchData(areaId: string) {\n const propertyTypes = propertyTypeQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.propertyType,\n });\n const constructionNumbers = constructionNumberQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.constructionNumber,\n });\n const projectPhases = projectPhaseQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.projectPhase,\n });\n const apartmentBuildings = apartmentBuildingQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.apartmentBuilding,\n });\n const districts = districtQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.district,\n });\n const areaProject = areaProjectGetById(areaId, {\n include: COMPOSED_INCLUDE_STRINGS.areaProject,\n });\n\n return {\n propertyTypes: await propertyTypes,\n constructionNumbers: await constructionNumbers,\n projectPhases: await projectPhases,\n apartmentBuildings: await apartmentBuildings,\n districts: await districts,\n areaProject: await areaProject,\n };\n }\n\n function extendModels(data: OriginalAreaModels): ExtendedAreaModels {\n const {\n constructionNumbers,\n propertyTypes,\n apartmentBuildings,\n projectPhases,\n districts,\n areaProject,\n } = data as ExtendedAreaModels;\n\n /*\n Extend propertTypes object\n */\n propertyTypes.forEach((propertyType) => {\n const { projectPhaseId, id } = propertyType;\n\n if (projectPhaseId) {\n propertyType.projectPhase = findProjectPhase(projectPhases, {\n id: projectPhaseId,\n });\n }\n\n propertyType.constructionNumbers = filterConstructionNumbers(constructionNumbers, {\n propertyTypeId: id,\n });\n\n if (propertyType.projectPhase) {\n propertyType.status = getPropertyTypeStatus(\n propertyType.projectPhase,\n propertyType.constructionNumbers,\n );\n }\n\n propertyType.apartmentBuildings = apartmentBuildings.filter((s) =>\n s.propertyTypeIds?.includes(propertyType.id),\n );\n\n propertyType.objectType = 'propertyType';\n });\n\n /*\n Extend projectPhase object\n */\n projectPhases.forEach((projectPhase) => {\n const { id } = projectPhase;\n\n projectPhase.propertyTypes = filterPropertyTypes(propertyTypes, {\n projectPhaseId: id,\n });\n projectPhase.constructionNumbers = filterConstructionNumbers(constructionNumbers, {\n projectPhaseId: id,\n });\n\n projectPhase.objectType = 'projectPhase';\n });\n\n /*\n Extend apartmentBuilding object\n */\n apartmentBuildings.forEach((apartmentBuilding) => {\n const { propertyTypeIds, constructionNumberIds, projectPhaseId } = apartmentBuilding;\n\n if (propertyTypeIds) {\n apartmentBuilding.propertyTypes = propertyTypes.filter(({ id }) =>\n propertyTypeIds?.includes(id),\n );\n }\n\n if (constructionNumberIds) {\n apartmentBuilding.constructionNumbers = constructionNumbers.filter(({ id }) =>\n constructionNumberIds?.includes(id),\n );\n }\n\n if (projectPhaseId) {\n apartmentBuilding.projectPhase = findProjectPhase(projectPhases, {\n id: projectPhaseId,\n });\n }\n\n if (apartmentBuilding.projectPhase) {\n apartmentBuilding.status = getApartmentBuildingStatus(\n apartmentBuilding.projectPhase,\n apartmentBuilding.constructionNumbers,\n );\n }\n\n apartmentBuilding.objectType = 'apartmentBuilding';\n });\n\n /*\n Extend constructionNumbers object\n */\n constructionNumbers.forEach((constructionNumber) => {\n const { propertyTypeId, projectPhaseId } = constructionNumber;\n\n constructionNumber.areaProject = areaProject;\n\n if (propertyTypeId) {\n constructionNumber.propertyType = findPropertyType(propertyTypes, {\n id: propertyTypeId,\n });\n }\n\n if (projectPhaseId) {\n constructionNumber.projectPhase = findProjectPhase(projectPhases, {\n id: projectPhaseId,\n });\n }\n\n constructionNumber.apartmentBuilding = apartmentBuildings.find((s) =>\n s.constructionNumberIds?.includes(constructionNumber.id),\n );\n\n constructionNumber.status = constructionNumberStatus(constructionNumber);\n\n constructionNumber.objectType = 'constructionNumber';\n });\n\n /*\n Extend district object\n */\n districts.forEach((district) => {\n district.status = getDistrictStatus(district, projectPhases);\n district.objectType = 'district';\n });\n\n areaProject.objectType = 'areaProject';\n\n return {\n constructionNumbers,\n propertyTypes,\n apartmentBuildings,\n projectPhases,\n districts,\n areaProject,\n };\n }\n\n return {\n getData,\n getCurrentAreaData,\n };\n};\n\nconst extendedArea = ExtendedAreaModelsUtility();\n\nexport { extendedArea, ExtendedAreaModels };\n"]}
1
+ {"version":3,"file":"extended-area.js","sourceRoot":"","sources":["../../src/extended-api-models/extended-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAEH,sBAAsB,EACtB,kBAAkB,EAGlB,uBAAuB,EAEvB,aAAa,EAEb,iBAAiB,EAEjB,iBAAiB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wB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cAAc,EAAE;gBAChB,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC,aAAa,EAAE;oBAC9D,EAAE,EAAE,cAAc;iBACrB,CAAC,CAAC;aACN;YAED,kBAAkB,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WACjE,OAAA,MAAA,CAAC,CAAC,qBAAqB,0CAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAA,EAAA,CAC3D,CAAC;YAEF,kBAAkB,CAAC,MAAM,GAAG,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;YAEzE,kBAAkB,CAAC,UAAU,GAAG,oBAAoB,CAAC;QACzD,CAAC,CAAC,CAAC;QAKH,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC3B,QAAQ,CAAC,MAAM,GAAG,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;YAC7D,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,WAAW,CAAC,UAAU,GAAG,aAAa,CAAC;QAEvC,OAAO;YACH,mBAAmB;YACnB,aAAa;YACb,kBAAkB;YAClB,aAAa;YACb,SAAS;YACT,WAAW;SACd,CAAC;IACN,CAAC;IAED,OAAO;QACH,OAAO;QACP,kBAAkB;KACrB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,yBAAyB,EAAE,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAsB,CAAC","sourcesContent":["import {\n ExtendedApartmentBuilding,\n ExtendedAreaProject,\n ExtendedConstructionNumber,\n ExtendedDistrict,\n ExtendedProjectPhase,\n ExtendedPropertyType,\n filterConstructionNumbers,\n filterPropertyTypes,\n findProjectPhase,\n findPropertyType,\n getDistrictStatus,\n} from '../api-utilities';\nimport { environmentDetails } from '../environment';\nimport {\n ApartmentBuildingModel,\n apartmentBuildingQuery,\n areaProjectGetById,\n AreaProjectModel,\n ConstructionNumberModel,\n constructionNumberQuery,\n DistrictModel,\n districtQuery,\n ProjectPhaseModel,\n projectPhaseQuery,\n PropertyTypeModel,\n propertyTypeQuery,\n} from '../generated';\nimport { COMPOSED_INCLUDE_STRINGS } from './included-properties';\nimport { getApartmentBuildingStatus } from './status/apartment-building-status';\nimport { constructionNumberStatus } from './status/construction-number-status';\nimport { getPropertyTypeStatus } from './status/property-type-status';\n\ninterface OriginalAreaModels {\n constructionNumbers: ConstructionNumberModel[];\n propertyTypes: PropertyTypeModel[];\n apartmentBuildings: ApartmentBuildingModel[];\n projectPhases: ProjectPhaseModel[];\n districts: DistrictModel[];\n areaProject: AreaProjectModel;\n}\n\ninterface ExtendedAreaModels {\n constructionNumbers: ExtendedConstructionNumber[];\n propertyTypes: ExtendedPropertyType[];\n apartmentBuildings: ExtendedApartmentBuilding[];\n projectPhases: ExtendedProjectPhase[];\n districts: ExtendedDistrict[];\n areaProject: ExtendedAreaProject;\n}\n\ninterface FilterFunctions {\n constructionNumber?: (constructionNumber: ConstructionNumberModel) => boolean;\n propertyType?: (propertyType: PropertyTypeModel) => boolean;\n apartmentBuilding?: (apartmentBuilding: ApartmentBuildingModel) => boolean;\n projectPhase?: (projectPhase: ProjectPhaseModel) => boolean;\n district?: (district: DistrictModel) => boolean;\n}\n\nconst ExtendedAreaModelsUtility = () => {\n const areaState: {\n [areaId: string]: {\n extendedData?: ExtendedAreaModels;\n resolveArray: Function[];\n filterFunctions?: FilterFunctions;\n };\n } = {};\n\n async function controller(areaId: string) {\n let originalData = fetchSessionStorageData(areaId);\n\n if (!originalData) {\n originalData = await fetchData(areaId);\n setSessionStorageData(areaId, originalData);\n }\n\n // Objects without images, should not be shown on the website\n originalData = filterObjectsWithImages(originalData);\n\n areaState[areaId].extendedData = extendModels(originalData);\n\n setLoaded(areaId);\n }\n\n async function getData(areaId: string): Promise<ExtendedAreaModels> {\n if (!areaState[areaId]) {\n areaState[areaId] = {\n resolveArray: [],\n };\n\n // Controller handles fetching + extending of data\n controller(areaId);\n }\n\n const state = areaState[areaId];\n\n if (!state.extendedData) {\n /*\n if no extendedData is found, it means it's being fetched.\n Promises will be resolved after data is loaded\n */\n return new Promise((res) => {\n state.resolveArray.push(res);\n });\n } else {\n // if no extendedData is found, it comes from sessionStorage\n return state.extendedData;\n }\n }\n\n async function getCurrentAreaData(): Promise<ExtendedAreaModels> {\n return getData(environmentDetails.areaId!);\n }\n\n function setLoaded(areaId: string) {\n areaState[areaId].resolveArray.forEach((res) => {\n res(areaState[areaId].extendedData);\n });\n }\n\n function filterObjectsWithImages(data: OriginalAreaModels): OriginalAreaModels {\n return {\n ...data,\n constructionNumbers: data.constructionNumbers.filter(\n ({ mainImage }) => !!mainImage?.url,\n ),\n propertyTypes: data.propertyTypes.filter(({ mainImage }) => !!mainImage?.url),\n apartmentBuildings: data.apartmentBuildings.filter(({ image }) => !!image?.url),\n };\n }\n\n function sessionStorageId(areaId: string) {\n return `AreaObjects::${areaId}`;\n }\n\n function fetchSessionStorageData(areaId: string) {\n const storageData = sessionStorage.getItem(sessionStorageId(areaId));\n if (!!storageData) {\n return JSON.parse(storageData) as OriginalAreaModels;\n } else {\n return;\n }\n }\n\n function setSessionStorageData(areaId: string, originalData: OriginalAreaModels) {\n try {\n sessionStorage.setItem(sessionStorageId(areaId), JSON.stringify(originalData));\n } catch (error) {\n console.warn('[extended-area] -- failed to save data to storage', error);\n }\n }\n\n async function fetchData(areaId: string) {\n const propertyTypes = propertyTypeQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.propertyType,\n });\n const constructionNumbers = constructionNumberQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.constructionNumber,\n });\n const projectPhases = projectPhaseQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.projectPhase,\n });\n const apartmentBuildings = apartmentBuildingQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.apartmentBuilding,\n });\n const districts = districtQuery({\n AreaProjectId: areaId,\n include: COMPOSED_INCLUDE_STRINGS.district,\n });\n const areaProject = areaProjectGetById(areaId, {\n include: COMPOSED_INCLUDE_STRINGS.areaProject,\n });\n\n return {\n propertyTypes: await propertyTypes,\n constructionNumbers: await constructionNumbers,\n projectPhases: await projectPhases,\n apartmentBuildings: await apartmentBuildings,\n districts: await districts,\n areaProject: await areaProject,\n };\n }\n\n function extendModels(data: OriginalAreaModels): ExtendedAreaModels {\n const {\n constructionNumbers,\n propertyTypes,\n apartmentBuildings,\n projectPhases,\n districts,\n areaProject,\n } = data as ExtendedAreaModels;\n\n /*\n Extend propertTypes object\n */\n propertyTypes.forEach((propertyType) => {\n const { projectPhaseId, id } = propertyType;\n\n if (projectPhaseId) {\n propertyType.projectPhase = findProjectPhase(projectPhases, {\n id: projectPhaseId,\n });\n }\n\n propertyType.constructionNumbers = filterConstructionNumbers(constructionNumbers, {\n propertyTypeId: id,\n });\n\n if (propertyType.projectPhase) {\n propertyType.status = getPropertyTypeStatus(\n propertyType.projectPhase,\n propertyType.constructionNumbers,\n );\n }\n\n propertyType.apartmentBuildings = apartmentBuildings.filter((s) =>\n s.propertyTypeIds?.includes(propertyType.id),\n );\n\n propertyType.objectType = 'propertyType';\n });\n\n /*\n Extend projectPhase object\n */\n projectPhases.forEach((projectPhase) => {\n const { id } = projectPhase;\n\n projectPhase.propertyTypes = filterPropertyTypes(propertyTypes, {\n projectPhaseId: id,\n });\n projectPhase.constructionNumbers = filterConstructionNumbers(constructionNumbers, {\n projectPhaseId: id,\n });\n\n projectPhase.objectType = 'projectPhase';\n });\n\n /*\n Extend apartmentBuilding object\n */\n apartmentBuildings.forEach((apartmentBuilding) => {\n const { propertyTypeIds, constructionNumberIds, projectPhaseId } = apartmentBuilding;\n\n if (propertyTypeIds) {\n apartmentBuilding.propertyTypes = propertyTypes.filter(({ id }) =>\n propertyTypeIds?.includes(id),\n );\n }\n\n if (constructionNumberIds) {\n apartmentBuilding.constructionNumbers = constructionNumbers.filter(({ id }) =>\n constructionNumberIds?.includes(id),\n );\n }\n\n if (projectPhaseId) {\n apartmentBuilding.projectPhase = findProjectPhase(projectPhases, {\n id: projectPhaseId,\n });\n }\n\n if (apartmentBuilding.projectPhase) {\n apartmentBuilding.status = getApartmentBuildingStatus(\n apartmentBuilding.projectPhase,\n apartmentBuilding.constructionNumbers,\n );\n }\n\n apartmentBuilding.objectType = 'apartmentBuilding';\n });\n\n /*\n Extend constructionNumbers object\n */\n constructionNumbers.forEach((constructionNumber) => {\n const { propertyTypeId, projectPhaseId } = constructionNumber;\n\n constructionNumber.areaProject = areaProject;\n\n if (propertyTypeId) {\n constructionNumber.propertyType = findPropertyType(propertyTypes, {\n id: propertyTypeId,\n });\n }\n\n if (projectPhaseId) {\n constructionNumber.projectPhase = findProjectPhase(projectPhases, {\n id: projectPhaseId,\n });\n }\n\n constructionNumber.apartmentBuilding = apartmentBuildings.find((s) =>\n s.constructionNumberIds?.includes(constructionNumber.id),\n );\n\n constructionNumber.status = constructionNumberStatus(constructionNumber);\n\n constructionNumber.objectType = 'constructionNumber';\n });\n\n /*\n Extend district object\n */\n districts.forEach((district) => {\n district.status = getDistrictStatus(district, projectPhases);\n district.objectType = 'district';\n });\n\n areaProject.objectType = 'areaProject';\n\n return {\n constructionNumbers,\n propertyTypes,\n apartmentBuildings,\n projectPhases,\n districts,\n areaProject,\n };\n }\n\n return {\n getData,\n getCurrentAreaData,\n };\n};\n\nconst extendedArea = ExtendedAreaModelsUtility();\n\nexport { extendedArea, ExtendedAreaModels };\n"]}
@@ -1,3 +1,3 @@
1
1
  import { ApartmentBuildingStatus, ExtendedConstructionNumber, ExtendedProjectPhase } from '../../api-utilities/api-utilities.types';
2
- declare const getApartmentBuildingStatus: (projectPhase: ExtendedProjectPhase, constructionNumbers?: ExtendedConstructionNumber[] | undefined) => ApartmentBuildingStatus | undefined;
2
+ declare const getApartmentBuildingStatus: (projectPhase: ExtendedProjectPhase, constructionNumbers?: ExtendedConstructionNumber[]) => ApartmentBuildingStatus | undefined;
3
3
  export { getApartmentBuildingStatus };
@@ -1 +1 @@
1
- {"version":3,"file":"apartment-building-status.js","sourceRoot":"","sources":["../../../src/extended-api-models/status/apartment-building-status.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,0BAA0B,GAAG,CAC/B,YAAkC,EAClC,mBAAkD,EACf,EAAE;IACrC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACzF,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACnF,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAE5F,IAAI,YAAY,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAC/D,IAAI,YAAY,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAEtD,IAAI,EAAC,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,CAAA;QAAE,OAAO,sBAAsB,EAAE,CAAC;IAElE,QAAQ,YAAY,CAAC,MAAM,EAAE;QACzB,KAAK,eAAe;YAChB,OAAO,sBAAsB,EAAE,CAAC;QACpC,KAAK,SAAS;YACV,OAAO,SAAS,CAAC;QACrB,KAAK,QAAQ;YACT,OAAO,eAAe,EAAE,CAAC;QAC7B;YACI,OAAO;KACd;IAED,SAAS,sBAAsB;QAC3B,IAAI,YAAY,CAAC,QAAQ;YAAE,OAAO,eAAe,CAAC;QAElD,IAAI,aAAa,EAAE;YACf,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,aAAa,EAAE,WAAW,C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from '../../api-utilities/api-utilities.types';\nimport { betweenDates, calculateDifferenceInDays } from '../../date';\n\nconst getApartmentBuildingStatus = (\n projectPhase: ExtendedProjectPhase,\n constructionNumbers?: ExtendedConstructionNumber[],\n): ApartmentBuildingStatus | undefined => {\n const currentDate = new Date();\n const saleStartDate = projectPhase.saleStartDate && new Date(projectPhase.saleStartDate);\n const saleEndDate = projectPhase.saleEndDate && new Date(projectPhase.saleEndDate);\n const allocationDate = projectPhase.allocationDate && new Date(projectPhase.allocationDate);\n\n if (projectPhase.status === 'Sold') return 'UnderConstruction';\n if (projectPhase.status === 'Rented') return 'Rented';\n\n if (!constructionNumbers?.length) return getInPreparationStatus();\n\n switch (projectPhase.status) {\n case 'InPreparation':\n return getInPreparationStatus();\n case 'ForRent':\n return 'ForRent';\n case 'OnSale':\n return getOnSaleStatus();\n default:\n return;\n }\n\n function getInPreparationStatus(): ApartmentBuildingStatus {\n if (projectPhase.isRental) return 'InPreparation';\n\n if (saleStartDate) {\n const differenceInDays = calculateDifferenceInDays(saleStartDate, currentDate);\n\n if (differenceInDays <= 30) return 'SaleSoon';\n }\n\n return 'InPreparation';\n }\n\n function getOnSaleStatus(): ApartmentBuildingStatus | undefined {\n if (!saleStartDate || !saleEndDate || !allocationDate) return;\n\n const betweenSaleStartAndSaleEnd = betweenDates(saleStartDate, currentDate, saleEndDate);\n const betweenSaleStartAndAllocation = betweenDates(\n saleStartDate,\n currentDate,\n allocationDate,\n );\n const afterAllocation = currentDate >= allocationDate;\n\n if (betweenSaleStartAndSaleEnd) return 'SaleStarted';\n\n if (betweenSaleStartAndAllocation) return 'AssigningOn';\n\n if (afterAllocation) {\n const constructionNumberStatusses = constructionNumbers!.map(\n ({ availabilityStatus }) => availabilityStatus,\n );\n const constructionNumbersAvailable = constructionNumberStatusses.filter(\n (s) => s === 'Available',\n );\n const constructionNumbersInOption = constructionNumberStatusses.filter(\n (s) => s === 'InOption',\n );\n\n if (constructionNumbersAvailable.length) return 'AmountAvailable';\n\n if (constructionNumbersInOption.length) return 'InOption';\n\n if (constructionNumberStatusses.indexOf('Sold') > -1) return 'Sold';\n }\n\n return;\n }\n};\n\nexport { getApartmentBuildingStatus };\n"]}
1
+ {"version":3,"file":"apartment-building-status.js","sourceRoot":"","sources":["../../../src/extended-api-models/status/apartment-building-status.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,0BAA0B,GAAG,CAC/B,YAAkC,EAClC,mBAAkD,EACf,EAAE;IACrC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACzF,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACnF,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAE5F,IAAI,YAAY,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAC/D,IAAI,YAAY,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAEtD,IAAI,CAAC,CAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,CAAA;QAAE,OAAO,sBAAsB,EAAE,CAAC;IAElE,QAAQ,YAAY,CAAC,MAAM,EAAE;QACzB,KAAK,eAAe;YAChB,OAAO,sBAAsB,EAAE,CAAC;QACpC,KAAK,SAAS;YACV,OAAO,SAAS,CAAC;QACrB,KAAK,QAAQ;YACT,OAAO,eAAe,EAAE,CAAC;QAC7B;YACI,OAAO;KACd;IAED,SAAS,sBAAsB;QAC3B,IAAI,YAAY,CAAC,QAAQ;YAAE,OAAO,eAAe,CAAC;QAElD,IAAI,aAAa,EAAE;Y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{\n ApartmentBuildingStatus,\n ExtendedConstructionNumber,\n ExtendedProjectPhase,\n} from '../../api-utilities/api-utilities.types';\nimport { betweenDates, calculateDifferenceInDays } from '../../date';\n\nconst getApartmentBuildingStatus = (\n projectPhase: ExtendedProjectPhase,\n constructionNumbers?: ExtendedConstructionNumber[],\n): ApartmentBuildingStatus | undefined => {\n const currentDate = new Date();\n const saleStartDate = projectPhase.saleStartDate && new Date(projectPhase.saleStartDate);\n const saleEndDate = projectPhase.saleEndDate && new Date(projectPhase.saleEndDate);\n const allocationDate = projectPhase.allocationDate && new Date(projectPhase.allocationDate);\n\n if (projectPhase.status === 'Sold') return 'UnderConstruction';\n if (projectPhase.status === 'Rented') return 'Rented';\n\n if (!constructionNumbers?.length) return getInPreparationStatus();\n\n switch (projectPhase.status) {\n case 'InPreparation':\n return getInPreparationStatus();\n case 'ForRent':\n return 'ForRent';\n case 'OnSale':\n return getOnSaleStatus();\n default:\n return;\n }\n\n function getInPreparationStatus(): ApartmentBuildingStatus {\n if (projectPhase.isRental) return 'InPreparation';\n\n if (saleStartDate) {\n const differenceInDays = calculateDifferenceInDays(saleStartDate, currentDate);\n\n if (differenceInDays <= 30) return 'SaleSoon';\n }\n\n return 'InPreparation';\n }\n\n function getOnSaleStatus(): ApartmentBuildingStatus | undefined {\n if (!saleStartDate || !saleEndDate || !allocationDate) return;\n\n const betweenSaleStartAndSaleEnd = betweenDates(saleStartDate, currentDate, saleEndDate);\n const betweenSaleStartAndAllocation = betweenDates(\n saleStartDate,\n currentDate,\n allocationDate,\n );\n const afterAllocation = currentDate >= allocationDate;\n\n if (betweenSaleStartAndSaleEnd) return 'SaleStarted';\n\n if (betweenSaleStartAndAllocation) return 'AssigningOn';\n\n if (afterAllocation) {\n const constructionNumberStatusses = constructionNumbers!.map(\n ({ availabilityStatus }) => availabilityStatus,\n );\n const constructionNumbersAvailable = constructionNumberStatusses.filter(\n (s) => s === 'Available',\n );\n const constructionNumbersInOption = constructionNumberStatusses.filter(\n (s) => s === 'InOption',\n );\n\n if (constructionNumbersAvailable.length) return 'AmountAvailable';\n\n if (constructionNumbersInOption.length) return 'InOption';\n\n if (constructionNumberStatusses.indexOf('Sold') > -1) return 'Sold';\n }\n\n return;\n }\n};\n\nexport { getApartmentBuildingStatus };\n"]}
@@ -11,7 +11,8 @@ const constructionNumberStatus = (constructionNumber) => {
11
11
  return 'UnderConstruction';
12
12
  switch (availabilityStatus) {
13
13
  case 'Reserved':
14
- if (projectPhaseStatus === 'OnSale' && (projectPhase === null || projectPhase === void 0 ? void 0 : projectPhase.allocationDate) &&
14
+ if (projectPhaseStatus === 'OnSale' &&
15
+ (projectPhase === null || projectPhase === void 0 ? void 0 : projectPhase.allocationDate) &&
15
16
  hasDatePassed(projectPhase.allocationDate)) {
16
17
  return 'InOption';
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"construction-number-status.js","sourceRoot":"","sources":["../../../src/extended-api-models/status/construction-number-status.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,wBAAwB,GAAG,CAC7B,kBAA8C,EACD,EAAE;IAC/C,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC;IAC9E,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,YAAY,IAAI,EAAE,CAAC;IAC1D,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,IAAI,EAAE,CAAC;IACvF,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC,YAAY,IAAI,EAAE,CAAC;IAEvF,IAAI,kBAAkB,KAAK,eAAe,EAAE;QACxC,OAAO,kBAAkB,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC;KAC3E;IAED,IAAI,kBAAkB,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAE9D,QAAQ,kBAAkB,EAAE;QACxB,KAAK,UAAU;YACX,IACI,kBAAkB,KAAK,QAAQ,KAC/B,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,cAAc,CAAA;gBAC5B,aAAa,CAAC,YAAY,CAAC,cAAc,CAAC,EAC5C;gBACE,OAAO,UAAU,CAAC;aACrB;YACD,OAAO,UAAU,CAAC;QACtB,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACZ,IAAI,kBAAkB,KAAK,aAAa,IAAI,uBAAuB,KAAK,aAAa,EAAE;gBACnF,OAAO,aAAa,CAAC;aACxB;YACD,OAAO,kBAAkB,CAAC;QAC9B,KAAK,MAAM;YACP,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;KAC3C;IAED,OAAO;AACX,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["import {\n ExtendedConstructionNumber,\n GeneratedConstructionNumberStatus,\n} from '../../api-utilities/api-utilities.types';\nimport { hasDatePassed } from '../../date';\n\nconst constructionNumberStatus = (\n constructionNumber: ExtendedConstructionNumber,\n): GeneratedConstructionNumberStatus | undefined => {\n const { projectPhase, availabilityStatus, propertyType } = constructionNumber;\n const { status: propertyTypeStatus } = propertyType || {};\n const { status: apartmentBuildingStatus } = constructionNumber.apartmentBuilding || {};\n const { status: projectPhaseStatus, isRental } = constructionNumber.projectPhase || {};\n\n if (projectPhaseStatus === 'InPreparation') {\n return availabilityStatus === 'Reserved' ? 'Reserved' : 'InPreparation';\n }\n\n if (projectPhaseStatus === 'Sold') return 'UnderConstruction';\n\n switch (availabilityStatus) {\n case 'Reserved':\n if (\n projectPhaseStatus === 'OnSale' &&\n projectPhase?.allocationDate &&\n hasDatePassed(projectPhase.allocationDate)\n ) {\n return 'InOption';\n }\n return 'Reserved';\n case 'InOption':\n case 'Available':\n if (propertyTypeStatus === 'AssigningOn' || apartmentBuildingStatus === 'AssigningOn') {\n return 'AssigningOn';\n }\n return availabilityStatus;\n case 'Sold':\n return isRental ? 'Rented' : 'Sold';\n }\n\n return;\n};\n\nexport { constructionNumberStatus };\n"]}
1
+ {"version":3,"file":"construction-number-status.js","sourceRoot":"","sources":["../../../src/extended-api-models/status/construction-number-status.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,wBAAwB,GAAG,CAC7B,kBAA8C,EACD,EAAE;IAC/C,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC;IAC9E,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,YAAY,IAAI,EAAE,CAAC;IAC1D,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,IAAI,EAAE,CAAC;IACvF,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC,YAAY,IAAI,EAAE,CAAC;IAEvF,IAAI,kBAAkB,KAAK,eAAe,EAAE;QACxC,OAAO,kBAAkB,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC;KAC3E;IAED,IAAI,kBAAkB,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAE9D,QAAQ,kBAAkB,EAAE;QACxB,KAAK,UAAU;YACX,IACI,kBAAkB,KAAK,QAAQ;iBAC/B,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,cAAc,CAAA;gBAC5B,aAAa,CAAC,YAAY,CAAC,cAAc,CAAC,EAC5C;gBACE,OAAO,UAAU,CAAC;aACrB;YACD,OAAO,UAAU,CAAC;QACtB,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACZ,IAAI,kBAAkB,KAAK,aAAa,IAAI,uBAAuB,KAAK,aAAa,EAAE;gBACnF,OAAO,aAAa,CAAC;aACxB;YACD,OAAO,kBAAkB,CAAC;QAC9B,KAAK,MAAM;YACP,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;KAC3C;IAED,OAAO;AACX,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["import {\n ExtendedConstructionNumber,\n GeneratedConstructionNumberStatus,\n} from '../../api-utilities/api-utilities.types';\nimport { hasDatePassed } from '../../date';\n\nconst constructionNumberStatus = (\n constructionNumber: ExtendedConstructionNumber,\n): GeneratedConstructionNumberStatus | undefined => {\n const { projectPhase, availabilityStatus, propertyType } = constructionNumber;\n const { status: propertyTypeStatus } = propertyType || {};\n const { status: apartmentBuildingStatus } = constructionNumber.apartmentBuilding || {};\n const { status: projectPhaseStatus, isRental } = constructionNumber.projectPhase || {};\n\n if (projectPhaseStatus === 'InPreparation') {\n return availabilityStatus === 'Reserved' ? 'Reserved' : 'InPreparation';\n }\n\n if (projectPhaseStatus === 'Sold') return 'UnderConstruction';\n\n switch (availabilityStatus) {\n case 'Reserved':\n if (\n projectPhaseStatus === 'OnSale' &&\n projectPhase?.allocationDate &&\n hasDatePassed(projectPhase.allocationDate)\n ) {\n return 'InOption';\n }\n return 'Reserved';\n case 'InOption':\n case 'Available':\n if (propertyTypeStatus === 'AssigningOn' || apartmentBuildingStatus === 'AssigningOn') {\n return 'AssigningOn';\n }\n return availabilityStatus;\n case 'Sold':\n return isRental ? 'Rented' : 'Sold';\n }\n\n return;\n};\n\nexport { constructionNumberStatus };\n"]}
@@ -1,4 +1,4 @@
1
1
  import { PropertyTypeStatus } from '../../api-utilities/api-utilities.types';
2
2
  import { ConstructionNumberModel, ProjectPhaseModel } from '../../generated';
3
- declare const getPropertyTypeStatus: (projectPhase: ProjectPhaseModel, constructionNumbers?: ConstructionNumberModel[] | undefined) => PropertyTypeStatus | undefined;
3
+ declare const getPropertyTypeStatus: (projectPhase: ProjectPhaseModel, constructionNumbers?: ConstructionNumberModel[]) => PropertyTypeStatus | undefined;
4
4
  export { getPropertyTypeStatus };
@@ -1 +1 @@
1
- {"version":3,"file":"property-type-status.js","sourceRoot":"","sources":["../../../src/extended-api-models/status/property-type-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGrE,MAAM,qBAAqB,GAAG,CAC1B,YAA+B,EAC/B,mBAA+C,EACjB,EAAE;IAChC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACzF,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACnF,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAE5F,IAAI,YAAY,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAC/D,IAAI,YAAY,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAEtD,IAAI,EAAC,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,CAAA;QAAE,OAAO,sBAAsB,EAAE,CAAC;IAElE,QAAQ,YAAY,CAAC,MAAM,EAAE;QACzB,KAAK,eAAe;YAChB,OAAO,sBAAsB,EAAE,CAAC;QACpC,KAAK,SAAS;YACV,OAAO,SAAS,CAAC;QACrB,KAAK,QAAQ;YACT,OAAO,eAAe,EAAE,CAAC;QAC7B;YACI,OAAO;KACd;IAED,SAAS,sBAAsB;QAC3B,IAAI,YAAY,CAAC,QAAQ;YAAE,OAAO,eAAe,CAAC;QAElD,IAAI,aAAa,EAAE;YACf,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;YAE/E,IAAI,gBAAgB,IAAI,EAAE;gBAAE,OAAO,UAAU,CAAC;SACjD;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,SAAS,eAAe;QACpB,IAAI,CAAC,aAAa,IAAI,CAAC,WAAW,IAAI,CAAC,cAAc;YAAE,OAAO;QAE9D,MAAM,0BAA0B,GAAG,YAAY,CAAC,aAAa,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;QACzF,MAAM,6BAA6B,GAAG,YAAY,CAC9C,aAAa,EACb,WAAW,EACX,cAAc,CACjB,CAAC;QACF,MAAM,eAAe,GAAG,WAAW,IAAI,cAAc,CAAC;QAEtD,IAAI,0BAA0B;YAAE,OAAO,aAAa,CAAC;QAErD,IAAI,6BAA6B;YAAE,OAAO,aAAa,CAAC;QAExD,IAAI,eAAe,EAAE;YACjB,MAAM,2BAA2B,GAAG,mBAAoB,CAAC,GAAG,CACxD,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC,kBAAkB,CACjD,CAAC;YACF,MAAM,4BAA4B,GAAG,2BAA2B,CAAC,MAAM,CACnE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,WAAW,CAC3B,CAAC;YACF,MAAM,2BAA2B,GAAG,2BAA2B,CAAC,MAAM,CAClE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,UAAU,CAC1B,CAAC;YAEF,IAAI,4BAA4B,CAAC,MAAM;gBAAE,OAAO,iBAAiB,CAAC;YAElE,IAAI,2BAA2B,CAAC,MAAM;gBAAE,OAAO,UAAU,CAAC;YAE1D,IAAI,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAAE,OAAO,MAAM,CAAC;SACvE;QAED,OAAO;IACX,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import { PropertyTypeStatus } from '../../api-utilities/api-utilities.types';\nimport { betweenDates, calculateDifferenceInDays } from '../../date';\nimport { ConstructionNumberModel, ProjectPhaseModel } from '../../generated';\n\nconst getPropertyTypeStatus = (\n projectPhase: ProjectPhaseModel,\n constructionNumbers?: ConstructionNumberModel[],\n): PropertyTypeStatus | undefined => {\n const currentDate = new Date();\n const saleStartDate = projectPhase.saleStartDate && new Date(projectPhase.saleStartDate);\n const saleEndDate = projectPhase.saleEndDate && new Date(projectPhase.saleEndDate);\n const allocationDate = projectPhase.allocationDate && new Date(projectPhase.allocationDate);\n\n if (projectPhase.status === 'Sold') return 'UnderConstruction';\n if (projectPhase.status === 'Rented') return 'Rented';\n\n if (!constructionNumbers?.length) return getInPreparationStatus();\n\n switch (projectPhase.status) {\n case 'InPreparation':\n return getInPreparationStatus();\n case 'ForRent':\n return 'ForRent';\n case 'OnSale':\n return getOnSaleStatus();\n default:\n return;\n }\n\n function getInPreparationStatus(): PropertyTypeStatus {\n if (projectPhase.isRental) return 'InPreparation';\n\n if (saleStartDate) {\n const differenceInDays = calculateDifferenceInDays(saleStartDate, currentDate);\n\n if (differenceInDays <= 30) return 'SaleSoon';\n }\n\n return 'InPreparation';\n }\n\n function getOnSaleStatus(): PropertyTypeStatus | undefined {\n if (!saleStartDate || !saleEndDate || !allocationDate) return;\n\n const betweenSaleStartAndSaleEnd = betweenDates(saleStartDate, currentDate, saleEndDate);\n const betweenSaleStartAndAllocation = betweenDates(\n saleStartDate,\n currentDate,\n allocationDate,\n );\n const afterAllocation = currentDate >= allocationDate;\n\n if (betweenSaleStartAndSaleEnd) return 'SaleStarted';\n\n if (betweenSaleStartAndAllocation) return 'AssigningOn';\n\n if (afterAllocation) {\n const constructionNumberStatusses = constructionNumbers!.map(\n ({ availabilityStatus }) => availabilityStatus,\n );\n const constructionNumbersAvailable = constructionNumberStatusses.filter(\n (s) => s === 'Available',\n );\n const constructionNumbersInOption = constructionNumberStatusses.filter(\n (s) => s === 'InOption',\n );\n\n if (constructionNumbersAvailable.length) return 'AmountAvailable';\n\n if (constructionNumbersInOption.length) return 'InOption';\n\n if (constructionNumberStatusses.indexOf('Sold') > -1) return 'Sold';\n }\n\n return;\n }\n};\n\nexport { getPropertyTypeStatus };\n"]}
1
+ {"version":3,"file":"property-type-status.js","sourceRoot":"","sources":["../../../src/extended-api-models/status/property-type-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGrE,MAAM,qBAAqB,GAAG,CAC1B,YAA+B,EAC/B,mBAA+C,EACjB,EAAE;IAChC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACzF,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACnF,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAE5F,IAAI,YAAY,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC;IAC/D,IAAI,YAAY,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAEtD,IAAI,CAAC,CAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,CAAA;QAAE,OAAO,sBAAsB,EAAE,CAAC;IAElE,QAAQ,YAAY,CAAC,MAAM,EAAE;QACzB,KAAK,eAAe;YAChB,OAAO,sBAAsB,EAAE,CAAC;QACpC,KAAK,SAAS;YACV,OAAO,SAAS,CAAC;QACrB,KAAK,QAAQ;YACT,OAAO,eAAe,EAAE,CAAC;QAC7B;YACI,OAAO;KACd;IAED,SAAS,sBAAsB;QAC3B,IAAI,YAAY,CAAC,QAAQ;YAAE,OAAO,eAAe,CAAC;QAElD,IAAI,aAAa,EAAE;YACf,MAAM,gBAAgB,GAAG,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ities/api-utilities.types';\nimport { betweenDates, calculateDifferenceInDays } from '../../date';\nimport { ConstructionNumberModel, ProjectPhaseModel } from '../../generated';\n\nconst getPropertyTypeStatus = (\n projectPhase: ProjectPhaseModel,\n constructionNumbers?: ConstructionNumberModel[],\n): PropertyTypeStatus | undefined => {\n const currentDate = new Date();\n const saleStartDate = projectPhase.saleStartDate && new Date(projectPhase.saleStartDate);\n const saleEndDate = projectPhase.saleEndDate && new Date(projectPhase.saleEndDate);\n const allocationDate = projectPhase.allocationDate && new Date(projectPhase.allocationDate);\n\n if (projectPhase.status === 'Sold') return 'UnderConstruction';\n if (projectPhase.status === 'Rented') return 'Rented';\n\n if (!constructionNumbers?.length) return getInPreparationStatus();\n\n switch (projectPhase.status) {\n case 'InPreparation':\n return getInPreparationStatus();\n case 'ForRent':\n return 'ForRent';\n case 'OnSale':\n return getOnSaleStatus();\n default:\n return;\n }\n\n function getInPreparationStatus(): PropertyTypeStatus {\n if (projectPhase.isRental) return 'InPreparation';\n\n if (saleStartDate) {\n const differenceInDays = calculateDifferenceInDays(saleStartDate, currentDate);\n\n if (differenceInDays <= 30) return 'SaleSoon';\n }\n\n return 'InPreparation';\n }\n\n function getOnSaleStatus(): PropertyTypeStatus | undefined {\n if (!saleStartDate || !saleEndDate || !allocationDate) return;\n\n const betweenSaleStartAndSaleEnd = betweenDates(saleStartDate, currentDate, saleEndDate);\n const betweenSaleStartAndAllocation = betweenDates(\n saleStartDate,\n currentDate,\n allocationDate,\n );\n const afterAllocation = currentDate >= allocationDate;\n\n if (betweenSaleStartAndSaleEnd) return 'SaleStarted';\n\n if (betweenSaleStartAndAllocation) return 'AssigningOn';\n\n if (afterAllocation) {\n const constructionNumberStatusses = constructionNumbers!.map(\n ({ availabilityStatus }) => availabilityStatus,\n );\n const constructionNumbersAvailable = constructionNumberStatusses.filter(\n (s) => s === 'Available',\n );\n const constructionNumbersInOption = constructionNumberStatusses.filter(\n (s) => s === 'InOption',\n );\n\n if (constructionNumbersAvailable.length) return 'AmountAvailable';\n\n if (constructionNumbersInOption.length) return 'InOption';\n\n if (constructionNumberStatusses.indexOf('Sold') > -1) return 'Sold';\n }\n\n return;\n }\n};\n\nexport { getPropertyTypeStatus };\n"]}
@@ -1,4 +1,7 @@
1
- const getApartmentBuildingView = (constructionNumber) => { var _a, _b; return (_b = (_a = constructionNumber.apartmentBuilding) === null || _a === void 0 ? void 0 : _a.views) === null || _b === void 0 ? void 0 : _b.find((s) => { var _a; return (_a = s.pointers) === null || _a === void 0 ? void 0 : _a.find((s) => s.constructionNumberId === constructionNumber.id); }); };
1
+ const getApartmentBuildingView = (constructionNumber) => {
2
+ var _a, _b;
3
+ return (_b = (_a = constructionNumber.apartmentBuilding) === null || _a === void 0 ? void 0 : _a.views) === null || _b === void 0 ? void 0 : _b.find((s) => { var _a; return (_a = s.pointers) === null || _a === void 0 ? void 0 : _a.find((s) => s.constructionNumberId === constructionNumber.id); });
4
+ };
2
5
  const getApartmentBuildingViewById = (constructionNumber, id) => { var _a, _b; return (_b = (_a = constructionNumber.apartmentBuilding) === null || _a === void 0 ? void 0 : _a.views) === null || _b === void 0 ? void 0 : _b.find((view) => view.id === id); };
3
6
  export { getApartmentBuildingView, getApartmentBuildingViewById };
4
7
  //# sourceMappingURL=apartment-building-view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apartment-building-view.js","sourceRoot":"","sources":["../../../src/extended-api-models/utilities/apartment-building-view.ts"],"names":[],"mappings":"AAEA,MAAM,wBAAwB,GAAG,CAAC,kBAA8C,EAAE,EAAE,kCAChF,kBAAkB,CAAC,iBAAiB,0CAAE,KAAK,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,wBACpD,CAAC,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,KAAK,kBAAkB,CAAC,EAAE,IAAC,IAC5E,CAAC;AAEN,MAAM,4BAA4B,GAAG,CAAC,kBAA8C,EAAE,EAAU,EAAE,EAAE,kCAChG,kBAAkB,CAAC,iBAAiB,0CAAE,KAAK,0CAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAC,CAAC;AAEhF,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,CAAC","sourcesContent":["import { ExtendedConstructionNumber } from '../../api-utilities/api-utilities.types';\n\nconst getApartmentBuildingView = (constructionNumber: ExtendedConstructionNumber) =>\n constructionNumber.apartmentBuilding?.views?.find((s) =>\n s.pointers?.find((s) => s.constructionNumberId === constructionNumber.id),\n );\n\nconst getApartmentBuildingViewById = (constructionNumber: ExtendedConstructionNumber, id: string) =>\n constructionNumber.apartmentBuilding?.views?.find((view) => view.id === id);\n\nexport { getApartmentBuildingView, getApartmentBuildingViewById };\n"]}
1
+ {"version":3,"file":"apartment-building-view.js","sourceRoot":"","sources":["../../../src/extended-api-models/utilities/apartment-building-view.ts"],"names":[],"mappings":"AAEA,MAAM,wBAAwB,GAAG,CAAC,kBAA8C,EAAE,EAAE;;IAChF,OAAA,MAAA,MAAA,kBAAkB,CAAC,iBAAiB,0CAAE,KAAK,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WACpD,OAAA,MAAA,CAAC,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,KAAK,kBAAkB,CAAC,EAAE,CAAC,CAAA,EAAA,CAC5E,CAAA;CAAA,CAAC;AAEN,MAAM,4BAA4B,GAAG,CAAC,kBAA8C,EAAE,EAAU,EAAE,EAAE,eAChG,OAAA,MAAA,MAAA,kBAAkB,CAAC,iBAAiB,0CAAE,KAAK,0CAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA,EAAA,CAAC;AAEhF,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,CAAC","sourcesContent":["import { ExtendedConstructionNumber } from '../../api-utilities/api-utilities.types';\n\nconst getApartmentBuildingView = (constructionNumber: ExtendedConstructionNumber) =>\n constructionNumber.apartmentBuilding?.views?.find((s) =>\n s.pointers?.find((s) => s.constructionNumberId === constructionNumber.id),\n );\n\nconst getApartmentBuildingViewById = (constructionNumber: ExtendedConstructionNumber, id: string) =>\n constructionNumber.apartmentBuilding?.views?.find((view) => view.id === id);\n\nexport { getApartmentBuildingView, getApartmentBuildingViewById };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"is-apartment.js","sourceRoot":"","sources":["../../../src/extended-api-models/utilities/is-apartment.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,GAAgB,CAAC,EAC9B,kBAAkB,EAClB,YAAY,GAIf,EAAW,EAAE;;IACV,IAAI,SAAoC,CAAC;IAEzC,IAAI,YAAY,EAAE;QACd,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC;KACtC;IAED,IAAI,kBAAkB,EAAE;QACpB,SAAS,SAAG,kBAAkB,CAAC,YAAY,0CAAE,SAAS,CAAC;KAC1D;IAED,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import {\n ExtendedConstructionNumber,\n ExtendedPropertyType,\n} from '../../api-utilities/api-utilities.types';\n\ninterface IsApartment {\n (obj: { constructionNumber: ExtendedConstructionNumber }): boolean;\n (obj: { propertyType: ExtendedPropertyType }): boolean;\n}\n\nconst isApartment: IsApartment = ({\n constructionNumber,\n propertyType,\n}: {\n constructionNumber?: ExtendedConstructionNumber;\n propertyType?: ExtendedPropertyType;\n}): boolean => {\n let houseType: string | undefined | null;\n\n if (propertyType) {\n houseType = propertyType.houseType;\n }\n\n if (constructionNumber) {\n houseType = constructionNumber.propertyType?.houseType;\n }\n\n return ['Appartement', 'Loft', 'Maisonette', 'Studio'].includes(houseType || '');\n};\n\nexport { isApartment };\n"]}
1
+ {"version":3,"file":"is-apartment.js","sourceRoot":"","sources":["../../../src/extended-api-models/utilities/is-apartment.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,GAAgB,CAAC,EAC9B,kBAAkB,EAClB,YAAY,GAIf,EAAW,EAAE;;IACV,IAAI,SAAoC,CAAC;IAEzC,IAAI,YAAY,EAAE;QACd,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC;KACtC;IAED,IAAI,kBAAkB,EAAE;QACpB,SAAS,GAAG,MAAA,kBAAkB,CAAC,YAAY,0CAAE,SAAS,CAAC;KAC1D;IAED,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import {\n ExtendedConstructionNumber,\n ExtendedPropertyType,\n} from '../../api-utilities/api-utilities.types';\n\ninterface IsApartment {\n (obj: { constructionNumber: ExtendedConstructionNumber }): boolean;\n (obj: { propertyType: ExtendedPropertyType }): boolean;\n}\n\nconst isApartment: IsApartment = ({\n constructionNumber,\n propertyType,\n}: {\n constructionNumber?: ExtendedConstructionNumber;\n propertyType?: ExtendedPropertyType;\n}): boolean => {\n let houseType: string | undefined | null;\n\n if (propertyType) {\n houseType = propertyType.houseType;\n }\n\n if (constructionNumber) {\n houseType = constructionNumber.propertyType?.houseType;\n }\n\n return ['Appartement', 'Loft', 'Maisonette', 'Studio'].includes(houseType || '');\n};\n\nexport { isApartment };\n"]}
@@ -3,7 +3,7 @@ export const functionIsTrue = (fn) => {
3
3
  const interval = setInterval(() => {
4
4
  if (fn()) {
5
5
  clearInterval(interval);
6
- resolve();
6
+ resolve(true);
7
7
  }
8
8
  }, 50);
9
9
  });
@@ -1 +1 @@
1
- {"version":3,"file":"function-is-true.js","sourceRoot":"","sources":["../src/function-is-true.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAY,EAAE,EAAE;IAC3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;YAC9B,IAAI,EAAE,EAAE,EAAE;gBACN,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACxB,OAAO,EAAE,CAAC;aACb;QACL,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["export const functionIsTrue = (fn: Function) => {\n return new Promise((resolve) => {\n const interval = setInterval(() => {\n if (fn()) {\n clearInterval(interval);\n resolve();\n }\n }, 50);\n });\n};\n"]}
1
+ {"version":3,"file":"function-is-true.js","sourceRoot":"","sources":["../src/function-is-true.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAY,EAAE,EAAE;IAC3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;YAC9B,IAAI,EAAE,EAAE,EAAE;gBACN,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACxB,OAAO,CAAC,IAAI,CAAC,CAAC;aACjB;QACL,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["export const functionIsTrue = (fn: Function) => {\n return new Promise((resolve) => {\n const interval = setInterval(() => {\n if (fn()) {\n clearInterval(interval);\n resolve(true);\n }\n }, 50);\n });\n};\n"]}
@@ -66,8 +66,8 @@ export interface AreaProjectModel {
66
66
  website?: WebsiteModel;
67
67
  id: string;
68
68
  }
69
- export declare type AreaStatus = 'InPreparation' | 'OnSale' | 'Sold';
70
- export declare type CRSType = 'unspecified' | 'name' | 'link';
69
+ export type AreaStatus = 'InPreparation' | 'OnSale' | 'Sold';
70
+ export type CRSType = 'unspecified' | 'name' | 'link';
71
71
  export interface CaseFormModel {
72
72
  areaProjectId?: string | null;
73
73
  districtId?: string | null;
@@ -171,7 +171,7 @@ export interface ConstructionNumberSpecifications {
171
171
  plotArea?: DecimalRange;
172
172
  volume?: DecimalRange;
173
173
  }
174
- export declare type ConstructionNumberStatus = 'Available' | 'InOption' | 'Sold' | 'Reserved';
174
+ export type ConstructionNumberStatus = 'Available' | 'InOption' | 'Sold' | 'Reserved';
175
175
  export interface CountryModel {
176
176
  isoCode?: string | null;
177
177
  name?: string | null;
@@ -188,7 +188,7 @@ export interface CustomerJourneyMilestone {
188
188
  nodeId?: string | null;
189
189
  url?: string | null;
190
190
  }
191
- export declare type CustomerJourneyMilestoneType = 'None' | 'NewPhaseAnnouncement' | 'SalesProcess' | 'ConceptAi' | 'ConstructionNumbersOnline' | 'FinalImages' | 'FinalPrices' | 'StartSaleAnnouncement' | 'WhatsIncluded' | 'StartSale' | 'ConstructionAwarded';
191
+ export type CustomerJourneyMilestoneType = 'None' | 'NewPhaseAnnouncement' | 'SalesProcess' | 'ConceptAi' | 'ConstructionNumbersOnline' | 'FinalImages' | 'FinalPrices' | 'StartSaleAnnouncement' | 'WhatsIncluded' | 'StartSale' | 'ConstructionAwarded';
192
192
  export interface DecimalRange {
193
193
  from?: number;
194
194
  to?: number | null;
@@ -322,7 +322,7 @@ export interface GardenModel {
322
322
  hasBackEntrance?: boolean | null;
323
323
  isMain?: boolean;
324
324
  }
325
- export declare type GeoJSONObjectType = 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | 'GeometryCollection' | 'Feature' | 'FeatureCollection';
325
+ export type GeoJSONObjectType = 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | 'GeometryCollection' | 'Feature' | 'FeatureCollection';
326
326
  export interface GrantModel {
327
327
  displayOnMap?: boolean;
328
328
  projectName?: string | null;
@@ -331,7 +331,7 @@ export interface GrantModel {
331
331
  status?: GrantStatus;
332
332
  id: string;
333
333
  }
334
- export declare type GrantStatus = 'NotActive' | 'ApplicationGranted';
334
+ export type GrantStatus = 'NotActive' | 'ApplicationGranted';
335
335
  export interface GroundLease {
336
336
  priceWithCanonDecimal?: number | null;
337
337
  canonPercentageYearly?: number | null;
@@ -343,7 +343,7 @@ export interface GroundLease {
343
343
  buyOffAmountDecimal?: number | null;
344
344
  priceWithBuyOffDecimal?: number | null;
345
345
  }
346
- export declare type HolidayFrequency = 'Once' | 'Monthly' | 'Yearly';
346
+ export type HolidayFrequency = 'Once' | 'Monthly' | 'Yearly';
347
347
  export interface HouseSelectorModel {
348
348
  areaProjectId?: string | null;
349
349
  districtId?: string | null;
@@ -492,7 +492,7 @@ export interface PipelineProjectModel {
492
492
  export interface PipelineProjectQuery {
493
493
  [key: string]: any;
494
494
  }
495
- export declare type PipelineProjectStatus = 'InPreparation' | 'UnderConstruction' | 'Finished' | 'SoonForRent' | 'ForRent' | 'Rented';
495
+ export type PipelineProjectStatus = 'InPreparation' | 'UnderConstruction' | 'Finished' | 'SoonForRent' | 'ForRent' | 'Rented';
496
496
  export interface Point {
497
497
  x?: number;
498
498
  y?: number;
@@ -500,8 +500,8 @@ export interface Point {
500
500
  export interface PolygonModel {
501
501
  coordinates?: number[][] | null;
502
502
  }
503
- export declare type PriceCondition = 'VrijOpNaam' | 'KostenKoper';
504
- export declare type PriceType = 'ExactSum' | 'AskingPrice' | 'StartsFrom' | 'Indication' | 'Circa' | 'PriceOnRequest';
503
+ export type PriceCondition = 'VrijOpNaam' | 'KostenKoper';
504
+ export type PriceType = 'ExactSum' | 'AskingPrice' | 'StartsFrom' | 'Indication' | 'Circa' | 'PriceOnRequest';
505
505
  export interface ProblemDetails {
506
506
  type?: string | null;
507
507
  title?: string | null;
@@ -562,7 +562,7 @@ export interface ProjectPhaseModel {
562
562
  customerJourneyMilestones?: CustomerJourneyMilestone[] | null;
563
563
  id: string;
564
564
  }
565
- export declare type ProjectPhaseStatus = 'InPreparation' | 'OnSale' | 'Sold' | 'ForRent' | 'Rented' | 'NotActive';
565
+ export type ProjectPhaseStatus = 'InPreparation' | 'OnSale' | 'Sold' | 'ForRent' | 'Rented' | 'NotActive';
566
566
  export interface PropertyLight {
567
567
  id?: string | null;
568
568
  projectId?: string | null;
@@ -685,8 +685,8 @@ export interface Room {
685
685
  renewedIn?: string | null;
686
686
  facilities?: string[] | null;
687
687
  }
688
- export declare type SaleSpecification = 'ExclusiefBouwrente' | 'BtwBelast' | 'InclusiefBtw';
689
- export declare type Salutation = 'Undefined' | 'Mr' | 'Mrs' | 'Ms';
688
+ export type SaleSpecification = 'ExclusiefBouwrente' | 'BtwBelast' | 'InclusiefBtw';
689
+ export type Salutation = 'Undefined' | 'Mr' | 'Mrs' | 'Ms';
690
690
  export interface SeoText {
691
691
  saleTitle?: string | null;
692
692
  saleText?: string | null;
@@ -740,7 +740,7 @@ export interface Vve {
740
740
  hasReserveFunds?: boolean | null;
741
741
  hasMeetings?: boolean | null;
742
742
  }
743
- export declare type WebchatType = 'None' | 'UnifiedCommunications' | 'Salesforce';
743
+ export type WebchatType = 'None' | 'UnifiedCommunications' | 'Salesforce';
744
744
  export interface WebsiteContactModel {
745
745
  enableWebchat?: boolean;
746
746
  webchatType?: WebchatType;
@@ -1028,69 +1028,69 @@ export interface ResourceDeleteResourceQueryParams {
1028
1028
  apiKey?: string;
1029
1029
  projectId?: string;
1030
1030
  }
1031
- export declare const activationEngineGetProfile: (clientId: string, params?: ActivationEngineGetProfileQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ActivationEngineModel>;
1032
- export declare const apartmentBuildingQuery: (params?: ApartmentBuildingQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ApartmentBuildingModel[]>;
1033
- export declare const apartmentBuildingUpdateApartmentBuilding: (nodeId: string, body: UpdateApartmentBuildingModel, config?: RequestConfig | undefined) => Promise<void>;
1034
- export declare const apartmentBuildingDeleteApartmentBuilding: (nodeId: string, body: any, config?: RequestConfig | undefined) => Promise<void>;
1035
- export declare const apartmentBuildingGetByExternalId: (nodeId: string, params?: ApartmentBuildingGetByExternalIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ApartmentBuildingModel>;
1036
- export declare const areaProjectGetById: (id: string, params?: AreaProjectGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<AreaProjectModel>;
1037
- export declare const areaProjectQuery: (params?: AreaProjectQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<AreaProjectModel[]>;
1038
- export declare const cityGetByName: (name: string, params?: CityGetByNameQueryParams | undefined, config?: RequestConfig | undefined) => Promise<CityModel>;
1039
- export declare const cityGetById: (id: string, params?: CityGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<CityModel>;
1040
- export declare const cityQuery: (params?: CityQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<CityModel[]>;
1041
- export declare const constructionNumberGetById: (id: string, params?: ConstructionNumberGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ConstructionNumberModel>;
1042
- export declare const constructionNumberQuery: (params?: ConstructionNumberQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ConstructionNumberModel[]>;
1043
- export declare const constructionNumberGet: (projectId: string, constructionNumber: string, params?: any, config?: RequestConfig | undefined) => Promise<ConstructionNumberLight>;
1044
- export declare const constructionNumberList: (projectId: string, params?: any, config?: RequestConfig | undefined) => Promise<ConstructionNumberLight>;
1045
- export declare const countryGetByIsoCode: (isoCode: string, params?: CountryGetByIsoCodeQueryParams | undefined, config?: RequestConfig | undefined) => Promise<CountryModel>;
1046
- export declare const countryGetById: (id: string, params?: CountryGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<CountryModel>;
1047
- export declare const countryQuery: (params?: CountryQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<CountryModel[]>;
1048
- export declare const digitalBrochureGetById: (id: string, params?: any, config?: RequestConfig | undefined) => Promise<DigitalBrochureModel>;
1049
- export declare const districtGetById: (id: string, params?: DistrictGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<DistrictModel>;
1050
- export declare const districtQuery: (params?: DistrictQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<DistrictModel[]>;
1051
- export declare const documentGetById: (id: string, params?: DocumentGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<DocumentModel>;
1052
- export declare const documentQuery: (params?: DocumentQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<DocumentModel[]>;
1053
- export declare const formLead: (body: LeadFormModel, config?: RequestConfig | undefined) => Promise<void>;
1054
- export declare const formCase: (body: CaseFormModel, config?: RequestConfig | undefined) => Promise<void>;
1055
- export declare const formDynamic: (body: DynamicFormModel, config?: RequestConfig | undefined) => Promise<void>;
1056
- export declare const formDigitalBrochure: (body: DigitalBrochureRequestModel, config?: RequestConfig | undefined) => Promise<void>;
1057
- export declare const fundaQuery: (params?: FundaQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ProjectModel[]>;
1058
- export declare const fundaGet: (params?: FundaGetQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1059
- export declare const fundaSubmit: (body: any, config?: RequestConfig | undefined) => Promise<void>;
1060
- export declare const fundaSubmitRoute: (id: string, body: any, config?: RequestConfig | undefined) => Promise<void>;
1061
- export declare const fundaRunTransactionCheck: (params?: FundaRunTransactionCheckQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1062
- export declare const fundaValidate: (body: any, config?: RequestConfig | undefined) => Promise<void>;
1063
- export declare const fundaShowLastSubmittedProject: (params?: FundaShowLastSubmittedProjectQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1064
- export declare const fundaShowConvertedFundaObject: (params?: FundaShowConvertedFundaObjectQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1065
- export declare const fundaCompareFundaObjectRevisionChanges: (params?: FundaCompareFundaObjectRevisionChangesQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1066
- export declare const fundaShowFundaProjectLogs: (params?: FundaShowFundaProjectLogsQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1067
- export declare const fundaExecuteFundaPublisher: (params?: FundaExecuteFundaPublisherQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1068
- export declare const fundaGetAllGwnVersionsByProjectId: (params?: FundaGetAllGwnVersionsByProjectIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1069
- export declare const fundaRemoveVersionFromGwn: (params?: FundaRemoveVersionFromGwnQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1070
- export declare const fundaGetActiveBrokersInGateway: (params?: FundaGetActiveBrokersInGatewayQueryParams | undefined, config?: RequestConfig | undefined) => Promise<void>;
1071
- export declare const grantGetById: (id: string, params?: GrantGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<GrantModel>;
1072
- export declare const grantQuery: (params?: GrantQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<GrantModel[]>;
1073
- export declare const houseSelectorQuery: (params?: HouseSelectorQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<HouseSelectorModel[]>;
1074
- export declare const houseSelectorUpdateHouseSelector: (nodeId: string, body: UpdateHouseSelectorBaseModel, config?: RequestConfig | undefined) => Promise<void>;
1075
- export declare const houseSelectorDeleteHouseSelector: (nodeId: string, body: any, config?: RequestConfig | undefined) => Promise<void>;
1076
- export declare const houseSelectorGetByExternalId: (nodeId: string, params?: HouseSelectorGetByExternalIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<HouseSelectorModel>;
1077
- export declare const houseSelectorPublishHouseSelector: (nodeId: string, body: any, config?: RequestConfig | undefined) => Promise<void>;
1078
- export declare const houseSelectorUpdateHouseSelectorViews: (nodeId: string, body: UpdateHouseSelectorViewsModel, config?: RequestConfig | undefined) => Promise<void>;
1079
- export declare const houseSelectorGetDraftByExternalId: (nodeId: string, params?: HouseSelectorGetDraftByExternalIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<HouseSelectorModel>;
1080
- export declare const pipelineProjectGetById: (id: string, params?: PipelineProjectGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<PipelineProjectModel>;
1081
- export declare const pipelineProjectQuery: (params?: PipelineProjectQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<PipelineProjectModel[]>;
1082
- export declare const projectPhaseSetCustomerJourneyMilestone: (id: string, body: CustomerJourneyMilestone, config?: RequestConfig | undefined) => Promise<void>;
1083
- export declare const projectPhaseDeleteCustomerJourneyMilestone: (id: string, nodeId: string, body: any, config?: RequestConfig | undefined) => Promise<void>;
1084
- export declare const projectPhaseGetById: (id: string, params?: ProjectPhaseGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ProjectPhaseModel>;
1085
- export declare const projectPhaseQuery: (params?: ProjectPhaseQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ProjectPhaseModel[]>;
1086
- export declare const propertyGetPublicProperties: (params?: any, config?: RequestConfig | undefined) => Promise<PropertyLight>;
1087
- export declare const propertyList: (projectId: string, params?: any, config?: RequestConfig | undefined) => Promise<PropertyLight>;
1088
- export declare const propertyTypeGetById: (id: string, params?: PropertyTypeGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<PropertyTypeModel>;
1089
- export declare const propertyTypeQuery: (params?: PropertyTypeQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<PropertyTypeModel[]>;
1090
- export declare const provinceGetByName: (name: string, params?: ProvinceGetByNameQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ProvinceModel>;
1091
- export declare const provinceGetById: (id: string, params?: ProvinceGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ProvinceModel>;
1092
- export declare const provinceQuery: (params?: ProvinceQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<ProvinceModel[]>;
1093
- export declare const regionGetById: (id: string, params?: RegionGetByIdQueryParams | undefined, config?: RequestConfig | undefined) => Promise<RegionModel>;
1094
- export declare const regionQuery: (params?: RegionQueryQueryParams | undefined, config?: RequestConfig | undefined) => Promise<RegionModel[]>;
1095
- export declare const resourceUpdateResource: (mediaId: string, body: UpdateResourceModel, config?: RequestConfig | undefined) => Promise<void>;
1096
- export declare const resourceDeleteResource: (mediaId: string, body: any, config?: RequestConfig | undefined) => Promise<void>;
1031
+ export declare const activationEngineGetProfile: (clientId: string, params?: ActivationEngineGetProfileQueryParams, config?: RequestConfig) => Promise<ActivationEngineModel>;
1032
+ export declare const apartmentBuildingQuery: (params?: ApartmentBuildingQueryQueryParams, config?: RequestConfig) => Promise<ApartmentBuildingModel[]>;
1033
+ export declare const apartmentBuildingUpdateApartmentBuilding: (nodeId: string, body: UpdateApartmentBuildingModel, config?: RequestConfig) => Promise<never>;
1034
+ export declare const apartmentBuildingDeleteApartmentBuilding: (nodeId: string, body: any, config?: RequestConfig) => Promise<never>;
1035
+ export declare const apartmentBuildingGetByExternalId: (nodeId: string, params?: ApartmentBuildingGetByExternalIdQueryParams, config?: RequestConfig) => Promise<ApartmentBuildingModel>;
1036
+ export declare const areaProjectGetById: (id: string, params?: AreaProjectGetByIdQueryParams, config?: RequestConfig) => Promise<AreaProjectModel>;
1037
+ export declare const areaProjectQuery: (params?: AreaProjectQueryQueryParams, config?: RequestConfig) => Promise<AreaProjectModel[]>;
1038
+ export declare const cityGetByName: (name: string, params?: CityGetByNameQueryParams, config?: RequestConfig) => Promise<CityModel>;
1039
+ export declare const cityGetById: (id: string, params?: CityGetByIdQueryParams, config?: RequestConfig) => Promise<CityModel>;
1040
+ export declare const cityQuery: (params?: CityQueryQueryParams, config?: RequestConfig) => Promise<CityModel[]>;
1041
+ export declare const constructionNumberGetById: (id: string, params?: ConstructionNumberGetByIdQueryParams, config?: RequestConfig) => Promise<ConstructionNumberModel>;
1042
+ export declare const constructionNumberQuery: (params?: ConstructionNumberQueryQueryParams, config?: RequestConfig) => Promise<ConstructionNumberModel[]>;
1043
+ export declare const constructionNumberGet: (projectId: string, constructionNumber: string, params?: any, config?: RequestConfig) => Promise<ConstructionNumberLight>;
1044
+ export declare const constructionNumberList: (projectId: string, params?: any, config?: RequestConfig) => Promise<ConstructionNumberLight>;
1045
+ export declare const countryGetByIsoCode: (isoCode: string, params?: CountryGetByIsoCodeQueryParams, config?: RequestConfig) => Promise<CountryModel>;
1046
+ export declare const countryGetById: (id: string, params?: CountryGetByIdQueryParams, config?: RequestConfig) => Promise<CountryModel>;
1047
+ export declare const countryQuery: (params?: CountryQueryQueryParams, config?: RequestConfig) => Promise<CountryModel[]>;
1048
+ export declare const digitalBrochureGetById: (id: string, params?: any, config?: RequestConfig) => Promise<DigitalBrochureModel>;
1049
+ export declare const districtGetById: (id: string, params?: DistrictGetByIdQueryParams, config?: RequestConfig) => Promise<DistrictModel>;
1050
+ export declare const districtQuery: (params?: DistrictQueryQueryParams, config?: RequestConfig) => Promise<DistrictModel[]>;
1051
+ export declare const documentGetById: (id: string, params?: DocumentGetByIdQueryParams, config?: RequestConfig) => Promise<DocumentModel>;
1052
+ export declare const documentQuery: (params?: DocumentQueryQueryParams, config?: RequestConfig) => Promise<DocumentModel[]>;
1053
+ export declare const formLead: (body: LeadFormModel, config?: RequestConfig) => Promise<never>;
1054
+ export declare const formCase: (body: CaseFormModel, config?: RequestConfig) => Promise<never>;
1055
+ export declare const formDynamic: (body: DynamicFormModel, config?: RequestConfig) => Promise<never>;
1056
+ export declare const formDigitalBrochure: (body: DigitalBrochureRequestModel, config?: RequestConfig) => Promise<never>;
1057
+ export declare const fundaQuery: (params?: FundaQueryQueryParams, config?: RequestConfig) => Promise<ProjectModel[]>;
1058
+ export declare const fundaGet: (params?: FundaGetQueryParams, config?: RequestConfig) => Promise<never>;
1059
+ export declare const fundaSubmit: (body: any, config?: RequestConfig) => Promise<never>;
1060
+ export declare const fundaSubmitRoute: (id: string, body: any, config?: RequestConfig) => Promise<never>;
1061
+ export declare const fundaRunTransactionCheck: (params?: FundaRunTransactionCheckQueryParams, config?: RequestConfig) => Promise<never>;
1062
+ export declare const fundaValidate: (body: any, config?: RequestConfig) => Promise<never>;
1063
+ export declare const fundaShowLastSubmittedProject: (params?: FundaShowLastSubmittedProjectQueryParams, config?: RequestConfig) => Promise<never>;
1064
+ export declare const fundaShowConvertedFundaObject: (params?: FundaShowConvertedFundaObjectQueryParams, config?: RequestConfig) => Promise<never>;
1065
+ export declare const fundaCompareFundaObjectRevisionChanges: (params?: FundaCompareFundaObjectRevisionChangesQueryParams, config?: RequestConfig) => Promise<never>;
1066
+ export declare const fundaShowFundaProjectLogs: (params?: FundaShowFundaProjectLogsQueryParams, config?: RequestConfig) => Promise<never>;
1067
+ export declare const fundaExecuteFundaPublisher: (params?: FundaExecuteFundaPublisherQueryParams, config?: RequestConfig) => Promise<never>;
1068
+ export declare const fundaGetAllGwnVersionsByProjectId: (params?: FundaGetAllGwnVersionsByProjectIdQueryParams, config?: RequestConfig) => Promise<never>;
1069
+ export declare const fundaRemoveVersionFromGwn: (params?: FundaRemoveVersionFromGwnQueryParams, config?: RequestConfig) => Promise<never>;
1070
+ export declare const fundaGetActiveBrokersInGateway: (params?: FundaGetActiveBrokersInGatewayQueryParams, config?: RequestConfig) => Promise<never>;
1071
+ export declare const grantGetById: (id: string, params?: GrantGetByIdQueryParams, config?: RequestConfig) => Promise<GrantModel>;
1072
+ export declare const grantQuery: (params?: GrantQueryQueryParams, config?: RequestConfig) => Promise<GrantModel[]>;
1073
+ export declare const houseSelectorQuery: (params?: HouseSelectorQueryQueryParams, config?: RequestConfig) => Promise<HouseSelectorModel[]>;
1074
+ export declare const houseSelectorUpdateHouseSelector: (nodeId: string, body: UpdateHouseSelectorBaseModel, config?: RequestConfig) => Promise<never>;
1075
+ export declare const houseSelectorDeleteHouseSelector: (nodeId: string, body: any, config?: RequestConfig) => Promise<never>;
1076
+ export declare const houseSelectorGetByExternalId: (nodeId: string, params?: HouseSelectorGetByExternalIdQueryParams, config?: RequestConfig) => Promise<HouseSelectorModel>;
1077
+ export declare const houseSelectorPublishHouseSelector: (nodeId: string, body: any, config?: RequestConfig) => Promise<never>;
1078
+ export declare const houseSelectorUpdateHouseSelectorViews: (nodeId: string, body: UpdateHouseSelectorViewsModel, config?: RequestConfig) => Promise<never>;
1079
+ export declare const houseSelectorGetDraftByExternalId: (nodeId: string, params?: HouseSelectorGetDraftByExternalIdQueryParams, config?: RequestConfig) => Promise<HouseSelectorModel>;
1080
+ export declare const pipelineProjectGetById: (id: string, params?: PipelineProjectGetByIdQueryParams, config?: RequestConfig) => Promise<PipelineProjectModel>;
1081
+ export declare const pipelineProjectQuery: (params?: PipelineProjectQueryQueryParams, config?: RequestConfig) => Promise<PipelineProjectModel[]>;
1082
+ export declare const projectPhaseSetCustomerJourneyMilestone: (id: string, body: CustomerJourneyMilestone, config?: RequestConfig) => Promise<never>;
1083
+ export declare const projectPhaseDeleteCustomerJourneyMilestone: (id: string, nodeId: string, body: any, config?: RequestConfig) => Promise<never>;
1084
+ export declare const projectPhaseGetById: (id: string, params?: ProjectPhaseGetByIdQueryParams, config?: RequestConfig) => Promise<ProjectPhaseModel>;
1085
+ export declare const projectPhaseQuery: (params?: ProjectPhaseQueryQueryParams, config?: RequestConfig) => Promise<ProjectPhaseModel[]>;
1086
+ export declare const propertyGetPublicProperties: (params?: any, config?: RequestConfig) => Promise<PropertyLight>;
1087
+ export declare const propertyList: (projectId: string, params?: any, config?: RequestConfig) => Promise<PropertyLight>;
1088
+ export declare const propertyTypeGetById: (id: string, params?: PropertyTypeGetByIdQueryParams, config?: RequestConfig) => Promise<PropertyTypeModel>;
1089
+ export declare const propertyTypeQuery: (params?: PropertyTypeQueryQueryParams, config?: RequestConfig) => Promise<PropertyTypeModel[]>;
1090
+ export declare const provinceGetByName: (name: string, params?: ProvinceGetByNameQueryParams, config?: RequestConfig) => Promise<ProvinceModel>;
1091
+ export declare const provinceGetById: (id: string, params?: ProvinceGetByIdQueryParams, config?: RequestConfig) => Promise<ProvinceModel>;
1092
+ export declare const provinceQuery: (params?: ProvinceQueryQueryParams, config?: RequestConfig) => Promise<ProvinceModel[]>;
1093
+ export declare const regionGetById: (id: string, params?: RegionGetByIdQueryParams, config?: RequestConfig) => Promise<RegionModel>;
1094
+ export declare const regionQuery: (params?: RegionQueryQueryParams, config?: RequestConfig) => Promise<RegionModel[]>;
1095
+ export declare const resourceUpdateResource: (mediaId: string, body: UpdateResourceModel, config?: RequestConfig) => Promise<never>;
1096
+ export declare const resourceDeleteResource: (mediaId: string, body: any, config?: RequestConfig) => Promise<never>;
@@ -2,7 +2,10 @@ import { BoundingBox, Coordinate, Coordinates, MapData } from '@bpd-library/type
2
2
  declare const calculateBoundingBox: (coordinates: Coordinates) => [number, number, number, number];
3
3
  declare const calculateMapDataBoundingBox: (mapData: MapData) => BoundingBox;
4
4
  declare const calculateMapDataCenter: (mapData: MapData) => Coordinate;
5
- declare const calculateBoundingBoxCenter: ([minX, minY, maxX, maxY]: [number, number, number, number]) => [number, number];
5
+ declare const calculateBoundingBoxCenter: ([minX, minY, maxX, maxY]: [number, number, number, number]) => [
6
+ number,
7
+ number
8
+ ];
6
9
  declare const calculateCenter: (coordinates: Coordinates) => Coordinate;
7
10
  declare const mergeBoundingBoxes: (boundingBoxes: BoundingBox[]) => BoundingBox;
8
11
  declare const expandBoundingBox: ([minX, minY, maxX, maxY]: BoundingBox, km: number) => BoundingBox;
@@ -1,6 +1,6 @@
1
- export declare type Selector = HTMLElement | HTMLCollection | NodeList | HTMLInputElement;
2
- export declare type Options = {
1
+ export type Selector = HTMLElement | HTMLCollection | NodeList | HTMLInputElement;
2
+ export type Options = {
3
3
  removeListener: boolean;
4
4
  };
5
- export declare type Callback = (state: boolean | null) => void;
5
+ export type Callback = (state: boolean | null) => void;
6
6
  export declare function useClickOutside(selector: Selector, callback: Callback, options?: Options): EventListener;
@@ -1,12 +1,17 @@
1
1
  import { MutableRefObject } from '@atomify/hooks/dist/hooks';
2
- declare type LazyResult = HTMLElement;
2
+ type LazyResult = HTMLElement;
3
3
  interface UseLazyProps<T> {
4
4
  fetcher: () => Promise<T>;
5
5
  loadingResult: () => LazyResult;
6
6
  errorResult: () => LazyResult;
7
7
  successResult: (data?: T) => LazyResult;
8
8
  }
9
- declare type LazyReturn<T> = [() => LazyResult, () => Promise<void>, MutableRefObject<T | null>, MutableRefObject<string>];
9
+ type LazyReturn<T> = [
10
+ () => LazyResult,
11
+ () => Promise<void>,
12
+ MutableRefObject<T | null>,
13
+ MutableRefObject<string>
14
+ ];
10
15
  export declare const LAZY_HOOKS: {
11
16
  LAZY_LOADING_HOOK: string;
12
17
  LAZY_ERROR_HOOK: string;
@@ -1,10 +1,10 @@
1
- declare type ScrollPosition = {
1
+ type ScrollPosition = {
2
2
  x: number;
3
3
  y: number;
4
4
  };
5
- export declare type ScrollCallback = {
5
+ export type ScrollCallback = {
6
6
  prevPosition: ScrollPosition;
7
7
  currentPosition: ScrollPosition;
8
8
  };
9
- export declare const useScrollPosition: (callback: ({ currentPosition, prevPosition }: ScrollCallback) => void, useWindow?: boolean | undefined) => void;
9
+ export declare const useScrollPosition: (callback: ({ currentPosition, prevPosition }: ScrollCallback) => void, useWindow?: boolean) => void;
10
10
  export {};
@@ -14,7 +14,7 @@ export const useScrollTo = (options = {}) => {
14
14
  return to;
15
15
  };
16
16
  function scrollTo({ position, offset, duration, scrollElement, delay, }) {
17
- return new Promise(resolve => {
17
+ return new Promise((resolve) => {
18
18
  const scrollPosition = window.scrollY === undefined ? window.pageYOffset : window.scrollY;
19
19
  const to = parseInt((position.top + scrollPosition - offset).toFixed(0), 10);
20
20
  const start = scrollElement
@@ -36,7 +36,7 @@ function scrollTo({ position, offset, duration, scrollElement, delay, }) {
36
36
  document.documentElement.scrollTop = val;
37
37
  }
38
38
  if ((val >= to && direction === 1) || (val <= to && direction === 0)) {
39
- resolve();
39
+ resolve(true);
40
40
  }
41
41
  else {
42
42
  requestAnimationFrame(animate);
@@ -1 +1 @@
1
- {"version":3,"file":"use-scroll-to.js","sourceRoot":"","sources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CAAC,EAAE;QACP,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KAC9B;IACD,CAAC,EAAE,CAAC;IACJ,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["const ST_DURATION = 500;\nconst ST_OFFSET = 50;\n\ninterface ScrollOptions {\n offset?: number;\n duration?: number;\n scrollElement?: HTMLElement;\n delay?: number;\n}\n\nexport const useScrollTo = (options: ScrollOptions = {}) => {\n function to(target: HTMLElement) {\n const scrollConfig = {\n position: target.getBoundingClientRect(),\n offset: options.offset || ST_OFFSET,\n duration: options.duration || ST_DURATION,\n scrollElement: options.scrollElement || null,\n delay: options.delay || 0,\n };\n\n return scrollTo(scrollConfig);\n }\n\n return to;\n};\n\n/**\n * Scrolls to an element\n * @param {({\n * position: DOMRect;\n * offset: number;\n * duration: number;\n * scrollElement: HTMLElement | null;\n * })} {\n * position,\n * offset,\n * duration,\n * scrollElement,\n * }\n * @returns\n */\nfunction scrollTo({\n position,\n offset,\n duration,\n scrollElement,\n delay,\n}: {\n position: DOMRect;\n offset: number;\n duration: number;\n scrollElement: HTMLElement | null;\n delay: number;\n}) {\n return new Promise(resolve => {\n const scrollPosition = window.scrollY === undefined ? window.pageYOffset : window.scrollY;\n const to = parseInt((position.top + scrollPosition - offset).toFixed(0), 10);\n const start = scrollElement\n ? scrollElement.scrollTop\n : Math.max(document.body.scrollTop, document.documentElement.scrollTop);\n const change = to - start;\n let currentTime = 0;\n const increment = 10;\n const direction = to > start ? 1 : 0;\n\n let timeout: any;\n\n const animate = () => {\n currentTime += increment;\n const val = parseInt(\n easeInOutQuad(currentTime, start, change, duration).toFixed(0),\n 10,\n );\n\n if (scrollElement) {\n scrollElement.scrollTop = val;\n } else {\n document.body.scrollTop = val;\n document.documentElement.scrollTop = val;\n }\n\n if ((val >= to && direction === 1) || (val <= to && direction === 0)) {\n resolve();\n } else {\n requestAnimationFrame(animate);\n }\n };\n\n if (delay > 0) {\n timeout = setTimeout(() => {\n animate();\n clearTimeout(timeout);\n }, delay);\n } else {\n animate();\n }\n });\n}\n\nfunction easeInOutQuad(t: number, b: number, c: number, d: number) {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t * t + b;\n }\n t--;\n return (-c / 2) * (t * (t - 2) - 1) + b;\n}\n"]}
1
+ {"version":3,"file":"use-scroll-to.js","sourceRoot":"","sources":["../../src/hooks/use-scroll-to.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,SAAS,GAAG,EAAE,CAAC;AASrB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAyB,EAAE,EAAE,EAAE;IACvD,SAAS,EAAE,CAAC,MAAmB;QAC3B,MAAM,YAAY,GAAG;YACjB,QAAQ,EAAE,MAAM,CAAC,qBAAqB,EAAE;YACxC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,SAAS;YACnC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,WAAW;YACzC,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;YAC5C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;SAC5B,CAAC;QAEF,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAiBF,SAAS,QAAQ,CAAC,EACd,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,aAAa,EACb,KAAK,GAOR;IACG,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QA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AC,CAAC;QAEF,IAAI,KAAK,GAAG,CAAC,EAAE;YACX,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBACtB,OAAO,EAAE,CAAC;gBACV,YAAY,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC,EAAE,KAAK,CAAC,CAAC;SACb;aAAM;YACH,OAAO,EAAE,CAAC;SACb;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,aAAa,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IAC7D,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,EAAE;QACP,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KAC9B;IACD,CAAC,EAAE,CAAC;IACJ,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["const ST_DURATION = 500;\nconst ST_OFFSET = 50;\n\ninterface ScrollOptions {\n offset?: number;\n duration?: number;\n scrollElement?: HTMLElement;\n delay?: number;\n}\n\nexport const useScrollTo = (options: ScrollOptions = {}) => {\n function to(target: HTMLElement) {\n const scrollConfig = {\n position: target.getBoundingClientRect(),\n offset: options.offset || ST_OFFSET,\n duration: options.duration || ST_DURATION,\n scrollElement: options.scrollElement || null,\n delay: options.delay || 0,\n };\n\n return scrollTo(scrollConfig);\n }\n\n return to;\n};\n\n/**\n * Scrolls to an element\n * @param {({\n * position: DOMRect;\n * offset: number;\n * duration: number;\n * scrollElement: HTMLElement | null;\n * })} {\n * position,\n * offset,\n * duration,\n * scrollElement,\n * }\n * @returns\n */\nfunction scrollTo({\n position,\n offset,\n duration,\n scrollElement,\n delay,\n}: {\n position: DOMRect;\n offset: number;\n duration: number;\n scrollElement: HTMLElement | null;\n delay: number;\n}) {\n return new Promise((resolve) => {\n const scrollPosition = window.scrollY === undefined ? window.pageYOffset : window.scrollY;\n const to = parseInt((position.top + scrollPosition - offset).toFixed(0), 10);\n const start = scrollElement\n ? scrollElement.scrollTop\n : Math.max(document.body.scrollTop, document.documentElement.scrollTop);\n const change = to - start;\n let currentTime = 0;\n const increment = 10;\n const direction = to > start ? 1 : 0;\n\n let timeout: any;\n\n const animate = () => {\n currentTime += increment;\n const val = parseInt(\n easeInOutQuad(currentTime, start, change, duration).toFixed(0),\n 10,\n );\n\n if (scrollElement) {\n scrollElement.scrollTop = val;\n } else {\n document.body.scrollTop = val;\n document.documentElement.scrollTop = val;\n }\n\n if ((val >= to && direction === 1) || (val <= to && direction === 0)) {\n resolve(true);\n } else {\n requestAnimationFrame(animate);\n }\n };\n\n if (delay > 0) {\n timeout = setTimeout(() => {\n animate();\n clearTimeout(timeout);\n }, delay);\n } else {\n animate();\n }\n });\n}\n\nfunction easeInOutQuad(t: number, b: number, c: number, d: number) {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t * t + b;\n }\n t--;\n return (-c / 2) * (t * (t - 2) - 1) + b;\n}\n"]}
package/dist/is-touch.js CHANGED
@@ -2,12 +2,12 @@ const IS_TOUCH = 'is-touch';
2
2
  const WITH_MOUSE = `${IS_TOUCH}--with-mouse`;
3
3
  const html = document.documentElement;
4
4
  export class DetectTouch {
5
+ get isTouchDevice() {
6
+ return this.touch;
7
+ }
5
8
  constructor() {
6
9
  this.hasMouse = false;
7
- this.touch =
8
- 'ontouchstart' in html ||
9
- navigator.maxTouchPoints > 0 ||
10
- navigator.msMaxTouchPoints > 0;
10
+ this.touch = 'ontouchstart' in html || navigator.maxTouchPoints > 0;
11
11
  html.addEventListener('touchstart', () => {
12
12
  html.removeEventListener('mousemove', () => this.handleMouseEvent());
13
13
  });
@@ -16,9 +16,6 @@ export class DetectTouch {
16
16
  html.classList.add(IS_TOUCH);
17
17
  }
18
18
  }
19
- get isTouchDevice() {
20
- return this.touch;
21
- }
22
19
  handleMouseEvent() {
23
20
  if (!this.hasMouse && html.classList.contains(IS_TOUCH)) {
24
21
  html.classList.add(WITH_MOUSE);
@@ -1 +1 @@
1
- {"version":3,"file":"is-touch.js","sourceRoot":"","sources":["../src/is-touch.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,UAAU,GAAG,GAAG,QAAQ,cAAc,CAAC;AAC7C,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC;AAEtC,MAAM,OAAO,WAAW;IAQpB;QACI,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,KAAK;YACN,cAAc,IAAI,IAAI;gBACtB,SAAS,CAAC,cAAc,GAAG,CAAC;gBAC5B,SAAS,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAEnC,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE;YACrC,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAElE,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAChC;IACL,CAAC;IApBD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAoBD,gBAAgB;QACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACrD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;IACL,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["const IS_TOUCH = 'is-touch';\nconst WITH_MOUSE = `${IS_TOUCH}--with-mouse`;\nconst html = document.documentElement;\n\nexport class DetectTouch {\n touch: boolean;\n hasMouse: boolean;\n\n get isTouchDevice() {\n return this.touch;\n }\n\n constructor() {\n this.hasMouse = false;\n this.touch =\n 'ontouchstart' in html ||\n navigator.maxTouchPoints > 0 ||\n navigator.msMaxTouchPoints > 0;\n\n html.addEventListener('touchstart', () => {\n html.removeEventListener('mousemove', () => this.handleMouseEvent());\n });\n\n html.addEventListener('mousemove', () => this.handleMouseEvent());\n\n if (this.touch) {\n html.classList.add(IS_TOUCH);\n }\n }\n\n handleMouseEvent() {\n if (!this.hasMouse && html.classList.contains(IS_TOUCH)) {\n html.classList.add(WITH_MOUSE);\n this.hasMouse = true;\n }\n }\n}\n\nexport const detectTouch = new DetectTouch();\n"]}
1
+ {"version":3,"file":"is-touch.js","sourceRoot":"","sources":["../src/is-touch.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,UAAU,GAAG,GAAG,QAAQ,cAAc,CAAC;AAC7C,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC;AAEtC,MAAM,OAAO,WAAW;IAIpB,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;QACI,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,cAAc,IAAI,IAAI,IAAI,SAAS,CAAC,cAAc,GAAG,CAAC,CAAC;QAEpE,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE;YACrC,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAElE,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAChC;IACL,CAAC;IAED,gBAAgB;QACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACrD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;IACL,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["const IS_TOUCH = 'is-touch';\nconst WITH_MOUSE = `${IS_TOUCH}--with-mouse`;\nconst html = document.documentElement;\n\nexport class DetectTouch {\n touch: boolean;\n hasMouse: boolean;\n\n get isTouchDevice() {\n return this.touch;\n }\n\n constructor() {\n this.hasMouse = false;\n this.touch = 'ontouchstart' in html || navigator.maxTouchPoints > 0;\n\n html.addEventListener('touchstart', () => {\n html.removeEventListener('mousemove', () => this.handleMouseEvent());\n });\n\n html.addEventListener('mousemove', () => this.handleMouseEvent());\n\n if (this.touch) {\n html.classList.add(IS_TOUCH);\n }\n }\n\n handleMouseEvent() {\n if (!this.hasMouse && html.classList.contains(IS_TOUCH)) {\n html.classList.add(WITH_MOUSE);\n this.hasMouse = true;\n }\n }\n}\n\nexport const detectTouch = new DetectTouch();\n"]}
@@ -1,10 +1,10 @@
1
1
  import { breakpoints } from './breakpoints';
2
- export declare type Breakpoints = keyof typeof breakpoints;
3
- export declare type BreakpointFunction = (breakpoint: Breakpoints) => string;
4
- export declare type UseMediaFunction = (breakpoints: {
2
+ export type Breakpoints = keyof typeof breakpoints;
3
+ export type BreakpointFunction = (breakpoint: Breakpoints) => string;
4
+ export type UseMediaFunction = (breakpoints: {
5
5
  [key in Breakpoints]: Breakpoint;
6
6
  }) => void;
7
- export declare type MediaQuery = {
7
+ export type MediaQuery = {
8
8
  breakpoint: Breakpoints;
9
9
  query: () => string;
10
10
  };
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=media-query.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-local-storage-store.js","sourceRoot":"","sources":["../../../src/store/generators/create-local-storage-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAA8C,EACjF,GAAG,EACH,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,GAC+B,EAAE,EAAE;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAgB;QACrC,YAAY;QACZ,OAAO;KACV,CAAC,CAAC;IAEH,SAAS,WAAW,CAAC,IAAW;QAC5B,OAAO,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,GAAG;QACR,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAmC,CAAC;QACxE,IAAI,WAAW,CAAC,MAAM,IAAI,IAAI,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE;YACvD,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO;SACV;QAED,OAAO,WAAW,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,SAAS,GAAG,CAAC,KAAY;QACrB,IAAI;YACA,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC;gBACnC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;gBAC1D,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;aAC/E,CAAC,CAAC;YAEH,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SAC9C;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;SACvD;IACL,CAAC;IAED,SAAS,qBAAqB,CAAC,KAAY;QACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAgB,CAAC;QAC/C,MAAM,aAAa,GAAU,EAAW,CAAC;QAEzC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,CAAC,GAAG,EAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAErC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC;IAEnB,IAAI,IAAI;QAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAE5B,uBAAS,GAAG,EAAE,GAAG,IAAK,KAAK,EAAG;AAClC,CAAC,CAAC","sourcesContent":["import { BrowserStorageStoreItem, BrowserStorageStoreSettings, Keys } from '../store.types';\nimport { createStore } from './create-store';\n\nexport const createLocalStorageStore = <State extends object, Action extends string>({\n key,\n actions,\n initialState,\n expireInDays,\n excludeProps,\n initAction,\n}: BrowserStorageStoreSettings<State, Action>) => {\n const store = createStore<State, Action>({\n initialState,\n actions,\n });\n\n function updateStore(data: State) {\n return store.dispatch(initAction, data);\n }\n\n function get(): State | undefined {\n const state = localStorage.getItem(key);\n if (!state) return;\n\n const parsedState = JSON.parse(state) as BrowserStorageStoreItem<State>;\n if (parsedState.expire && new Date() > parsedState.expire) {\n localStorage.removeItem(key);\n return;\n }\n\n return parsedState.value;\n }\n\n function set(state: State) {\n try {\n const now = new Date();\n const serializedState = JSON.stringify({\n value: excludeProps ? excludePropsFromState(state) : state,\n expire: expireInDays ? now.setDate(now.getDate() + expireInDays) : undefined,\n });\n\n localStorage.setItem(key, serializedState);\n } catch (error) {\n console.log('Error in localStorage.setItem', error);\n }\n }\n\n function excludePropsFromState(state: State) {\n const keys = Object.keys(state) as Keys<State>;\n const filteredState: State = {} as State;\n\n keys.filter((key) => !excludeProps?.includes(key)).forEach((key) => {\n const value = state[key];\n filteredState[key] = value;\n });\n\n return filteredState;\n }\n\n store.subscribe((data) => set(data));\n\n const data = get();\n\n if (data) updateStore(data);\n\n return { get, set, ...store };\n};\n"]}
1
+ {"version":3,"file":"create-local-storage-store.js","sourceRoot":"","sources":["../../../src/store/generators/create-local-storage-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAA8C,EACjF,GAAG,EACH,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,GAC+B,EAAE,EAAE;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAgB;QACrC,YAAY;QACZ,OAAO;KACV,CAAC,CAAC;IAEH,SAAS,WAAW,CAAC,IAAW;QAC5B,OAAO,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,GAAG;QAC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AAG,EAAE,EAAE;YAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAErC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC;IAEnB,IAAI,IAAI;QAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAE5B,uBAAS,GAAG,EAAE,GAAG,IAAK,KAAK,EAAG;AAClC,CAAC,CAAC","sourcesContent":["import { BrowserStorageStoreItem, BrowserStorageStoreSettings, Keys } from '../store.types';\nimport { createStore } from './create-store';\n\nexport const createLocalStorageStore = <State extends object, Action extends string>({\n key,\n actions,\n initialState,\n expireInDays,\n excludeProps,\n initAction,\n}: BrowserStorageStoreSettings<State, Action>) => {\n const store = createStore<State, Action>({\n initialState,\n actions,\n });\n\n function updateStore(data: State) {\n return store.dispatch(initAction, data);\n }\n\n function get(): State | undefined {\n const state = localStorage.getItem(key);\n if (!state) return;\n\n const parsedState = JSON.parse(state) as BrowserStorageStoreItem<State>;\n if (parsedState.expire && new Date() > parsedState.expire) {\n localStorage.removeItem(key);\n return;\n }\n\n return parsedState.value;\n }\n\n function set(state: State) {\n try {\n const now = new Date();\n const serializedState = JSON.stringify({\n value: excludeProps ? excludePropsFromState(state) : state,\n expire: expireInDays ? now.setDate(now.getDate() + expireInDays) : undefined,\n });\n\n localStorage.setItem(key, serializedState);\n } catch (error) {\n console.log('Error in localStorage.setItem', error);\n }\n }\n\n function excludePropsFromState(state: State) {\n const keys = Object.keys(state) as Keys<State>;\n const filteredState: State = {} as State;\n\n keys.filter((key) => !excludeProps?.includes(key)).forEach((key) => {\n const value = state[key];\n filteredState[key] = value;\n });\n\n return filteredState;\n }\n\n store.subscribe((data) => set(data));\n\n const data = get();\n\n if (data) updateStore(data);\n\n return { get, set, ...store };\n};\n"]}
@@ -1,3 +1,3 @@
1
- declare type ProxyContainer = <T extends object = object, K extends object = object>(services: T, handler: K) => T;
1
+ type ProxyContainer = <T extends object = object, K extends object = object>(services: T, handler: K) => T;
2
2
  export declare const proxyContainer: ProxyContainer;
3
3
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAW5C,MAAM,UAAU,WAAW,CACvB,QAAuC;IAEvC,MAAM,SAAS,GAAqB,EAAE,CAAC;IAEvC,IAAI,SAAS,GAAU,QAAQ,CAAC,YAAY,CAAC;IAE7C,MAAM,SAAS,GAAG;QACd,GAAG,CAAC,KAAY,EAAE,GAAgB,EAAE,KAAU;YAC1C,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE;gBACpC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACnB,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;aAC7B;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ,CAAC;IAEF,IAAI,KAAK,GAAG,cAAc,CAAQ,QAAQ,CAAC,YAAY,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;IAE1E,SAAS,SAAS,CAAC,QAAiC,EAAE,IAAkB;QACpE,IAAI,OAAO,QAAQ,KAAK,UAAU;YAC9B,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAChF,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,SAAS,WAAW,CAAC,QAAiC;QAClD,IAAI,OAAO,QAAQ,KAAK,UAAU;YAC9B,IAAI,KAAK,CAAC,gEAAgE,CAAC,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QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,GAAG;QACR,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,SAAS,GAAG,CAAC,KAAY;QACrB,IAAI;YACA,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAE9C,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SAChD;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;SACzD;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAErC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC;IACnB,IAAI,IAAI;QAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAE5B,uBAAS,GAAG,EAAE,GAAG,IAAK,KAAK,EAAG;AAClC,CAAC,CAAC","sourcesContent":["import { proxyContainer } from './polyfill';\nimport {\n BrowserStorageStoreItem,\n BrowserStorageStoreSettings,\n Keys,\n ObserverCallback,\n Observers,\n Store,\n StoreSettings,\n} from './store.types';\n\nexport function createStore<State extends object, Actions extends string>(\n settings: StoreSettings<State, Actions>,\n): Store<State, Actions> {\n const observers: Observers<State> = [];\n\n let prevState: State = settings.initialState;\n\n const validator = {\n set(state: State, key: keyof State, value: any) {\n if (valueHasChanged(state[key], value)) {\n state[key] = value;\n callObservers(state, key);\n }\n\n return true;\n },\n };\n\n let state = proxyContainer<State>(settings.initialState || {}, validator);\n\n function subscribe(observer: ObserverCallback<State>, keys?: Keys<State>) {\n if (typeof observer !== 'function')\n new Error('You can only subscribe to Store changes with a valid function!');\n observers.push({ callback: observer, keys });\n return true;\n }\n\n function unsubscribe(observer: ObserverCallback<State>) {\n if (typeof observer !== 'function')\n new Error('You can only subscribe to Store changes with a valid function!');\n\n const match = observers.find(({ callback }) => callback === observer);\n if (match) {\n observers.splice(observers.indexOf(match), 1);\n }\n }\n\n async function dispatch(actionKey: Actions, payload: any) {\n if (!settings.actions || typeof settings.actions[actionKey] !== 'function')\n new Error(`Action \"${actionKey}\" doesn't exist.`);\n\n const action = settings.actions![actionKey];\n prevState = Object.assign({}, state);\n const newState = await action(state, payload);\n state = newState;\n\n return state;\n }\n\n function callObservers(data: State, key: any) {\n observers.forEach(({ keys, callback }) => {\n if (!keys) {\n callback(data);\n } else if (Array.isArray(keys) && keys.indexOf(key) > -1) {\n callback(data);\n }\n });\n }\n\n return {\n subscribe,\n unsubscribe,\n dispatch,\n getState: () => state,\n getPrevState: () => prevState,\n };\n}\n\nfunction valueHasChanged(value: unknown, old: unknown): boolean {\n // This ensures (old==NaN, value==NaN) always returns false\n return old !== value && (old === old || value === value);\n}\n\nexport const createLocalStorageStore = <State extends object, Action extends string>({\n key,\n actions,\n initialState,\n expireInDays,\n excludeProps,\n initAction,\n}: BrowserStorageStoreSettings<State, Action>) => {\n const store = createStore<State, Action>({\n initialState,\n actions,\n });\n\n function updateStore(data: State) {\n return store.dispatch(initAction, data);\n }\n\n function get(): State | undefined {\n const state = localStorage.getItem(key);\n if (!state) return;\n\n const parsedState = JSON.parse(state) as BrowserStorageStoreItem<State>;\n if (parsedState.expire && new Date() > parsedState.expire) {\n localStorage.removeItem(key);\n return;\n }\n\n return parsedState.value;\n }\n\n function set(state: State) {\n try {\n const now = new Date();\n const serializedState = JSON.stringify({\n value: excludeProps ? excludePropsFromState(state) : state,\n expire: expireInDays ? now.setDate(now.getDate() + expireInDays) : undefined,\n });\n\n localStorage.setItem(key, serializedState);\n } catch (error) {\n console.log('Error in localStorage.setItem', error);\n }\n }\n\n function excludePropsFromState(state: State) {\n const keys = Object.keys(state) as Keys<State>;\n const filteredState: State = {} as State;\n\n keys.filter((key) => !excludeProps?.includes(key)).forEach((key) => {\n const value = state[key];\n filteredState[key] = value;\n });\n\n return filteredState;\n }\n\n store.subscribe((data) => set(data));\n\n const data = get();\n\n if (data) updateStore(data);\n\n return { get, set, ...store };\n};\n\nexport const createSessionStorageStore = <State extends object, Action extends string>({\n key,\n initialState,\n actions,\n initAction,\n}: BrowserStorageStoreSettings<State, Action>) => {\n const store = createStore<State, Action>({\n initialState,\n actions,\n });\n\n function updateStore(data: State) {\n return store.dispatch(initAction, data);\n }\n\n function get(): State | undefined {\n const value = sessionStorage.getItem(key);\n if (!value) return;\n\n return JSON.parse(value);\n }\n\n function set(value: State) {\n try {\n const serializedState = JSON.stringify(value);\n\n sessionStorage.setItem(key, serializedState);\n } catch (error) {\n console.log('Error in sessionStorage.setItem', error);\n }\n }\n\n store.subscribe((data) => set(data));\n\n const data = get();\n if (data) updateStore(data);\n\n return { get, set, ...store };\n};\n"]}
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAW5C,MAAM,UAAU,WAAW,CACvB,QAAuC;IAEvC,MAAM,SAAS,GAAqB,EAAE,CAAC;IAEvC,IAAI,SAAS,GAAU,QAAQ,CAAC,YAAY,CAAC;IAE7C,MAAM,SAAS,GAAG;QACd,GAAG,CAAC,KAAY,EAAE,GAAgB,EAAE,KAAU;YAC1C,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE;gBACpC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACnB,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;aAC7B;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ,CAAC;IAEF,IAAI,KAAK,GAAG,cAAc,CAAQ,QAAQ,CAAC,YAAY,IAAI,EAAE,E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rowserStorageStoreSettings,\n Keys,\n ObserverCallback,\n Observers,\n Store,\n StoreSettings,\n} from './store.types';\n\nexport function createStore<State extends object, Actions extends string>(\n settings: StoreSettings<State, Actions>,\n): Store<State, Actions> {\n const observers: Observers<State> = [];\n\n let prevState: State = settings.initialState;\n\n const validator = {\n set(state: State, key: keyof State, value: any) {\n if (valueHasChanged(state[key], value)) {\n state[key] = value;\n callObservers(state, key);\n }\n\n return true;\n },\n };\n\n let state = proxyContainer<State>(settings.initialState || {}, validator);\n\n function subscribe(observer: ObserverCallback<State>, keys?: Keys<State>) {\n if (typeof observer !== 'function')\n new Error('You can only subscribe to Store changes with a valid function!');\n observers.push({ callback: observer, keys });\n return true;\n }\n\n function unsubscribe(observer: ObserverCallback<State>) {\n if (typeof observer !== 'function')\n new Error('You can only subscribe to Store changes with a valid function!');\n\n const match = observers.find(({ callback }) => callback === observer);\n if (match) {\n observers.splice(observers.indexOf(match), 1);\n }\n }\n\n async function dispatch(actionKey: Actions, payload: any) {\n if (!settings.actions || typeof settings.actions[actionKey] !== 'function')\n new Error(`Action \"${actionKey}\" doesn't exist.`);\n\n const action = settings.actions![actionKey];\n prevState = Object.assign({}, state);\n const newState = await action(state, payload);\n state = newState;\n\n return state;\n }\n\n function callObservers(data: State, key: any) {\n observers.forEach(({ keys, callback }) => {\n if (!keys) {\n callback(data);\n } else if (Array.isArray(keys) && keys.indexOf(key) > -1) {\n callback(data);\n }\n });\n }\n\n return {\n subscribe,\n unsubscribe,\n dispatch,\n getState: () => state,\n getPrevState: () => prevState,\n };\n}\n\nfunction valueHasChanged(value: unknown, old: unknown): boolean {\n // This ensures (old==NaN, value==NaN) always returns false\n return old !== value && (old === old || value === value);\n}\n\nexport const createLocalStorageStore = <State extends object, Action extends string>({\n key,\n actions,\n initialState,\n expireInDays,\n excludeProps,\n initAction,\n}: BrowserStorageStoreSettings<State, Action>) => {\n const store = createStore<State, Action>({\n initialState,\n actions,\n });\n\n function updateStore(data: State) {\n return store.dispatch(initAction, data);\n }\n\n function get(): State | undefined {\n const state = localStorage.getItem(key);\n if (!state) return;\n\n const parsedState = JSON.parse(state) as BrowserStorageStoreItem<State>;\n if (parsedState.expire && new Date() > parsedState.expire) {\n localStorage.removeItem(key);\n return;\n }\n\n return parsedState.value;\n }\n\n function set(state: State) {\n try {\n const now = new Date();\n const serializedState = JSON.stringify({\n value: excludeProps ? excludePropsFromState(state) : state,\n expire: expireInDays ? now.setDate(now.getDate() + expireInDays) : undefined,\n });\n\n localStorage.setItem(key, serializedState);\n } catch (error) {\n console.log('Error in localStorage.setItem', error);\n }\n }\n\n function excludePropsFromState(state: State) {\n const keys = Object.keys(state) as Keys<State>;\n const filteredState: State = {} as State;\n\n keys.filter((key) => !excludeProps?.includes(key)).forEach((key) => {\n const value = state[key];\n filteredState[key] = value;\n });\n\n return filteredState;\n }\n\n store.subscribe((data) => set(data));\n\n const data = get();\n\n if (data) updateStore(data);\n\n return { get, set, ...store };\n};\n\nexport const createSessionStorageStore = <State extends object, Action extends string>({\n key,\n initialState,\n actions,\n initAction,\n}: BrowserStorageStoreSettings<State, Action>) => {\n const store = createStore<State, Action>({\n initialState,\n actions,\n });\n\n function updateStore(data: State) {\n return store.dispatch(initAction, data);\n }\n\n function get(): State | undefined {\n const value = sessionStorage.getItem(key);\n if (!value) return;\n\n return JSON.parse(value);\n }\n\n function set(value: State) {\n try {\n const serializedState = JSON.stringify(value);\n\n sessionStorage.setItem(key, serializedState);\n } catch (error) {\n console.log('Error in sessionStorage.setItem', error);\n }\n }\n\n store.subscribe((data) => set(data));\n\n const data = get();\n if (data) updateStore(data);\n\n return { get, set, ...store };\n};\n"]}
@@ -1,11 +1,11 @@
1
- export declare type ObserverCallback<T> = (state: T) => void;
2
- export declare type Keys<T> = (keyof T)[];
3
- export declare type ActionHandler<T> = (state: T, payload: any) => T;
4
- export declare type Actions<A extends string, T> = Record<A, ActionHandler<T>>;
5
- export declare type Subscribe<T> = (observer: ObserverCallback<T>, keys?: Keys<T>) => void;
6
- export declare type Unsubscribe<T> = (observer: ObserverCallback<T>) => void;
7
- export declare type Dispatch<A extends string, T> = (actionKey: A, payload?: any) => T | Promise<T>;
8
- export declare type State<T> = () => T;
1
+ export type ObserverCallback<T> = (state: T) => void;
2
+ export type Keys<T> = (keyof T)[];
3
+ export type ActionHandler<T> = (state: T, payload: any) => T;
4
+ export type Actions<A extends string, T> = Record<A, ActionHandler<T>>;
5
+ export type Subscribe<T> = (observer: ObserverCallback<T>, keys?: Keys<T>) => void;
6
+ export type Unsubscribe<T> = (observer: ObserverCallback<T>) => void;
7
+ export type Dispatch<A extends string, T> = (actionKey: A, payload?: any) => T | Promise<T>;
8
+ export type State<T> = () => T;
9
9
  export interface Store<T, A extends string> {
10
10
  getState: State<T>;
11
11
  getPrevState: State<T>;
@@ -21,7 +21,7 @@ export interface Observer<T> {
21
21
  callback: ObserverCallback<T>;
22
22
  keys?: Keys<T>;
23
23
  }
24
- export declare type Observers<T> = Array<Observer<T>>;
24
+ export type Observers<T> = Array<Observer<T>>;
25
25
  export interface BrowserStorageStoreItem<T> {
26
26
  value: T;
27
27
  expire?: Date;
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=store.types.js.map
@@ -1,3 +1,3 @@
1
1
  export declare const round: (value: number, decimals: number) => string;
2
- export declare const putThousandsSeparators: (value: number | string, sep?: string | undefined) => string;
2
+ export declare const putThousandsSeparators: (value: number | string, sep?: string) => string;
3
3
  export declare const toCurrency: (value: number, decimals?: number) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpd-library/utilities",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "description": "Description",
5
5
  "url": "https://github.com/{repo name}",
6
6
  "license": "MIT",
@@ -12,18 +12,11 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "tsc --moduleResolution node --outDir dist --declarationDir dist --declaration true",
15
- "regen-package-lock": "rm -rf node_modules package-lock.json; npm install",
16
15
  "generate-swagger": "oats-generator import --config config/oats-generator.config.js"
17
16
  },
18
17
  "author": {
19
18
  "name": "Dylan Vens"
20
19
  },
21
- "resolutions": {
22
- "@atomify/hooks": "1.1.11",
23
- "@atomify/jsx": "1.7.1",
24
- "@atomify/kit": "1.1.11",
25
- "@atomify/core": "2.4.1"
26
- },
27
20
  "devDependencies": {
28
21
  "@babel/cli": "^7.2.3",
29
22
  "@babel/plugin-proposal-class-properties": "^7.2.3",
@@ -39,19 +32,19 @@
39
32
  "rollup": "^2.38.0",
40
33
  "rollup-plugin-node-externals": "^2.2.0",
41
34
  "ts-node": "^9.1.1",
42
- "typescript": "^3.7.5",
35
+ "typescript": "~4.9.5",
43
36
  "uglify-es": "^3.3.9"
44
37
  },
45
38
  "publishConfig": {
46
39
  "access": "public"
47
40
  },
48
- "gitHead": "4d436105ae635cd3f5812f69a18b4d49e6106026",
41
+ "gitHead": "449913ec355fbcefd390c499aec34f0577ef53d9",
49
42
  "dependencies": {
50
43
  "@atomify/core": "2.4.1",
51
44
  "@atomify/hooks": "1.1.11",
52
45
  "@atomify/jsx": "1.7.1",
53
46
  "@atomify/kit": "1.1.11",
54
- "@bpd-library/types": "^2.0.11",
47
+ "@bpd-library/types": "^2.0.12",
55
48
  "qs": "^6.9.4",
56
49
  "query-string": "5"
57
50
  }