@v-office/website-sdk 2.24.1 → 2.26.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 (34) hide show
  1. package/dist/cli.mjs +89 -2
  2. package/dist/{client-DC4LG3CP.mjs → client--T_tQSjV.mjs} +237 -70
  3. package/dist/index.d.mts +22 -5
  4. package/dist/index.mjs +1 -1
  5. package/dist/instructions/CHANGELOG.md +2 -0
  6. package/dist/instructions/MIGRATION.md +2 -0
  7. package/dist/instructions/README.md +1 -1
  8. package/dist/instructions/creation.md +5 -0
  9. package/dist/instructions/rentals.md +75 -0
  10. package/dist/instructions/search.md +48 -3
  11. package/dist/instructions/versions/2.25.0/CHANGELOG.md +41 -0
  12. package/dist/instructions/versions/2.25.0/MIGRATION.md +64 -0
  13. package/dist/instructions/versions/2.26.0/CHANGELOG.md +33 -0
  14. package/dist/instructions/versions/2.26.0/MIGRATION.md +31 -0
  15. package/dist/{to-rental-highlights-C1NF2uuE.mjs → operations-DwURbo0b.mjs} +1 -626
  16. package/dist/{rentals-eqFhtCdT.mjs → rentals-D4wmqjzL.mjs} +96 -33
  17. package/dist/{search-CKL-8T8q.mjs → search-DtBtzIGf.mjs} +5 -4
  18. package/dist/to-rental-highlights-BL5m3Uen.mjs +626 -0
  19. package/dist/translations/v9/de-DE/core.json +3 -1
  20. package/dist/translations/v9/en-US/core.json +3 -1
  21. package/dist/{v9-data-BnYxa2Ek.mjs → v9-data-C3SWtDGs.mjs} +7 -5
  22. package/instructions/CHANGELOG.md +2 -0
  23. package/instructions/MIGRATION.md +2 -0
  24. package/instructions/README.md +1 -1
  25. package/instructions/creation.md +5 -0
  26. package/instructions/rentals.md +75 -0
  27. package/instructions/search.md +48 -3
  28. package/instructions/versions/2.25.0/CHANGELOG.md +41 -0
  29. package/instructions/versions/2.25.0/MIGRATION.md +64 -0
  30. package/instructions/versions/2.25.0/release.json +3 -0
  31. package/instructions/versions/2.26.0/CHANGELOG.md +33 -0
  32. package/instructions/versions/2.26.0/MIGRATION.md +31 -0
  33. package/instructions/versions/2.26.0/release.json +3 -0
  34. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { Ut as defineV9PropertyHighlightSourcesFromUnknown, Vt as defineWebsiteSDKOptions, t as createWebsiteSDK } from "./client-DC4LG3CP.mjs";
2
+ import { Ht as defineWebsiteSDKOptions, Wt as defineV9PropertyHighlightSourcesFromUnknown, c as makeV9GraphQLClient, d as makeV0OpenApiClientFetchLive, l as V0OpenApiClient, t as createWebsiteSDK } from "./client--T_tQSjV.mjs";
3
+ import { c as parseVofficeRatingData } from "./v9-data-C3SWtDGs.mjs";
4
+ import { s as rentalsAllWithoutFeedbacksQuery } from "./operations-DwURbo0b.mjs";
3
5
  import { SearchSearchSortSchema, defineCustomAttributesFromUnknown } from "@v-office/sdk-core";
4
6
  import { ByteSize, Console, Effect, FileSystem, Layer, Option, Path, Schema, Stdio, Terminal } from "effect";
5
7
  import { Command, Flag } from "effect/unstable/cli";
@@ -16,7 +18,7 @@ var CLICheckFailed = class extends Error {
16
18
  const toCLIError = (message, cause) => cause instanceof Error ? new CLICheckFailed(`${message}: ${cause.message}`, { cause }) : new CLICheckFailed(message, { cause });
17
19
  //#endregion
18
20
  //#region package.json
19
- var version = "2.24.1";
21
+ var version = "2.26.0";
20
22
  //#endregion
21
23
  //#region src/cli/output.ts
22
24
  const toJson = (value) => Effect.try({
@@ -276,6 +278,90 @@ const liveCommands = [
276
278
  Command.make("contact").pipe(Command.withDescription("Run live contact operations."), Command.withSubcommands([contactSubmit]))
277
279
  ];
278
280
  //#endregion
281
+ //#region src/legacy-v9/review-criteria-discovery.ts
282
+ const DEFAULT_SAMPLE_SIZE = 5;
283
+ const criterionKeyPattern = /^fb_[1-9]\d*$/;
284
+ const findMostReviewedRentalIds = (config) => makeV9GraphQLClient(config).execute(rentalsAllWithoutFeedbacksQuery, {
285
+ language: "de",
286
+ rentalRatingDataAttributes: ["fb_count"]
287
+ }).pipe(Effect.map((data) => data.all.map((rental) => ({
288
+ id: rental.voffice_id,
289
+ count: parseVofficeRatingData(rental.voffice_rating?.data).known.fb_count ?? 0
290
+ })).filter((rental) => rental.count > 0).sort((left, right) => right.count - left.count).map((rental) => rental.id)));
291
+ const isUnknownUnit = (error) => error.status === 503 && typeof error.raw === "object" && error.raw !== null && error.raw.reason === "could not find unit";
292
+ const loadUnitCriterionValues = (unitId) => Effect.gen(function* () {
293
+ const result = yield* (yield* V0OpenApiClient).execute("proxyVofficeAction", { query: {
294
+ actionName: "getUnit",
295
+ data: JSON.stringify({ id: unitId })
296
+ } }).pipe(Effect.catch((error) => isUnknownUnit(error) ? Effect.succeed(void 0) : Effect.fail(error)));
297
+ if (result === void 0) return void 0;
298
+ const response = result.raw;
299
+ if (response.ok === false) return void 0;
300
+ return Object.entries(response.data ?? {}).filter(([key, value]) => criterionKeyPattern.test(key) && (typeof value === "number" || typeof value === "string" && value.trim() !== ""));
301
+ });
302
+ const discoverV9ReviewCriteria = ({ config, rentalIds }) => Effect.runPromise(Effect.gen(function* () {
303
+ const explicit = rentalIds !== void 0 && rentalIds.length > 0;
304
+ const candidates = explicit ? rentalIds : yield* findMostReviewedRentalIds(config);
305
+ const checkedRentalIds = [];
306
+ const skippedRentalIds = [];
307
+ const criteria = /* @__PURE__ */ new Map();
308
+ for (const unitId of candidates) {
309
+ if (!explicit && checkedRentalIds.length === DEFAULT_SAMPLE_SIZE) break;
310
+ const values = yield* loadUnitCriterionValues(unitId);
311
+ if (values === void 0) {
312
+ skippedRentalIds.push(unitId);
313
+ continue;
314
+ }
315
+ checkedRentalIds.push(unitId);
316
+ for (const [key, value] of values) {
317
+ const criterion = criteria.get(key) ?? {
318
+ type: typeof value === "number" ? "stars" : "text",
319
+ rentalIds: []
320
+ };
321
+ criterion.rentalIds.push(unitId.toString());
322
+ criteria.set(key, criterion);
323
+ }
324
+ }
325
+ return {
326
+ checkedRentalIds: checkedRentalIds.map(String),
327
+ skippedRentalIds: skippedRentalIds.map(String),
328
+ criteria: [...criteria.entries()].map(([v9, criterion]) => ({
329
+ v9,
330
+ ...criterion
331
+ }))
332
+ };
333
+ }).pipe(Effect.provide(makeV0OpenApiClientFetchLive({
334
+ apiKey: config.apiKey,
335
+ ...config.v0ApiBaseUrl === void 0 ? {} : { baseUrl: config.v0ApiBaseUrl }
336
+ }))));
337
+ //#endregion
338
+ //#region src/cli/commands/review-criteria.ts
339
+ const parseRentalIds = (value) => {
340
+ const ids = value.split(",").map((id) => Number(id.trim()));
341
+ return ids.every((id) => Number.isSafeInteger(id) && id > 0) ? Effect.succeed(ids) : Effect.fail(new CLICheckFailed("Expected --rental-ids to list vOffice unit IDs."));
342
+ };
343
+ const reviewCriteriaCommand = Command.make("review-criteria", { rentalIds: Flag.String("rental-ids").pipe(Flag.optional, Flag.withDescription("Comma-separated vOffice unit IDs to check. Defaults to the five units with the most feedbacks.")) }, ({ rentalIds }) => Effect.gen(function* () {
344
+ const root = yield* websiteSdkCommand;
345
+ if (root.backend !== "v9") return yield* Effect.fail(new CLICheckFailed("review-criteria is only available for --backend v9."));
346
+ const { config } = yield* loadCLIConfig(root);
347
+ if (config.backend !== "v9") return yield* Effect.fail(new CLICheckFailed("review-criteria needs a v9 config."));
348
+ const ids = Option.isSome(rentalIds) ? yield* parseRentalIds(rentalIds.value) : void 0;
349
+ const result = yield* Effect.tryPromise({
350
+ try: () => discoverV9ReviewCriteria({
351
+ config,
352
+ ...ids === void 0 ? {} : { rentalIds: ids }
353
+ }),
354
+ catch: (cause) => toCLIError("Review criteria discovery failed", cause)
355
+ });
356
+ yield* printOutput(root, result);
357
+ })).pipe(Command.withDescription("List the v9 fb_* review criteria vOffice returns for units, for the v9Reviews option."), Command.withExamples([{
358
+ command: "website-sdk --backend v9 review-criteria",
359
+ description: "List the criteria of the five units with the most feedbacks."
360
+ }, {
361
+ command: "website-sdk --backend v9 review-criteria --rental-ids 212350,212351",
362
+ description: "List the criteria of specific units."
363
+ }]));
364
+ //#endregion
279
365
  //#region src/cli/commands/static.ts
280
366
  const parseSearchSort = (input) => parseJson(input, "--sort").pipe(Effect.flatMap((value) => Schema.decodeUnknownEffect(SearchSearchSortSchema, { onExcessProperty: "error" })(value).pipe(Effect.mapError((cause) => toCLIError("Invalid --sort value", cause)))));
281
367
  const staticCommands = [
@@ -332,6 +418,7 @@ const staticCommands = [
332
418
  const cliCommand = websiteSdkCommand.pipe(Command.withSubcommands([
333
419
  configCommand,
334
420
  ...staticCommands,
421
+ reviewCriteriaCommand,
335
422
  availabilityCommand,
336
423
  ...liveCommands
337
424
  ]));