@v-office/website-sdk 2.28.1 → 2.29.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.
Files changed (36) hide show
  1. package/README.md +8 -0
  2. package/dist/cli.mjs +420 -12
  3. package/dist/{client-EtS0Qm3i.mjs → client-B8cF8Ra1.mjs} +285 -45
  4. package/dist/index.d.mts +36 -4
  5. package/dist/index.mjs +1 -1
  6. package/dist/instructions/CHANGELOG.md +1 -0
  7. package/dist/instructions/MIGRATION.md +1 -0
  8. package/dist/instructions/README.md +3 -2
  9. package/dist/instructions/creation.md +35 -4
  10. package/dist/instructions/custom-attributes.md +2 -2
  11. package/dist/instructions/filter.md +5 -3
  12. package/dist/instructions/quote.md +1 -1
  13. package/dist/instructions/rentals.md +36 -0
  14. package/dist/instructions/search.md +214 -6
  15. package/dist/instructions/versions/2.29.0/CHANGELOG.md +62 -0
  16. package/dist/instructions/versions/2.29.0/MIGRATION.md +97 -0
  17. package/dist/{v9-data-C3SWtDGs.mjs → operations-CfjJjdrw.mjs} +3122 -1
  18. package/dist/{rentals-B4g91vwW.mjs → rentals-DvYUm25t.mjs} +4 -5
  19. package/dist/{search-B-lvOmXL.mjs → search-BkrzAC9w.mjs} +6 -5
  20. package/dist/{to-rental-highlights-BL5m3Uen.mjs → to-rental-highlights-D7oepO6s.mjs} +1 -1
  21. package/dist/translations/v9/de-DE/core.json +8 -1
  22. package/dist/translations/v9/en-US/core.json +8 -1
  23. package/instructions/CHANGELOG.md +1 -0
  24. package/instructions/MIGRATION.md +1 -0
  25. package/instructions/README.md +3 -2
  26. package/instructions/creation.md +35 -4
  27. package/instructions/custom-attributes.md +2 -2
  28. package/instructions/filter.md +5 -3
  29. package/instructions/quote.md +1 -1
  30. package/instructions/rentals.md +36 -0
  31. package/instructions/search.md +214 -6
  32. package/instructions/versions/2.29.0/CHANGELOG.md +62 -0
  33. package/instructions/versions/2.29.0/MIGRATION.md +97 -0
  34. package/instructions/versions/2.29.0/release.json +3 -0
  35. package/package.json +5 -3
  36. package/dist/operations-DwURbo0b.mjs +0 -2850
package/README.md CHANGED
@@ -91,6 +91,9 @@ sdk.static.filter.getFilters(input);
91
91
  sdk.static.documents.getTermsAndPrivacyPolicy(input);
92
92
 
93
93
  sdk.live.search.search(input);
94
+ // v9 only:
95
+ sdk.live.rentals.getRentalsByIds(input);
96
+ sdk.live.voucher.validate(input);
94
97
  sdk.live.availability.getInitialAvailability(input);
95
98
  sdk.live.availability.getStartDateSelectedAvailability(input);
96
99
  sdk.live.quote.quote(input);
@@ -122,6 +125,9 @@ Quote mutation helpers are available under `sdk.live.quote`:
122
125
  website-sdk --backend v10 rentals --locale de-DE
123
126
  website-sdk --backend v9 filters --locale en-US
124
127
  website-sdk --backend v10 search --locale de-DE --query "adults=2"
128
+ website-sdk --backend v9 rentals-by-ids --locale de-DE --rental-ids 12,34
129
+ website-sdk --backend v9 voucher validate --code SUMMER26
130
+ website-sdk --backend v9 hub-filters request --object-group
125
131
  ```
126
132
 
127
133
  The CLI can read config from environment variables or from JSON files:
@@ -144,6 +150,8 @@ For v9, environment configuration uses:
144
150
  - `HUB_API_KEY`
145
151
  - `IMAGE_PROXY_BASE_URL`
146
152
  - `HUB_V0_API_BASE_URL` optional
153
+ - `HUB_RENTAL_SCOPE_PROPERTY_KIND` optional, `facility` or `objectGroup`
154
+ - `HUB_RENTAL_IDS_SEARCH` optional, `true` or `false`
147
155
 
148
156
  ## Migration From Legacy
149
157
 
package/dist/cli.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { Ht as defineWebsiteSDKOptions, Wt as defineV9PropertyHighlightSourcesFromUnknown, c as makeV9GraphQLClient, d as makeV0OpenApiClientFetchLive, l as V0OpenApiClient, t as createWebsiteSDK } from "./client-EtS0Qm3i.mjs";
3
- import { c as parseVofficeRatingData } from "./v9-data-C3SWtDGs.mjs";
4
- import { s as rentalsAllWithoutFeedbacksQuery } from "./operations-DwURbo0b.mjs";
2
+ import { $t as V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY, Jt as defineV9PropertyHighlightSourcesFromUnknown, Kt as defineWebsiteSDKOptions, Qt as V9_HUB_OBJECT_GROUP_FILTER_KEY, Xt as V9_HUB_FACILITY_SCOPE_FILTER_KEY, Zt as V9_HUB_FACILITY_SEARCH_FILTER_KEY, en as V9_HUB_OFFERS_FILTER_KEY, f as makeV9GraphQLClient, h as makeV0OpenApiClientFetchLive, i as toV9SdkOwnedHubFilterKeys, n as checkV9HubFilters, nn as V9_HUB_RENTAL_IDS_FILTER_KEY, p as V0OpenApiClient, r as toV9RequiredHubFilterKeys, rn as V9_SDK_OWNED_HUB_FILTER_KEYS, t as createWebsiteSDK, tn as V9_HUB_OFFER_FILTER_KEY } from "./client-B8cF8Ra1.mjs";
3
+ import { _ as parseVofficeRatingData, i as hubFiltersQuery, l as rentalsAllWithoutFeedbacksQuery } from "./operations-CfjJjdrw.mjs";
5
4
  import { SearchSearchSortSchema, defineCustomAttributesFromUnknown } from "@v-office/sdk-core";
6
5
  import { ByteSize, Console, Effect, FileSystem, Layer, Option, Path, Schema, Stdio, Terminal } from "effect";
7
6
  import { Command, Flag } from "effect/unstable/cli";
@@ -18,7 +17,7 @@ var CLICheckFailed = class extends Error {
18
17
  const toCLIError = (message, cause) => cause instanceof Error ? new CLICheckFailed(`${message}: ${cause.message}`, { cause }) : new CLICheckFailed(message, { cause });
19
18
  //#endregion
20
19
  //#region package.json
21
- var version = "2.28.1";
20
+ var version = "2.29.0";
22
21
  //#endregion
23
22
  //#region src/cli/output.ts
24
23
  const toJson = (value) => Effect.try({
@@ -71,7 +70,9 @@ const WebsiteV9CLIConfigSchema = Schema.Struct({
71
70
  v0ApiBaseUrl: Schema.optionalKey(NonBlankStringSchema),
72
71
  v1ApiBaseUrl: Schema.optionalKey(NonBlankStringSchema),
73
72
  rentalDataAttributes: Schema.optionalKey(Schema.Array(NonBlankStringSchema)),
74
- facilityObjectGroupRelationAttributeId: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0)))
73
+ facilityObjectGroupRelationAttributeId: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
74
+ rentalScopePropertyKind: Schema.optionalKey(Schema.Literals(["facility", "objectGroup"])),
75
+ rentalIdsSearch: Schema.optionalKey(Schema.Boolean)
75
76
  });
76
77
  const WebsiteV10CLIConfigSchema = Schema.Struct({
77
78
  backend: Schema.optionalKey(Schema.Literal("v10")),
@@ -83,6 +84,11 @@ const WebsiteV10CLIConfigSchema = Schema.Struct({
83
84
  const WebsiteSDKCLIConfigSchema = Schema.Union([WebsiteV9CLIConfigSchema, WebsiteV10CLIConfigSchema]);
84
85
  const decodeCLIConfig = (input, path) => Schema.decodeUnknownEffect(WebsiteSDKCLIConfigSchema)(input).pipe(Effect.mapError((cause) => toCLIError(`Invalid Website SDK config file at ${path}. Expected a complete v9 or v10 config`, cause)));
85
86
  const getRequiredEnv = (name) => Effect.sync(() => process.env[name]).pipe(Effect.flatMap((value) => value === void 0 || value.trim().length === 0 ? Effect.fail(new CLICheckFailed(`Missing required environment variable ${name}.`)) : Effect.succeed(value)));
87
+ const getOptionalEnvChoice = ({ name, choices }) => Effect.sync(() => process.env[name]?.trim()).pipe(Effect.flatMap((value) => {
88
+ if (value === void 0 || value.length === 0) return Effect.succeed(void 0);
89
+ const choice = choices.find((candidate) => candidate === value);
90
+ return choice === void 0 ? Effect.fail(new CLICheckFailed(`Environment variable ${name} must be one of ${choices.join(", ")}, got "${value}".`)) : Effect.succeed(choice);
91
+ }));
86
92
  /**
87
93
  * Registry-shaped options files hold authored inputs rather than trusted registry
88
94
  * snapshots. Build and validate both registries at this boundary.
@@ -118,6 +124,14 @@ const fromEnvironment = (root) => Effect.gen(function* () {
118
124
  const options = yield* readOptions(root, void 0);
119
125
  if (root.backend === "v9") {
120
126
  const v0ApiBaseUrl = process.env.HUB_V0_API_BASE_URL;
127
+ const rentalScopePropertyKind = yield* getOptionalEnvChoice({
128
+ name: "HUB_RENTAL_SCOPE_PROPERTY_KIND",
129
+ choices: ["facility", "objectGroup"]
130
+ });
131
+ const rentalIdsSearch = yield* getOptionalEnvChoice({
132
+ name: "HUB_RENTAL_IDS_SEARCH",
133
+ choices: ["true", "false"]
134
+ });
121
135
  return {
122
136
  config: {
123
137
  backend: "v9",
@@ -125,7 +139,9 @@ const fromEnvironment = (root) => Effect.gen(function* () {
125
139
  apiKey: yield* getRequiredEnv("HUB_API_KEY"),
126
140
  imageProxyBaseUrl: yield* getRequiredEnv("IMAGE_PROXY_BASE_URL"),
127
141
  v1ApiBaseUrl: yield* getRequiredEnv("HUB_V1_API_BASE_URL"),
128
- ...v0ApiBaseUrl === void 0 || v0ApiBaseUrl.length === 0 ? {} : { v0ApiBaseUrl }
142
+ ...v0ApiBaseUrl === void 0 || v0ApiBaseUrl.length === 0 ? {} : { v0ApiBaseUrl },
143
+ ...rentalScopePropertyKind === void 0 ? {} : { rentalScopePropertyKind },
144
+ ...rentalIdsSearch === void 0 ? {} : { rentalIdsSearch: rentalIdsSearch === "true" }
129
145
  },
130
146
  options
131
147
  };
@@ -222,7 +238,11 @@ const env = Command.make("env", {}, Effect.fn(function* () {
222
238
  "VOFFICE_LOCAL_DEV_ACCESS_TOKEN",
223
239
  "VOFFICE_IMAGE_BASE_URL"
224
240
  ],
225
- optional: root.backend === "v9" ? ["HUB_V0_API_BASE_URL"] : []
241
+ optional: root.backend === "v9" ? [
242
+ "HUB_V0_API_BASE_URL",
243
+ "HUB_RENTAL_SCOPE_PROPERTY_KIND",
244
+ "HUB_RENTAL_IDS_SEARCH"
245
+ ] : []
226
246
  });
227
247
  })).pipe(Command.withDescription("List environment variables used by the selected backend."));
228
248
  const configCommand = Command.make("config").pipe(Command.withDescription("Inspect CLI configuration."), Command.withSubcommands([show, env]));
@@ -272,10 +292,26 @@ const bookingBook = Command.make("book", {
272
292
  command: "website-sdk --backend v10 booking book --quote-input ./quote-input.json --contact-input ./booking-contact.json --relative-redirect-url https://example.test/payment --yes",
273
293
  description: "Create a booking from a reusable quote input and booking contact fixture."
274
294
  }]));
295
+ const voucherValidate = Command.make("validate", {
296
+ locale: localeFlag,
297
+ code: Flag.String("code").pipe(Flag.withDescription("Voucher code to check.")),
298
+ start: Flag.String("start").pipe(Flag.optional, Flag.withDescription("Arrival date, DD-MM-YYYY or YYYY-MM-DD.")),
299
+ end: Flag.String("end").pipe(Flag.optional, Flag.withDescription("Departure date, DD-MM-YYYY or YYYY-MM-DD."))
300
+ }, ({ locale, code, start, end }) => websiteSdkCommand.pipe(Effect.flatMap((root) => withSDK(root, (sdk) => sdk.backend === "v9" ? sdk.live.voucher.validate({
301
+ locale,
302
+ code,
303
+ ...Option.isSome(start) ? { start: start.value } : {},
304
+ ...Option.isSome(end) ? { end: end.value } : {}
305
+ }) : Promise.reject(/* @__PURE__ */ new Error("voucher validate requires --backend v9."))).pipe(Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Check whether a voucher code can be redeemed."), Command.withExamples([{
306
+ command: "website-sdk --backend v9 voucher validate --code SUMMER --start 01-08-2026 --end 08-08-2026",
307
+ description: "Check a voucher code against a stay."
308
+ }]));
309
+ const voucherCommand = Command.make("voucher").pipe(Command.withDescription("Run live voucher operations."), Command.withSubcommands([voucherValidate]));
275
310
  const liveCommands = [
276
311
  quote,
277
312
  Command.make("booking").pipe(Command.withDescription("Run live booking operations."), Command.withSubcommands([bookingBook])),
278
- Command.make("contact").pipe(Command.withDescription("Run live contact operations."), Command.withSubcommands([contactSubmit]))
313
+ Command.make("contact").pipe(Command.withDescription("Run live contact operations."), Command.withSubcommands([contactSubmit])),
314
+ voucherCommand
279
315
  ];
280
316
  //#endregion
281
317
  //#region src/legacy-v9/review-criteria-discovery.ts
@@ -373,13 +409,23 @@ const staticCommands = [
373
409
  command: "website-sdk --backend v9 rentals --locale en-US",
374
410
  description: "Fetch v9 rentals in English."
375
411
  }])),
412
+ Command.make("rentals-by-ids", {
413
+ locale: localeFlag,
414
+ rentalIds: Flag.String("rental-ids").pipe(Flag.withDescription("Comma-separated vOffice rental IDs."))
415
+ }, ({ locale, rentalIds }) => websiteSdkCommand.pipe(Effect.flatMap((root) => withSDK(root, (sdk) => sdk.backend === "v9" ? sdk.live.rentals.getRentalsByIds({
416
+ locale,
417
+ rentalIds: rentalIds.split(",").map((rentalId) => rentalId.trim()).filter((rentalId) => rentalId.length > 0)
418
+ }) : Promise.reject(/* @__PURE__ */ new Error("rentals-by-ids requires --backend v9."))).pipe(Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Fetch the v9 rentals with the given IDs."), Command.withExamples([{
419
+ command: "website-sdk --backend v9 rentals-by-ids --locale en-US --rental-ids 12,34",
420
+ description: "Fetch two v9 rentals in English."
421
+ }])),
376
422
  Command.make("search", {
377
423
  locale: localeFlag,
378
424
  query: Flag.String("query").pipe(Flag.withDescription("Search query string, for example \"city=munich&adults=2\".")),
379
425
  limit: Flag.Int("limit").pipe(Flag.optional, Flag.withDescription("Optional positive result limit.")),
380
426
  cursor: Flag.String("cursor").pipe(Flag.optional, Flag.withDescription("Optional pagination cursor.")),
381
- rentalIdsIn: Flag.String("rental-ids-in").pipe(Flag.optional, Flag.withDescription("Optional comma-separated rental IDs to restrict v10 search results.")),
382
- voucher: Flag.String("voucher").pipe(Flag.optional, Flag.withDescription("Optional voucher code for v10 search pricing.")),
427
+ rentalIdsIn: Flag.String("rental-ids-in").pipe(Flag.optional, Flag.withDescription("Optional comma-separated rental IDs to restrict search results; v9 needs rentalIdsSearch: true in the config.")),
428
+ voucher: Flag.String("voucher").pipe(Flag.optional, Flag.withDescription("Optional voucher code for search pricing.")),
383
429
  sort: Flag.String("sort").pipe(Flag.optional, Flag.withDescription("Optional SearchSearchSort JSON, for example '{\"by\":\"price\",\"direction\":\"ASC\"}'."))
384
430
  }, ({ locale, query, limit, cursor, rentalIdsIn, voucher, sort }) => websiteSdkCommand.pipe(Effect.flatMap((root) => {
385
431
  return Effect.gen(function* () {
@@ -392,12 +438,12 @@ const staticCommands = [
392
438
  query,
393
439
  ...Option.isSome(limit) ? { limit: limit.value } : {},
394
440
  ...Option.isSome(cursor) ? { cursor: cursor.value } : {},
441
+ ...Option.isSome(voucher) ? { voucher: voucher.value } : {},
442
+ ...parsedRentalIdsIn.length > 0 ? { rentalIdsIn: parsedRentalIdsIn } : {},
395
443
  ...v9Sort === void 0 ? {} : { sort: v9Sort }
396
444
  };
397
445
  return yield* withSDK(root, (sdk) => sdk.backend === "v9" ? sdk.live.search.search(input) : sdk.live.search.search({
398
446
  ...input,
399
- ...parsedRentalIdsIn.length > 0 ? { rentalIdsIn: parsedRentalIdsIn } : {},
400
- ...Option.isSome(voucher) ? { voucher: voucher.value } : {},
401
447
  ...parsedSort === void 0 ? {} : { sort: parsedSort }
402
448
  })).pipe(Effect.flatMap((result) => printOutput(root, result)));
403
449
  });
@@ -414,11 +460,373 @@ const staticCommands = [
414
460
  }]))
415
461
  ];
416
462
  //#endregion
463
+ //#region src/legacy-v9/hub-filters.ts
464
+ const fetchV9HubFilters = (config) => Effect.runPromise(makeV9GraphQLClient(config).execute(hubFiltersQuery, { language: "de" }).pipe(Effect.map((data) => data.filter.map(({ key, name, options }) => ({
465
+ key,
466
+ name,
467
+ options: options ?? []
468
+ })))));
469
+ //#endregion
470
+ //#region src/cli/v9-hub-filters.ts
471
+ const GROUP = "Beliebte Filter";
472
+ const inputFilter = ({ name, queryKey }) => ({
473
+ name,
474
+ type: "InputFilter",
475
+ display_type: "hidden",
476
+ group: GROUP,
477
+ custom_query: { query: [{
478
+ key: queryKey,
479
+ operator: "EQUAL",
480
+ value: null
481
+ }] }
482
+ });
483
+ const HUB_FILTER_REQUESTS = {
484
+ [V9_HUB_FACILITY_SCOPE_FILTER_KEY]: {
485
+ purpose: "Das SDK begrenzt damit die Suche auf die Ferienanlage der Website (rentalScope). Der Wert ist die Hub-interne Ferienanlagen-ID (`VofficeUnit.voffice_facility_id`). Wird nie angezeigt.",
486
+ entry: inputFilter({
487
+ name: "Ferienanlage (Scope)",
488
+ queryKey: "VofficeUnit.voffice_facility_id"
489
+ })
490
+ },
491
+ [V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY]: {
492
+ purpose: "Das SDK begrenzt damit die Suche auf die Objektgruppe der Website (rentalScope). Der Wert ist die vOffice-Gruppen-ID. Wird nie angezeigt.",
493
+ entry: inputFilter({
494
+ name: "Objektgruppe (Scope)",
495
+ queryKey: "VofficeGroup.voffice_group_id"
496
+ })
497
+ },
498
+ [V9_HUB_RENTAL_IDS_FILTER_KEY]: {
499
+ purpose: "Das SDK sucht damit Unterkünfte anhand ihrer vOffice-IDs (`rentalIdsIn`, z. B. für die Merkliste). Wird nie angezeigt.",
500
+ entry: inputFilter({
501
+ name: "vOffice ID",
502
+ queryKey: "VofficeUnit.voffice_id"
503
+ })
504
+ },
505
+ [V9_HUB_OBJECT_GROUP_FILTER_KEY]: {
506
+ purpose: "Filter nach Objektgruppe in der Suche der Website. Der Wert ist die vOffice-Gruppen-ID.",
507
+ entry: inputFilter({
508
+ name: "Objektgruppe",
509
+ queryKey: "VofficeGroup.voffice_group_id"
510
+ })
511
+ },
512
+ [V9_HUB_FACILITY_SEARCH_FILTER_KEY]: {
513
+ purpose: "Filter nach Ferienanlage in der Suche der Website. Die Optionen (vOffice-Ferienanlagen-IDs mit Namen) erzeugt der Hub selbst.",
514
+ entry: {
515
+ name: "Ferienanlage",
516
+ type: "SpecialFilter\\FacilityFilter",
517
+ display_type: "searchselect",
518
+ group: GROUP,
519
+ property: "facility"
520
+ }
521
+ },
522
+ [V9_HUB_OFFERS_FILTER_KEY]: {
523
+ purpose: "Nur Unterkünfte mit einem sichtbaren Angebot. Der Key muss genau `offers` heißen, der Hub liefert die Abfrage selbst.",
524
+ entry: {
525
+ name: "Angebote",
526
+ type: "SpecialFilter\\OffersFilter",
527
+ display_type: "hidden",
528
+ group: GROUP
529
+ }
530
+ },
531
+ [V9_HUB_OFFER_FILTER_KEY]: {
532
+ purpose: "Nur Unterkünfte mit einem bestimmten Angebot. Der Wert ist die vOffice-Angebots-ID.",
533
+ entry: inputFilter({
534
+ name: "Angebot",
535
+ queryKey: "VofficeOffer.voffice_offer_id"
536
+ })
537
+ }
538
+ };
539
+ const REQUEST_ORDER = [
540
+ V9_HUB_FACILITY_SCOPE_FILTER_KEY,
541
+ V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY,
542
+ V9_HUB_RENTAL_IDS_FILTER_KEY,
543
+ V9_HUB_OBJECT_GROUP_FILTER_KEY,
544
+ V9_HUB_FACILITY_SEARCH_FILTER_KEY,
545
+ V9_HUB_OFFERS_FILTER_KEY,
546
+ V9_HUB_OFFER_FILTER_KEY
547
+ ];
548
+ const toRequestedHubFilterKeys = ({ selection, sdkOwnedKeys }) => {
549
+ const wanted = /* @__PURE__ */ new Set([
550
+ ...sdkOwnedKeys,
551
+ ...selection.unit ? [V9_HUB_RENTAL_IDS_FILTER_KEY] : [],
552
+ ...selection.objectGroup ? [V9_HUB_OBJECT_GROUP_FILTER_KEY] : [],
553
+ ...selection.facility ? [V9_HUB_FACILITY_SEARCH_FILTER_KEY] : [],
554
+ ...selection.offers ? [V9_HUB_OFFERS_FILTER_KEY] : [],
555
+ ...selection.offer ? [V9_HUB_OFFER_FILTER_KEY] : []
556
+ ]);
557
+ return REQUEST_ORDER.filter((key) => wanted.has(key));
558
+ };
559
+ const REQUEST_FLAGS = /* @__PURE__ */ new Map([
560
+ [V9_HUB_OBJECT_GROUP_FILTER_KEY, "--object-group"],
561
+ [V9_HUB_FACILITY_SEARCH_FILTER_KEY, "--facility"],
562
+ [V9_HUB_OFFERS_FILTER_KEY, "--offers"],
563
+ [V9_HUB_OFFER_FILTER_KEY, "--offer"]
564
+ ]);
565
+ const renderMissingHubFilters = (missing) => {
566
+ const flags = missing.flatMap((key) => REQUEST_FLAGS.get(key) ?? []);
567
+ const requestable = missing.filter((key) => REQUEST_FLAGS.has(key) || V9_SDK_OWNED_HUB_FILTER_KEYS.has(key));
568
+ const custom = missing.filter((key) => !requestable.includes(key));
569
+ return [
570
+ `Missing Hub filters: ${missing.join(", ")}.`,
571
+ ...requestable.length === 0 ? [] : [`Run \`website-sdk hub-filters request${flags.map((flag) => ` ${flag}`).join("")}\` and hand the file to a be-on! developer.`],
572
+ ...custom.length === 0 ? [] : [`The request file cannot describe ${custom.join(", ")}; ask a be-on! developer for these Hub entries directly.`]
573
+ ].join(" ");
574
+ };
575
+ const toMember = ({ key, entry }) => JSON.stringify({ [key]: entry }, null, 2).split("\n").slice(1, -1).map((line) => line.slice(2)).join("\n");
576
+ const json = (value) => JSON.stringify(value, null, 2);
577
+ const renderHubFilterRequest = ({ beOnKey, graphqlUrl, keys, hubFilters }) => {
578
+ const hubByKey = new Map(hubFilters.map((filter) => [filter.key, filter]));
579
+ const sections = keys.map((key) => {
580
+ const { purpose, entry } = HUB_FILTER_REQUESTS[key];
581
+ const existing = hubByKey.get(key);
582
+ const status = existing === void 0 ? "Fehlt an diesem be-on Key. Eintrag hinzufügen." : `Existiert bereits${existing.name === null ? "" : ` (Name im Hub: „${existing.name}“)`}. Der Hub zeigt nur Key und Name, nicht \`custom_query\`: in Nova mit dem Eintrag unten vergleichen.`;
583
+ return [
584
+ `### \`${key}\``,
585
+ "",
586
+ `Wofür: ${purpose}`,
587
+ "",
588
+ `Status: ${status}`,
589
+ "",
590
+ "```json",
591
+ toMember({
592
+ key,
593
+ entry
594
+ }),
595
+ "```"
596
+ ].join("\n");
597
+ });
598
+ return [
599
+ "# Hub-Filter für eine Website anfragen",
600
+ "",
601
+ `be-on Key: \`${beOnKey}\``,
602
+ "",
603
+ `Hub: ${graphqlUrl}`,
604
+ "",
605
+ "Das Website-SDK braucht die folgenden Filter an diesem be-on Key. Ohne sie filtert die Suche nicht oder der Build der Website bricht ab.",
606
+ "",
607
+ "## Filter",
608
+ "",
609
+ sections.join("\n\n"),
610
+ "",
611
+ "## Vorgehen",
612
+ "",
613
+ "1. In Nova den VofficeFilter dieses be-on Keys öffnen.",
614
+ "2. Das bestehende JSON behalten, nichts löschen oder ersetzen.",
615
+ "3. Fehlende Einträge hinzufügen, unvollständige ergänzen.",
616
+ "4. Existiert ein Key bereits mit gleichem Namen: mit dem Eintrag oben vergleichen. Fehlt `custom_query`, ergänzen. Bedeutet der Key etwas anderes, nichts ändern und beim Website-Entwickler nachfragen.",
617
+ "5. Stable Filter (aus `stable-filters.json`, z. B. `pool`, `wifi`, `bedrooms`) nie kopieren, der Hub ergänzt sie selbst.",
618
+ "6. Speichern. Nova leert dabei den Hub-Filter-Cache.",
619
+ "7. Danach `website-sdk hub-filters check` ausführen.",
620
+ "",
621
+ "Ein `InputFilter` ohne `custom_query` und ohne `property` filtert nichts.",
622
+ "",
623
+ "## Alle Einträge auf einmal",
624
+ "",
625
+ "Enthält auch Keys, die schon existieren. Diese nicht doppelt eintragen, sondern wie in Schritt 4 vergleichen.",
626
+ "",
627
+ "```json",
628
+ json(Object.fromEntries(keys.map((key) => [key, HUB_FILTER_REQUESTS[key].entry]))),
629
+ "```",
630
+ ""
631
+ ].join("\n");
632
+ };
633
+ const definition = ({ key, de, en, ...rest }) => ({
634
+ key,
635
+ source: "backendFilter",
636
+ category: "OTHER",
637
+ label: {
638
+ "de-DE": de,
639
+ "en-US": en
640
+ },
641
+ searchable: true,
642
+ internal: false,
643
+ ...rest
644
+ });
645
+ const toBackendFilterDefinitions = ({ keys, hubFilters }) => {
646
+ const definitions = [];
647
+ const notes = [];
648
+ if (keys.includes("objectGroup")) {
649
+ definitions.push(definition({
650
+ key: V9_HUB_OBJECT_GROUP_FILTER_KEY,
651
+ de: "Objektgruppe",
652
+ en: "Object group",
653
+ type: "option",
654
+ options: [{
655
+ value: "<vOffice object group ID>",
656
+ label: {
657
+ "de-DE": "<Gruppenname>",
658
+ "en-US": "<group name>"
659
+ }
660
+ }]
661
+ }));
662
+ notes.push(`${V9_HUB_OBJECT_GROUP_FILTER_KEY}: add one option per group. The value is the vOffice object group ID; the labels are the group names your site keeps, the Hub returns none.`);
663
+ }
664
+ if (keys.includes("facility_search")) {
665
+ const [firstFacilityOption, ...otherFacilityOptions] = (hubFilters.find(({ key }) => key === "facility_search")?.options ?? []).map(({ key, value }) => ({
666
+ value: key,
667
+ label: {
668
+ "de-DE": value ?? key,
669
+ "en-US": value ?? key
670
+ }
671
+ }));
672
+ definitions.push(definition({
673
+ key: V9_HUB_FACILITY_SEARCH_FILTER_KEY,
674
+ de: "Ferienanlage",
675
+ en: "Facility",
676
+ type: "option",
677
+ options: firstFacilityOption === void 0 ? [{
678
+ value: "<vOffice facility ID>",
679
+ label: {
680
+ "de-DE": "<Name>",
681
+ "en-US": "<name>"
682
+ }
683
+ }] : [firstFacilityOption, ...otherFacilityOptions]
684
+ }));
685
+ notes.push(firstFacilityOption === void 0 ? `${V9_HUB_FACILITY_SEARCH_FILTER_KEY}: the Hub has no options for this key yet. Run this command again once a be-on! developer has added the Hub entry.` : `${V9_HUB_FACILITY_SEARCH_FILTER_KEY}: options come from the Hub (vOffice facility IDs, not rental.property.id). The English labels are the German names; translate them.`);
686
+ }
687
+ if (keys.includes("offers")) definitions.push(definition({
688
+ key: V9_HUB_OFFERS_FILTER_KEY,
689
+ de: "Angebote",
690
+ en: "Special offers",
691
+ type: "boolean"
692
+ }));
693
+ if (keys.includes("offer")) {
694
+ definitions.push(definition({
695
+ key: V9_HUB_OFFER_FILTER_KEY,
696
+ de: "Angebot",
697
+ en: "Special offer",
698
+ type: "int",
699
+ numericBounds: { min: 1 }
700
+ }));
701
+ notes.push(`${V9_HUB_OFFER_FILTER_KEY}: the value is one vOffice offer ID.`);
702
+ }
703
+ return {
704
+ definitions,
705
+ notes
706
+ };
707
+ };
708
+ const renderRequestSummary = ({ file, keys, hubFilters }) => {
709
+ const { definitions, notes } = toBackendFilterDefinitions({
710
+ keys,
711
+ hubFilters
712
+ });
713
+ return [`Wrote ${file}. Hand this file to a be-on! developer; the Hub entries must exist before the site can use these filters.`, ...definitions.length === 0 ? [] : [
714
+ "",
715
+ "Add these to customAttributeFilterDefinitions:",
716
+ json(definitions),
717
+ ...notes.length === 0 ? [] : ["", ...notes.map((note) => `- ${note}`)]
718
+ ]].join("\n");
719
+ };
720
+ //#endregion
721
+ //#region src/cli/commands/v9-hub-filters.ts
722
+ const DEFAULT_REQUEST_FILE = "hub-filter-request.md";
723
+ const loadV9Context = (root) => Effect.gen(function* () {
724
+ if (root.backend !== "v9") return yield* Effect.fail(new CLICheckFailed("hub-filters requires --backend v9."));
725
+ const { config, options } = yield* loadCLIConfig(root);
726
+ if (config.backend !== "v9") return yield* Effect.fail(new CLICheckFailed("hub-filters needs a v9 config."));
727
+ return {
728
+ config,
729
+ options
730
+ };
731
+ });
732
+ const loadHubFilters = (config) => Effect.tryPromise({
733
+ try: () => fetchV9HubFilters(config),
734
+ catch: (cause) => toCLIError("Failed to read the Hub filters", cause)
735
+ });
736
+ const writeTextFile = ({ path, text }) => Effect.tryPromise({
737
+ try: async () => {
738
+ const { writeFile } = await import("node:fs/promises");
739
+ await writeFile(path, text, "utf8");
740
+ },
741
+ catch: (cause) => toCLIError(`Failed to write ${path}`, cause)
742
+ });
743
+ const flag = ({ name, description }) => Flag.Boolean(name).pipe(Flag.withDescription(description), Flag.withDefault(false));
744
+ const request = Command.make("request", {
745
+ objectGroup: flag({
746
+ name: "object-group",
747
+ description: "Request the object group filter (objectGroup)."
748
+ }),
749
+ facility: flag({
750
+ name: "facility",
751
+ description: "Request the facility filter (facility_search)."
752
+ }),
753
+ offers: flag({
754
+ name: "offers",
755
+ description: "Request the filter for units with any special offer (offers)."
756
+ }),
757
+ offer: flag({
758
+ name: "offer",
759
+ description: "Request the filter for units with one special offer (offer)."
760
+ }),
761
+ unit: flag({
762
+ name: "unit",
763
+ description: "Request the filter by vOffice unit ID, the favourites search (voffice_id)."
764
+ }),
765
+ out: Flag.String("out").pipe(Flag.withDescription("Path of the Markdown file to write."), Flag.withDefault(DEFAULT_REQUEST_FILE))
766
+ }, ({ out, ...selection }) => Effect.gen(function* () {
767
+ const root = yield* websiteSdkCommand;
768
+ const { config, options } = yield* loadV9Context(root);
769
+ const keys = toRequestedHubFilterKeys({
770
+ selection,
771
+ sdkOwnedKeys: toV9SdkOwnedHubFilterKeys({
772
+ config,
773
+ rentalScope: options?.rentalScope
774
+ })
775
+ });
776
+ if (keys.length === 0) return yield* Console.log("Nothing to request: pass --object-group, --facility, --offers, --offer or --unit. No file written.");
777
+ const hubFilters = yield* loadHubFilters(config);
778
+ yield* writeTextFile({
779
+ path: out,
780
+ text: renderHubFilterRequest({
781
+ beOnKey: config.apiKey,
782
+ graphqlUrl: config.graphqlUrl,
783
+ keys,
784
+ hubFilters
785
+ })
786
+ });
787
+ yield* Console.log(renderRequestSummary({
788
+ file: out,
789
+ keys,
790
+ hubFilters
791
+ }));
792
+ })).pipe(Command.withDescription("Write a Markdown request for a be-on! developer with the Hub filters this site needs."), Command.withExamples([{
793
+ command: "website-sdk --backend v9 hub-filters request --object-group --offers",
794
+ description: "Write hub-filter-request.md for an object group and an offers filter."
795
+ }, {
796
+ command: "website-sdk --backend v9 --config ./config.json --options ./options.json hub-filters request --out ./request.md",
797
+ description: "Request the scope and favourites filters the configuration already implies."
798
+ }]));
799
+ const check = Command.make("check", {}, () => Effect.gen(function* () {
800
+ const root = yield* websiteSdkCommand;
801
+ const { config, options } = yield* loadV9Context(root);
802
+ const required = toV9RequiredHubFilterKeys({
803
+ config,
804
+ rentalScope: options?.rentalScope,
805
+ customAttributeFilterDefinitions: options?.customAttributeFilterDefinitions ?? []
806
+ });
807
+ if (required.length === 0) return yield* Console.log("This configuration needs no Hub filters.");
808
+ const { present, missing } = checkV9HubFilters({
809
+ required,
810
+ hubFilters: yield* loadHubFilters(config)
811
+ });
812
+ yield* printOutput(root, {
813
+ present,
814
+ missing,
815
+ ...missing.length === 0 ? { note: "All required keys exist. The Hub filter list does not show custom_query, so an entry without it is not detected; an InputFilter without custom_query filters nothing." } : {}
816
+ });
817
+ if (missing.length > 0) return yield* Effect.fail(new CLICheckFailed(renderMissingHubFilters(missing)));
818
+ })).pipe(Command.withDescription("Check that the Hub filters this configuration needs exist for the be-on key."), Command.withExamples([{
819
+ command: "website-sdk --backend v9 --config ./config.json --options ./options.json hub-filters check",
820
+ description: "Compare backend filters, the scope key and voffice_id with the Hub."
821
+ }]));
822
+ const hubFiltersCommand = Command.make("hub-filters").pipe(Command.withDescription("Request and check be-on! Hub filters for v9 sites."), Command.withSubcommands([request, check]));
823
+ //#endregion
417
824
  //#region src/cli/index.ts
418
825
  const cliCommand = websiteSdkCommand.pipe(Command.withSubcommands([
419
826
  configCommand,
420
827
  ...staticCommands,
421
828
  reviewCriteriaCommand,
829
+ hubFiltersCommand,
422
830
  availabilityCommand,
423
831
  ...liveCommands
424
832
  ]));