@v-office/website-sdk 1.2.1 → 2.1.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.
- package/README.md +93 -232
- package/dist/cli.mjs +105 -84
- package/dist/client-xkXV7Nf-.mjs +5127 -0
- package/dist/index.d.mts +1444 -11259
- package/dist/index.mjs +16 -4
- package/dist/instructions/CHANGELOG.md +10 -0
- package/dist/instructions/MIGRATION.md +10 -0
- package/dist/instructions/README.md +64 -0
- package/dist/instructions/availability.md +157 -0
- package/dist/instructions/booking.md +165 -0
- package/dist/instructions/contact.md +110 -0
- package/dist/instructions/creation.md +223 -0
- package/dist/instructions/document-structured-json.md +100 -0
- package/dist/instructions/filter.md +158 -0
- package/dist/instructions/quote.md +342 -0
- package/dist/instructions/rentals.md +152 -0
- package/dist/instructions/search.md +238 -0
- package/dist/instructions/versions/2.0.0/CHANGELOG.md +69 -0
- package/dist/instructions/versions/2.0.0/MIGRATION.md +223 -0
- package/dist/instructions/versions/2.1.0/CHANGELOG.md +32 -0
- package/dist/instructions/versions/2.1.0/MIGRATION.md +89 -0
- package/dist/{quote-DQGps4dy.mjs → quote--25SMlYS.mjs} +41 -19
- package/dist/{rentals-plxPVx83.mjs → rentals-DCKUaLnB.mjs} +22 -16
- package/dist/{search-BuR5apFw.mjs → search-8iCC0Nel.mjs} +40 -23
- package/dist/to-rental-highlights-CZYJeR1D.mjs +5905 -0
- package/dist/translations/shared/de-DE/contact.json +19 -0
- package/dist/translations/shared/de-DE/quote.json +5 -1
- package/dist/translations/shared/en-US/contact.json +19 -0
- package/dist/translations/shared/en-US/quote.json +5 -1
- package/dist/translations/v10/de-DE/mapped-search-filters.json +3 -0
- package/dist/translations/v10/en-US/mapped-search-filters.json +3 -0
- package/instructions/CHANGELOG.md +10 -0
- package/instructions/MIGRATION.md +10 -0
- package/instructions/README.md +64 -0
- package/instructions/availability.md +157 -0
- package/instructions/booking.md +165 -0
- package/instructions/contact.md +110 -0
- package/instructions/creation.md +223 -0
- package/instructions/document-structured-json.md +100 -0
- package/instructions/filter.md +158 -0
- package/instructions/quote.md +342 -0
- package/instructions/rentals.md +152 -0
- package/instructions/search.md +238 -0
- package/instructions/versions/2.0.0/CHANGELOG.md +69 -0
- package/instructions/versions/2.0.0/MIGRATION.md +223 -0
- package/instructions/versions/2.1.0/CHANGELOG.md +32 -0
- package/instructions/versions/2.1.0/MIGRATION.md +89 -0
- package/package.json +42 -56
- package/dist/client-DeEUMMOh.mjs +0 -33237
- package/dist/custom-attribute-D5Kb1YHA.mjs +0 -54
- package/dist/errors-2cuUGSvi.mjs +0 -5
- package/dist/operations-B4IgNB3E.mjs +0 -12618
- package/dist/operations-DcU1qt7g.mjs +0 -1158
- package/dist/quote-BVx3TAHE.mjs +0 -513
- package/dist/quote-CRjV_lf-.mjs +0 -609
- package/dist/rentals-H3RYtMqT.mjs +0 -323
- package/dist/search-filter-metadata-DZP0-Udc.mjs +0 -4294
- package/dist/to-rental-highlights-CAATPqan.mjs +0 -524
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { Pt as defineWebsiteSDKOptions, t as createWebsiteSDK } from "./client-xkXV7Nf-.mjs";
|
|
3
3
|
import { Console, Effect, FileSystem, Layer, Option, Path, Stdio, Terminal } from "effect";
|
|
4
4
|
import { Command, Flag } from "effect/unstable/cli";
|
|
5
5
|
import { inspect } from "node:util";
|
|
6
6
|
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
7
|
-
import { access } from "node:fs/promises";
|
|
7
|
+
import { access, stat } from "node:fs/promises";
|
|
8
8
|
//#region src/cli/output.ts
|
|
9
9
|
const toJson = (value) => JSON.stringify(value, (_key, item) => typeof item === "bigint" ? item.toString() : item, 2);
|
|
10
10
|
const printOutput = (root, value) => {
|
|
@@ -23,10 +23,10 @@ const backendFlag = Flag.choice("backend", ["v9", "v10"]).pipe(Flag.withDescript
|
|
|
23
23
|
const localeFlag = Flag.choice("locale", ["de-DE", "en-US"]).pipe(Flag.withDescription("Locale used for localized SDK calls."), Flag.withDefault("de-DE"));
|
|
24
24
|
const inputFileFlag = Flag.file("input", { mustExist: true }).pipe(Flag.withDescription("Path to a JSON input file."));
|
|
25
25
|
const confirmFlag = Flag.boolean("yes").pipe(Flag.withDescription("Confirm execution of commands that submit or mutate backend state."));
|
|
26
|
-
const
|
|
26
|
+
const websiteSdkCommand = Command.make("website-sdk").pipe(Command.withDescription("Run @v-office/website-sdk operations from the command line."), Command.withSharedFlags({
|
|
27
27
|
backend: backendFlag,
|
|
28
|
-
config: Flag.file("config", { mustExist: true }).pipe(Flag.optional, Flag.withDescription("Path to a JSON
|
|
29
|
-
options: Flag.file("options", { mustExist: true }).pipe(Flag.optional, Flag.withDescription("Path to a JSON
|
|
28
|
+
config: Flag.file("config", { mustExist: true }).pipe(Flag.optional, Flag.withDescription("Path to a JSON WebsiteSDKConfig file. Defaults to environment variables.")),
|
|
29
|
+
options: Flag.file("options", { mustExist: true }).pipe(Flag.optional, Flag.withDescription("Path to a JSON WebsiteSDKOptions file.")),
|
|
30
30
|
output: Flag.choice("output", ["json", "pretty"]).pipe(Flag.withDescription("Output format."), Flag.withDefault("json"))
|
|
31
31
|
}));
|
|
32
32
|
//#endregion
|
|
@@ -54,24 +54,14 @@ const readJsonFile = (path, label) => Effect.tryPromise({
|
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/cli/config.ts
|
|
56
56
|
const getRequiredEnv = (name) => Effect.sync(() => process.env[name]).pipe(Effect.flatMap((value) => value === void 0 || value.length === 0 ? Effect.fail(new CLICheckFailed(`Missing required environment variable ${name}.`)) : Effect.succeed(value)));
|
|
57
|
-
const readOptions = (root, fallback) => Option.isSome(root.options) ? readJsonFile(root.options.value, "
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
case "v10": return {
|
|
66
|
-
...config,
|
|
67
|
-
options
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const fromConfigFile = (root) => Option.isSome(root.config) ? readJsonFile(root.config.value, "CMS config").pipe(Effect.flatMap((config) => config.backend !== root.backend ? Effect.fail(new CLICheckFailed(`Config file backend "${config.backend}" does not match --backend ${root.backend}.`)) : readOptions(root, config.options).pipe(Effect.map((options) => ({
|
|
72
|
-
config: withOptions(config, options),
|
|
73
|
-
options
|
|
74
|
-
}))))) : fromEnvironment(root);
|
|
57
|
+
const readOptions = (root, fallback) => Option.isSome(root.options) ? readJsonFile(root.options.value, "Website SDK options").pipe(Effect.map(defineWebsiteSDKOptions)) : Effect.succeed(fallback);
|
|
58
|
+
const fromConfigFile = (root) => Option.isSome(root.config) ? readJsonFile(root.config.value, "Website SDK config").pipe(Effect.flatMap((config) => {
|
|
59
|
+
const configBackend = config.backend ?? "v10";
|
|
60
|
+
return configBackend !== root.backend ? Effect.fail(new CLICheckFailed(`Config file backend "${configBackend}" does not match --backend ${root.backend}.`)) : readOptions(root, void 0).pipe(Effect.map((options) => ({
|
|
61
|
+
config,
|
|
62
|
+
options
|
|
63
|
+
})));
|
|
64
|
+
})) : fromEnvironment(root);
|
|
75
65
|
const fromEnvironment = (root) => Effect.gen(function* () {
|
|
76
66
|
const options = yield* readOptions(root, void 0);
|
|
77
67
|
if (root.backend === "v9") {
|
|
@@ -79,14 +69,11 @@ const fromEnvironment = (root) => Effect.gen(function* () {
|
|
|
79
69
|
return {
|
|
80
70
|
config: {
|
|
81
71
|
backend: "v9",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
imageProxyBaseUrl: yield* getRequiredEnv("IMAGE_PROXY_BASE_URL")
|
|
88
|
-
},
|
|
89
|
-
...options === void 0 ? {} : { options }
|
|
72
|
+
graphqlUrl: yield* getRequiredEnv("HUB_GRAPHQL_URL"),
|
|
73
|
+
apiKey: yield* getRequiredEnv("HUB_API_KEY"),
|
|
74
|
+
imageProxyBaseUrl: yield* getRequiredEnv("IMAGE_PROXY_BASE_URL"),
|
|
75
|
+
v1ApiBaseUrl: yield* getRequiredEnv("HUB_V1_API_BASE_URL"),
|
|
76
|
+
...v0ApiBaseUrl === void 0 || v0ApiBaseUrl.length === 0 ? {} : { v0ApiBaseUrl }
|
|
90
77
|
},
|
|
91
78
|
options
|
|
92
79
|
};
|
|
@@ -94,12 +81,9 @@ const fromEnvironment = (root) => Effect.gen(function* () {
|
|
|
94
81
|
return {
|
|
95
82
|
config: {
|
|
96
83
|
backend: "v10",
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
imageBaseUrl: yield* getRequiredEnv("VOFFICE_IMAGE_BASE_URL")
|
|
101
|
-
},
|
|
102
|
-
...options === void 0 ? {} : { options }
|
|
84
|
+
apiEndpoint: yield* getRequiredEnv("VOFFICE_API_ENDPOINT"),
|
|
85
|
+
accessToken: yield* getRequiredEnv("VOFFICE_LOCAL_DEV_ACCESS_TOKEN"),
|
|
86
|
+
imageBaseUrl: yield* getRequiredEnv("VOFFICE_IMAGE_BASE_URL")
|
|
103
87
|
},
|
|
104
88
|
options
|
|
105
89
|
};
|
|
@@ -109,37 +93,25 @@ const redactValue = (value) => {
|
|
|
109
93
|
return value.length <= 4 ? "****" : `${value.slice(0, 2)}****${value.slice(-2)}`;
|
|
110
94
|
};
|
|
111
95
|
const redactConfig = (config) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
case "v10": return {
|
|
121
|
-
...config,
|
|
122
|
-
v10: {
|
|
123
|
-
...config.v10,
|
|
124
|
-
accessToken: redactValue(config.v10.accessToken) ?? ""
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
96
|
+
if (config.backend === "v9") return {
|
|
97
|
+
...config,
|
|
98
|
+
apiKey: redactValue(config.apiKey) ?? ""
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
...config,
|
|
102
|
+
accessToken: redactValue(config.accessToken) ?? ""
|
|
103
|
+
};
|
|
128
104
|
};
|
|
129
105
|
const loadCLIConfig = fromConfigFile;
|
|
130
106
|
//#endregion
|
|
131
107
|
//#region src/cli/sdk.ts
|
|
132
108
|
const withSDK = (root, run) => Effect.gen(function* () {
|
|
133
|
-
const { config } = yield* loadCLIConfig(root);
|
|
109
|
+
const { config, options } = yield* loadCLIConfig(root);
|
|
134
110
|
return yield* Effect.tryPromise({
|
|
135
|
-
try:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} finally {
|
|
140
|
-
await sdk.dispose();
|
|
141
|
-
}
|
|
142
|
-
},
|
|
111
|
+
try: () => run(createWebsiteSDK({
|
|
112
|
+
config,
|
|
113
|
+
...options === void 0 ? {} : { options }
|
|
114
|
+
})),
|
|
143
115
|
catch: (cause) => toCLIError("SDK operation failed", cause)
|
|
144
116
|
});
|
|
145
117
|
});
|
|
@@ -153,8 +125,8 @@ const initial = Command.make("initial", {
|
|
|
153
125
|
rentalId: rentalIdFlag,
|
|
154
126
|
calculateFromDate: calculateFromDateFlag,
|
|
155
127
|
calculateThroughDate: calculateThroughDateFlag
|
|
156
|
-
}, (input) =>
|
|
157
|
-
command: "
|
|
128
|
+
}, (input) => websiteSdkCommand.pipe(Effect.flatMap((root) => withSDK(root, (sdk) => sdk.live.availability.getInitialAvailability(input)).pipe(Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Fetch initial availability for a rental."), Command.withExamples([{
|
|
129
|
+
command: "website-sdk --backend v10 availability initial --rental-id 123 --calculate-from-date 2026-07-01 --calculate-through-date 2026-08-01",
|
|
158
130
|
description: "Fetch an initial availability calendar."
|
|
159
131
|
}]));
|
|
160
132
|
const startDateSelected = Command.make("start-date-selected", {
|
|
@@ -163,15 +135,15 @@ const startDateSelected = Command.make("start-date-selected", {
|
|
|
163
135
|
selectedStartDate: Flag.string("selected-start-date").pipe(Flag.withDescription("Selected start date, formatted as YYYY-MM-DD.")),
|
|
164
136
|
calculateFromDate: calculateFromDateFlag,
|
|
165
137
|
calculateThroughDate: calculateThroughDateFlag
|
|
166
|
-
}, (input) =>
|
|
167
|
-
command: "
|
|
138
|
+
}, (input) => websiteSdkCommand.pipe(Effect.flatMap((root) => withSDK(root, (sdk) => sdk.live.availability.getStartDateSelectedAvailability(input)).pipe(Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Fetch availability after selecting a start date."), Command.withExamples([{
|
|
139
|
+
command: "website-sdk --backend v9 availability start-date-selected --rental-id 123 --selected-start-date 2026-07-08 --calculate-from-date 2026-07-01 --calculate-through-date 2026-08-01",
|
|
168
140
|
description: "Fetch available end dates for a selected start date."
|
|
169
141
|
}]));
|
|
170
142
|
const availabilityCommand = Command.make("availability").pipe(Command.withDescription("Run live availability operations."), Command.withSubcommands([initial, startDateSelected]));
|
|
171
143
|
//#endregion
|
|
172
144
|
//#region src/cli/commands/config.ts
|
|
173
145
|
const show = Command.make("show", {}, Effect.fn(function* () {
|
|
174
|
-
const root = yield*
|
|
146
|
+
const root = yield* websiteSdkCommand;
|
|
175
147
|
const resolved = yield* loadCLIConfig(root);
|
|
176
148
|
yield* printOutput(root, {
|
|
177
149
|
...resolved,
|
|
@@ -179,7 +151,7 @@ const show = Command.make("show", {}, Effect.fn(function* () {
|
|
|
179
151
|
});
|
|
180
152
|
})).pipe(Command.withDescription("Show the resolved CLI config with secrets redacted."));
|
|
181
153
|
const env = Command.make("env", {}, Effect.fn(function* () {
|
|
182
|
-
const root = yield*
|
|
154
|
+
const root = yield* websiteSdkCommand;
|
|
183
155
|
yield* printOutput(root, {
|
|
184
156
|
backend: root.backend,
|
|
185
157
|
required: root.backend === "v9" ? [
|
|
@@ -201,30 +173,56 @@ const configCommand = Command.make("config").pipe(Command.withDescription("Inspe
|
|
|
201
173
|
const requireConfirmation = (root, confirmed, commandName) => confirmed ? Effect.void : Effect.fail(/* @__PURE__ */ new Error(`${commandName} can submit data to the configured backend. Re-run with --yes to confirm.`));
|
|
202
174
|
//#endregion
|
|
203
175
|
//#region src/cli/commands/live.ts
|
|
204
|
-
const
|
|
205
|
-
|
|
176
|
+
const quoteInputFileFlag = Flag.file("quote-input", { mustExist: true }).pipe(Flag.withDescription("Path to a JSON QuoteQuoteInput file."));
|
|
177
|
+
const contactInputFileFlag = Flag.file("contact-input", { mustExist: true }).pipe(Flag.withDescription("Path to a JSON BookingContact file."));
|
|
178
|
+
const relativeRedirectUrlFlag = Flag.string("relative-redirect-url").pipe(Flag.withDescription("Redirect URL passed to booking payment initialization."));
|
|
179
|
+
const quote = Command.make("quote", { input: inputFileFlag }, ({ input }) => websiteSdkCommand.pipe(Effect.flatMap((root) => readJsonFile(input, "quote input").pipe(Effect.flatMap((quoteInput) => withSDK(root, (sdk) => sdk.live.quote.quote(quoteInput))), Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Create a live guest quote from a JSON QuoteQuoteInput file."), Command.withExamples([{
|
|
180
|
+
command: "website-sdk --backend v10 quote --input ./quote-input.json",
|
|
206
181
|
description: "Create a quote using a reusable JSON fixture."
|
|
207
182
|
}]));
|
|
208
183
|
const contactSubmit = Command.make("submit", {
|
|
209
184
|
input: inputFileFlag,
|
|
210
185
|
yes: confirmFlag
|
|
211
|
-
}, ({ input, yes }) =>
|
|
186
|
+
}, ({ input, yes }) => websiteSdkCommand.pipe(Effect.flatMap((root) => Effect.gen(function* () {
|
|
212
187
|
yield* requireConfirmation(root, yes, "contact submit");
|
|
213
188
|
const contactInput = yield* readJsonFile(input, "contact input");
|
|
214
189
|
yield* withSDK(root, (sdk) => sdk.live.contact.submit(contactInput));
|
|
215
190
|
yield* printSuccess(root);
|
|
216
|
-
})))).pipe(Command.withDescription("Submit a contact request from a JSON
|
|
217
|
-
command: "
|
|
191
|
+
})))).pipe(Command.withDescription("Submit a contact request from a JSON ContactSubmitInput file."), Command.withExamples([{
|
|
192
|
+
command: "website-sdk --backend v9 contact submit --input ./contact-input.json --yes",
|
|
218
193
|
description: "Submit a contact request after explicit confirmation."
|
|
219
194
|
}]));
|
|
220
|
-
const
|
|
195
|
+
const bookingBook = Command.make("book", {
|
|
196
|
+
contactInput: contactInputFileFlag,
|
|
197
|
+
quoteInput: quoteInputFileFlag,
|
|
198
|
+
relativeRedirectUrl: relativeRedirectUrlFlag,
|
|
199
|
+
yes: confirmFlag
|
|
200
|
+
}, ({ contactInput, quoteInput, relativeRedirectUrl, yes }) => websiteSdkCommand.pipe(Effect.flatMap((root) => Effect.gen(function* () {
|
|
201
|
+
yield* requireConfirmation(root, yes, "booking book");
|
|
202
|
+
const [quoteRequest, contact] = yield* Effect.all([readJsonFile(quoteInput, "quote input"), readJsonFile(contactInput, "booking contact input")]);
|
|
203
|
+
const quoteResult = yield* withSDK(root, (sdk) => sdk.live.quote.quote(quoteRequest));
|
|
204
|
+
if (quoteResult.status !== "available") return yield* Effect.fail(new CLICheckFailed("Cannot create a booking because the quote is unavailable."));
|
|
205
|
+
yield* printOutput(root, yield* withSDK(root, (sdk) => sdk.live.booking.book({
|
|
206
|
+
quote: quoteResult.quote,
|
|
207
|
+
contact,
|
|
208
|
+
relativeRedirectUrl
|
|
209
|
+
})));
|
|
210
|
+
})))).pipe(Command.withDescription("Create a booking from quote/contact JSON files after confirmation."), Command.withExamples([{
|
|
211
|
+
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",
|
|
212
|
+
description: "Create a booking from a reusable quote input and booking contact fixture."
|
|
213
|
+
}]));
|
|
214
|
+
const liveCommands = [
|
|
215
|
+
quote,
|
|
216
|
+
Command.make("booking").pipe(Command.withDescription("Run live booking operations."), Command.withSubcommands([bookingBook])),
|
|
217
|
+
Command.make("contact").pipe(Command.withDescription("Run live contact operations."), Command.withSubcommands([contactSubmit]))
|
|
218
|
+
];
|
|
221
219
|
const staticCommands = [
|
|
222
|
-
Command.make("filters", { locale: localeFlag }, ({ locale }) =>
|
|
223
|
-
command: "
|
|
220
|
+
Command.make("filters", { locale: localeFlag }, ({ locale }) => websiteSdkCommand.pipe(Effect.flatMap((root) => withSDK(root, (sdk) => sdk.static.filter.getFilters({ locale })).pipe(Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Fetch unified filter definitions."), Command.withExamples([{
|
|
221
|
+
command: "website-sdk --backend v10 filters --locale de-DE",
|
|
224
222
|
description: "Fetch v10 filter definitions as JSON."
|
|
225
223
|
}])),
|
|
226
|
-
Command.make("rentals", { locale: localeFlag }, ({ locale }) =>
|
|
227
|
-
command: "
|
|
224
|
+
Command.make("rentals", { locale: localeFlag }, ({ locale }) => websiteSdkCommand.pipe(Effect.flatMap((root) => withSDK(root, (sdk) => sdk.static.rentals.getRentals({ locale })).pipe(Effect.flatMap((result) => printOutput(root, result)))))).pipe(Command.withDescription("Fetch rental summaries."), Command.withExamples([{
|
|
225
|
+
command: "website-sdk --backend v9 rentals --locale en-US",
|
|
228
226
|
description: "Fetch v9 rentals in English."
|
|
229
227
|
}])),
|
|
230
228
|
Command.make("search", {
|
|
@@ -232,31 +230,33 @@ const staticCommands = [
|
|
|
232
230
|
query: Flag.string("query").pipe(Flag.withDescription("Search query string, for example \"city=munich&adults=2\".")),
|
|
233
231
|
limit: Flag.integer("limit").pipe(Flag.optional, Flag.withDescription("Optional positive result limit.")),
|
|
234
232
|
cursor: Flag.string("cursor").pipe(Flag.optional, Flag.withDescription("Optional pagination cursor.")),
|
|
235
|
-
rentalIdsIn: Flag.string("rental-ids-in").pipe(Flag.optional, Flag.withDescription("Optional comma-separated rental IDs to restrict v10 search results."))
|
|
236
|
-
|
|
233
|
+
rentalIdsIn: Flag.string("rental-ids-in").pipe(Flag.optional, Flag.withDescription("Optional comma-separated rental IDs to restrict v10 search results.")),
|
|
234
|
+
voucher: Flag.string("voucher").pipe(Flag.optional, Flag.withDescription("Optional voucher code for v10 search pricing."))
|
|
235
|
+
}, ({ locale, query, limit, cursor, rentalIdsIn, voucher }) => websiteSdkCommand.pipe(Effect.flatMap((root) => {
|
|
237
236
|
const parsedRentalIdsIn = Option.isSome(rentalIdsIn) ? rentalIdsIn.value.split(",").map((rentalId) => rentalId.trim()).filter((rentalId) => rentalId.length > 0) : [];
|
|
238
237
|
const input = {
|
|
239
238
|
locale,
|
|
240
239
|
query,
|
|
241
240
|
...parsedRentalIdsIn.length > 0 ? { rentalIdsIn: parsedRentalIdsIn } : {},
|
|
241
|
+
...Option.isSome(voucher) ? { voucher: voucher.value } : {},
|
|
242
242
|
...Option.isSome(limit) ? { limit: limit.value } : {},
|
|
243
243
|
...Option.isSome(cursor) ? { cursor: cursor.value } : {}
|
|
244
244
|
};
|
|
245
245
|
return withSDK(root, (sdk) => sdk.live.search.search(input)).pipe(Effect.flatMap((result) => printOutput(root, result)));
|
|
246
246
|
}))).pipe(Command.withDescription("Run a live rental search."), Command.withExamples([{
|
|
247
|
-
command: "
|
|
247
|
+
command: "website-sdk --backend v10 search --locale de-DE --query \"adults=2\"",
|
|
248
248
|
description: "Search v10 rentals with a query string."
|
|
249
249
|
}]))
|
|
250
250
|
];
|
|
251
251
|
//#endregion
|
|
252
252
|
//#region src/cli/index.ts
|
|
253
|
-
const cliCommand =
|
|
253
|
+
const cliCommand = websiteSdkCommand.pipe(Command.withSubcommands([
|
|
254
254
|
configCommand,
|
|
255
255
|
...staticCommands,
|
|
256
256
|
availabilityCommand,
|
|
257
257
|
...liveCommands
|
|
258
258
|
]));
|
|
259
|
-
const runCLI = Command.run(cliCommand, { version: "1.0
|
|
259
|
+
const runCLI = Command.run(cliCommand, { version: "2.1.0" });
|
|
260
260
|
//#endregion
|
|
261
261
|
//#region src/cli/node-services.ts
|
|
262
262
|
const unsupported = (operation) => Effect.die(`Unsupported CLI platform operation: ${operation}`);
|
|
@@ -300,7 +300,28 @@ const FileSystemLive = Layer.succeed(FileSystem.FileSystem, {
|
|
|
300
300
|
remove: () => unsupported("FileSystem.remove"),
|
|
301
301
|
rename: () => unsupported("FileSystem.rename"),
|
|
302
302
|
sink: () => unsupported("FileSystem.sink"),
|
|
303
|
-
stat: () =>
|
|
303
|
+
stat: (path) => Effect.tryPromise({
|
|
304
|
+
try: async () => {
|
|
305
|
+
const stats = await stat(path);
|
|
306
|
+
return {
|
|
307
|
+
type: stats.isFile() ? "File" : stats.isDirectory() ? "Directory" : stats.isSymbolicLink() ? "SymbolicLink" : "Unknown",
|
|
308
|
+
mtime: Option.some(stats.mtime),
|
|
309
|
+
atime: Option.some(stats.atime),
|
|
310
|
+
birthtime: Option.some(stats.birthtime),
|
|
311
|
+
dev: stats.dev,
|
|
312
|
+
ino: Option.some(stats.ino),
|
|
313
|
+
mode: stats.mode,
|
|
314
|
+
nlink: Option.some(stats.nlink),
|
|
315
|
+
uid: Option.some(stats.uid),
|
|
316
|
+
gid: Option.some(stats.gid),
|
|
317
|
+
rdev: Option.some(stats.rdev),
|
|
318
|
+
size: FileSystem.Size(stats.size),
|
|
319
|
+
blksize: Option.some(FileSystem.Size(stats.blksize)),
|
|
320
|
+
blocks: Option.some(stats.blocks)
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
catch: (cause) => cause
|
|
324
|
+
}),
|
|
304
325
|
stream: () => unsupported("FileSystem.stream"),
|
|
305
326
|
symlink: () => unsupported("FileSystem.symlink"),
|
|
306
327
|
truncate: () => unsupported("FileSystem.truncate"),
|