@v-office/website-sdk 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { A as toUnusedFilterKeys, C as parseChildrenAges, D as parseQueryParameters, E as collectQueryParameters, L as parseVofficeUnitData, O as expandCustomAttributeFilterCompositions, T as toQueryString, an as toStableSearchInputParameterValues, in as toStableSearchInputBackendQueryKeys, j as stable_filters_default, k as toCustomAttributeFilterLabel, nn as STABLE_SEARCH_INPUTS, on as toStableSearchInputQueryKeys, w as parseOccupancyCount } from "./client-BFtPZZZh.mjs";
1
+ import { $t as toStableSearchInputParameterValues, A as toUnusedFilterKeys, C as parseChildrenAges, D as parseQueryParameters, E as collectQueryParameters, L as parseVofficeUnitData, O as expandCustomAttributeFilterCompositions, Qt as toStableSearchInputBackendQueryKeys, T as toQueryString, Xt as STABLE_SEARCH_INPUTS, en as toStableSearchInputQueryKeys, j as stable_filters_default, k as toCustomAttributeFilterLabel, w as parseOccupancyCount } from "./client-DYP0Y59i.mjs";
2
2
  import { t as CMSError } from "./errors-2cuUGSvi.mjs";
3
- import { d as daysBetweenLocalDates, l as toIsoDateFromPeriodQueryDate } from "./parser-D6UAf8Ld.mjs";
4
- import { n as toAddress, t as toRentalHighlights } from "./to-rental-highlights-CkHgZINu.mjs";
3
+ import { C as daysBetweenLocalDates, _ as toFormattedSearchPrice, x as toIsoDateFromPeriodQueryDate } from "./quote-CRjV_lf-.mjs";
4
+ import { n as toAddress, t as toRentalHighlights } from "./to-rental-highlights-BShYK50C.mjs";
5
5
  import { Effect } from "effect";
6
6
  //#region src/adapters/v9/parser/search/input/filter/apply-voffice-filter-derived-basic-query-inputs.ts
7
7
  const hasBasicQueryInput = ({ basicQueryInputs, key }) => basicQueryInputs.some((input) => input.key === key);
@@ -67,6 +67,10 @@ const toCustomBackendFilterInput = ({ queryKey, value, filter }) => {
67
67
  value: numberValue
68
68
  } : void 0;
69
69
  }
70
+ case "string": return value.length > 0 ? {
71
+ key: queryKey,
72
+ value
73
+ } : void 0;
70
74
  case "option": return filter.options.some((option) => option.value === value) ? {
71
75
  key: queryKey,
72
76
  value
@@ -311,15 +315,29 @@ const toQueryInput = ({ query, customAttributeFilterDefinitions, locale, transla
311
315
  return {
312
316
  appliedFilters: [...compositionResult.appliedFilters, ...appliedFilters],
313
317
  queryInput: {
314
- vofficeData: Object.keys(filter).length > 0 ? { filter } : void 0,
318
+ vofficeData: {
319
+ filter: Object.keys(filter).length > 0 ? filter : void 0,
320
+ alternatives: true
321
+ },
315
322
  basicQueryInputs
316
323
  },
317
324
  unusedFilterKeys: toUnusedFilterKeys(basicQueryResult.remainingQuery)
318
325
  };
319
326
  });
320
327
  //#endregion
328
+ //#region src/adapters/v9/parser/search/output/to-formatted-price.ts
329
+ const DEFAULT_V9_SEARCH_CURRENCY = "EUR";
330
+ const toFormattedPrice = ({ locale, calc }) => {
331
+ if (calc?.total == null) return Effect.succeed(null);
332
+ return Effect.succeed(toFormattedSearchPrice({
333
+ amount: calc.total,
334
+ currency: DEFAULT_V9_SEARCH_CURRENCY,
335
+ locale
336
+ }));
337
+ };
338
+ //#endregion
321
339
  //#region src/adapters/v9/parser/search/to-search-output-item.ts
322
- const toSearchOutputItem = ({ locale, rentalHighlightPrioritization, customAttributeFilterDefinitions, rental, translations }) => Effect.gen(function* () {
340
+ const toSearchOutputItem = ({ locale, rentalHighlightPrioritization, customAttributeFilterDefinitions, rental, translations, includeFormattedTotal }) => Effect.gen(function* () {
323
341
  const data = parseVofficeUnitData(rental.data);
324
342
  const item = {
325
343
  id: rental.voffice_id.toString(),
@@ -336,6 +354,11 @@ const toSearchOutputItem = ({ locale, rentalHighlightPrioritization, customAttri
336
354
  attributes: data
337
355
  });
338
356
  if (highlights != null) item.highlights = highlights;
357
+ const formattedPrice = yield* toFormattedPrice({
358
+ locale,
359
+ calc: rental.additional_voffice_data?.calc
360
+ });
361
+ if (includeFormattedTotal && formattedPrice != null) item.formattedTotal = formattedPrice;
339
362
  return item;
340
363
  });
341
364
  //#endregion
@@ -1,7 +1,7 @@
1
- import { P as VofficeUnitDataPropertyMetadata } from "./client-BFtPZZZh.mjs";
1
+ import { P as VofficeUnitDataPropertyMetadata } from "./client-DYP0Y59i.mjs";
2
2
  import "./errors-2cuUGSvi.mjs";
3
- import { c as localeToLanguage, o as toCountry, s as makeTranslate } from "./parser-D6UAf8Ld.mjs";
4
- import { i as renderLabeledAttributeValue, t as renderCustomAttributeHighlight } from "./custom-attribute-ChCbJKf_.mjs";
3
+ import { b as localeToLanguage, v as toCountry, y as makeTranslate } from "./quote-CRjV_lf-.mjs";
4
+ import { i as renderLabeledAttributeValue, t as renderCustomAttributeHighlight } from "./custom-attribute-D5Kb1YHA.mjs";
5
5
  import { Effect } from "effect";
6
6
  //#region src/adapters/v9/parser/rentals/to-localized-string.ts
7
7
  const isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v-office/website-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "SDK for the connection to PMS from the website",
5
5
  "bin": {
6
6
  "website-sdk": "./dist/cli.mjs"
@@ -19,26 +19,24 @@
19
19
  "#services": "./src/services/index.ts",
20
20
  "#shared-parsers": "./src/adapters/shared/parser/index.ts",
21
21
  "#v10-codegen-types": "./scripts/v10/graphql-codegen/types.ts",
22
- "#v10-metadata-search-filter": "./scripts/v10/metadata-generation/search-filter-metadata.ts",
23
- "#v10-metadata-search-filter-category-keys": "./scripts/v10/metadata-generation/search-filter-category-keys.ts",
24
- "#v10-metadata-rental": "./scripts/v10/metadata-generation/rental-metadata.ts",
25
- "#v10-metadata-property": "./scripts/v10/metadata-generation/property-metadata.ts",
26
- "#v10-generated": "./scripts/v10/graphql-codegen/generated/index.ts",
27
22
  "#v10-generated-graphql": "./scripts/v10/graphql-codegen/generated/graphql.ts",
28
23
  "#v10-operations": "./scripts/v10/graphql-codegen/operations/index.ts",
24
+ "#v10-metadata-rental": "./scripts/v10/metadata-generation/rental-metadata.ts",
25
+ "#v10-metadata-property": "./scripts/v10/metadata-generation/property-metadata.ts",
26
+ "#v10-metadata-search-filter": "./scripts/v10/metadata-generation/search-filter-metadata.ts",
27
+ "#v10-metadata-search-filter-category-keys": "./scripts/v10/metadata-generation/search-filter-category-keys.ts",
29
28
  "#v9-data": "./scripts/v9/heuristic-generation/v9-data.ts",
30
29
  "#v9-data-public": "./scripts/v9/heuristic-generation/public-api.ts",
30
+ "#v9-stable-filters": "./scripts/v9/graphql-codegen/stable-filters.json",
31
+ "#v9-search-filter-key-map": "./scripts/v9/graphql-codegen/search-filter-key-map.ts",
32
+ "#v9-operations": "./scripts/v9/graphql-codegen/operations/index.ts",
33
+ "#v9-generated-graphql": "./scripts/v9/graphql-codegen/generated/graphql.ts",
31
34
  "#v9-v0-data": "./scripts/v9/v0/generated/v0-data.ts",
32
35
  "#v9-v0-openapi-types": "./scripts/v9/v0/generated/openapi-types.ts",
33
36
  "#v9-v0-public": "./scripts/v9/v0/public-api.ts",
34
37
  "#v9-v1-data": "./scripts/v9/v1/generated/v1-data.ts",
35
38
  "#v9-v1-openapi-types": "./scripts/v9/v1/generated/openapi-types.ts",
36
- "#v9-v1-public": "./scripts/v9/v1/public-api.ts",
37
- "#v9-generated": "./scripts/v9/graphql-codegen/generated/index.ts",
38
- "#v9-generated-graphql": "./scripts/v9/graphql-codegen/generated/graphql.ts",
39
- "#v9-operations": "./scripts/v9/graphql-codegen/operations/index.ts",
40
- "#v9-stable-filters": "./scripts/v9/graphql-codegen/stable-filters.json",
41
- "#v9-search-filter-key-map": "./scripts/v9/graphql-codegen/search-filter-key-map.ts"
39
+ "#v9-v1-public": "./scripts/v9/v1/public-api.ts"
42
40
  },
43
41
  "exports": {
44
42
  ".": "./dist/index.mjs",
@@ -49,23 +47,26 @@
49
47
  "access": "public"
50
48
  },
51
49
  "dependencies": {
52
- "effect": "4.0.0-beta.74",
53
- "graphql": "16.14.0",
50
+ "effect": "4.0.0-beta.78",
51
+ "graphql": "16.14.1",
54
52
  "yaml": "2.9.0"
55
53
  },
56
54
  "devDependencies": {
57
55
  "@effect/language-service": "0.86.2",
58
- "@graphql-codegen/cli": "7.1.1",
56
+ "@graphql-codegen/cli": "7.1.2",
59
57
  "@graphql-codegen/client-preset": "6.0.1",
60
58
  "@graphql-typed-document-node/core": "3.2.0",
61
59
  "@types/node": "25.9.1",
62
- "@typescript/native-preview": "7.0.0-dev.20260527.2",
60
+ "@typescript/native-preview": "7.0.0-dev.20260604.1",
63
61
  "openapi-typescript": "7.13.0",
64
- "oxfmt": "0.52.0",
65
- "oxlint": "1.67.0",
66
- "tsdown": "0.22.1",
62
+ "oxfmt": "0.53.0",
63
+ "oxlint": "1.68.0",
64
+ "tsdown": "0.22.2",
67
65
  "typescript": "6.0.3",
68
- "vitest": "4.1.7"
66
+ "vitest": "4.1.8"
67
+ },
68
+ "inlinedDependencies": {
69
+ "@graphql-typed-document-node/core": "3.2.0"
69
70
  },
70
71
  "scripts": {
71
72
  "p": "pnpm run build && node --env-file=.env playground.ts",
@@ -1,65 +0,0 @@
1
- import { DateTime, Duration, Option } from "effect";
2
- //#region src/adapters/shared/parser/local-date.ts
3
- const ISO_LOCAL_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
4
- const isLocalDateString = (value) => {
5
- if (!ISO_LOCAL_DATE_PATTERN.test(value)) return false;
6
- const date = DateTime.make(value);
7
- return Option.isSome(date) && DateTime.formatIsoDateUtc(date.value) === value;
8
- };
9
- const daysBetweenLocalDates = ({ start, end }) => {
10
- const startDate = DateTime.removeTime(DateTime.makeUnsafe(start));
11
- const endDate = DateTime.removeTime(DateTime.makeUnsafe(end));
12
- const duration = DateTime.toEpochMillis(endDate) - DateTime.toEpochMillis(startDate);
13
- return Math.trunc(Duration.toDays(Duration.millis(duration)));
14
- };
15
- //#endregion
16
- //#region src/adapters/shared/parser/period-query-date.ts
17
- const PREFERRED_QUERY_DATE_PATTERN = /^(\d{2})-(\d{2})-(\d{4})$/;
18
- const ISO_QUERY_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
19
- const QUERY_MONTH_PATTERN = /^(\d{2})-(\d{4})$/;
20
- const toIsoDateFromPeriodQueryDate = (value) => {
21
- const preferredMatch = PREFERRED_QUERY_DATE_PATTERN.exec(value);
22
- const isoDate = preferredMatch == null ? ISO_QUERY_DATE_PATTERN.test(value) ? value : void 0 : `${preferredMatch[3]}-${preferredMatch[2]}-${preferredMatch[1]}`;
23
- if (isoDate === void 0) return;
24
- return isLocalDateString(isoDate) ? isoDate : void 0;
25
- };
26
- const toYearMonthFromPeriodQueryMonth = (value) => {
27
- const match = QUERY_MONTH_PATTERN.exec(value);
28
- if (!match) return;
29
- const [, month, year] = match;
30
- const monthNumber = Number.parseInt(month, 10);
31
- return monthNumber >= 1 && monthNumber <= 12 ? {
32
- year: Number.parseInt(year, 10),
33
- month: monthNumber
34
- } : void 0;
35
- };
36
- //#endregion
37
- //#region src/adapters/shared/parser/locale.ts
38
- const localeToLanguage = (locale) => locale.split("-")[0] ?? locale;
39
- //#endregion
40
- //#region src/adapters/shared/parser/translation.ts
41
- const makeTranslate = (translations, locale) => (key, fallback) => translations.translate(locale, key, fallback);
42
- //#endregion
43
- //#region src/adapters/shared/parser/to-country.ts
44
- const toCountry = (country, locale) => {
45
- const normalizedCountryCode = country.trim().toUpperCase();
46
- if (!/^[A-Z]{2}$/.test(normalizedCountryCode)) return country;
47
- return new Intl.DisplayNames([locale], { type: "region" }).of(normalizedCountryCode) ?? country;
48
- };
49
- //#endregion
50
- //#region src/adapters/shared/parser/to-night-count.ts
51
- const toNightCount = (input) => {
52
- const nights = daysBetweenLocalDates({
53
- start: input.period.start,
54
- end: input.period.end
55
- });
56
- return Math.max(1, nights);
57
- };
58
- //#endregion
59
- //#region src/adapters/shared/parser/unknown.ts
60
- const asRecord = (value) => typeof value === "object" && value !== null ? value : {};
61
- const asArray = (value) => Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
62
- const firstString = (...values) => values.find((value) => typeof value === "string" && value.length > 0);
63
- const firstNumber = (...values) => values.find((value) => typeof value === "number" && Number.isFinite(value));
64
- //#endregion
65
- export { toNightCount as a, localeToLanguage as c, daysBetweenLocalDates as d, firstString as i, toIsoDateFromPeriodQueryDate as l, asRecord as n, toCountry as o, firstNumber as r, makeTranslate as s, asArray as t, toYearMonthFromPeriodQueryMonth as u };