@ferryrsvp/liknoss-client 1.0.3

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.
@@ -0,0 +1,7 @@
1
+ export { createLiknossClient } from "./client";
2
+ export { LiknossApiError, LiknossConfigurationError, LiknossError, LiknossHttpError, LiknossNetworkError, LiknossResponseParseError, } from "./core/errors";
3
+ export { createAccommodationService, createBookingService, createCatalogService, createInsuranceService, createTripService, createValidationService, } from "./services";
4
+ export type { components, operations, paths } from "./generated/openapi";
5
+ export type { LiknossApiErrorDetail, LiknossApiPayloadShape, LiknossBookingStatus, LiknossClientOptions, LiknossGetMethod, LiknossMethodArgs, LiknossPostMethod, LiknossResult, LiknossResponseMeta, LiknossTransport, LiknossWarning, } from "./core/types";
6
+ export type { LiknossClient } from "./client";
7
+ export type { LiknossAccommodationService, LiknossBookingService, LiknossCatalogService, LiknossInsuranceService, LiknossTripService, LiknossValidationService, } from "./services";
@@ -0,0 +1,285 @@
1
+ //#region src/core/errors.ts
2
+ var e = class extends Error {
3
+ constructor(e, t = {}) {
4
+ super(e), this.name = new.target.name, this.code = t.code, this.cause = t.cause;
5
+ }
6
+ }, t = class extends e {}, n = class extends e {
7
+ constructor(e, t) {
8
+ super(e, { cause: t.cause }), this.endpoint = t.endpoint, this.method = t.method;
9
+ }
10
+ }, r = class extends e {
11
+ constructor(e, t) {
12
+ super(e), this.endpoint = t.endpoint, this.method = t.method, this.responseBody = t.responseBody, this.status = t.status, this.statusText = t.statusText;
13
+ }
14
+ }, i = class extends e {
15
+ constructor(e, t) {
16
+ super(e, { cause: t.cause }), this.endpoint = t.endpoint, this.method = t.method, this.rawBody = t.rawBody, this.status = t.status;
17
+ }
18
+ }, a = class extends e {
19
+ constructor(e, t) {
20
+ super(e, { code: t.meta.code }), this.issues = t.issues, this.meta = t.meta, this.payload = t.payload;
21
+ }
22
+ };
23
+ //#endregion
24
+ //#region src/core/normalize.ts
25
+ function o(e) {
26
+ return typeof e == "object" && !!e;
27
+ }
28
+ function s(e) {
29
+ if (typeof e != "string") return;
30
+ let t = e.trim();
31
+ return t.length > 0 ? t : void 0;
32
+ }
33
+ function c(e) {
34
+ return o(e);
35
+ }
36
+ function ee(e) {
37
+ return c(e) && e.severeError === !0;
38
+ }
39
+ function l(e) {
40
+ if (!c(e)) return [];
41
+ let t = [];
42
+ if (e.perCompanyErrorDetails) for (let [n, r] of Object.entries(e.perCompanyErrorDetails)) for (let e of r) t.push({
43
+ code: e.code ?? void 0,
44
+ company: n,
45
+ description: e.description ?? "Liknoss reported an issue.",
46
+ severity: e.severity ?? void 0,
47
+ source: "perCompanyErrorDetails"
48
+ });
49
+ if (e.bookingStatusesPerCompany) for (let n of e.bookingStatusesPerCompany) !n.status || n.status === "SUCCESS" || t.push({
50
+ code: n.status,
51
+ company: n.company?.abbreviation ?? n.company?.description ?? void 0,
52
+ description: `Booking status reported ${n.status}.`,
53
+ source: "bookingStatus"
54
+ });
55
+ return t;
56
+ }
57
+ function u(e, t) {
58
+ return c(e) ? {
59
+ abbreviation: e.abbreviation,
60
+ code: e.code,
61
+ endpoint: t.endpoint,
62
+ message: e.message,
63
+ method: t.method,
64
+ requestId: s(e.requestId),
65
+ responseCode: s(e.responseCode),
66
+ responseDescription: s(e.responseDesciption),
67
+ status: t.status
68
+ } : {
69
+ endpoint: t.endpoint,
70
+ method: t.method,
71
+ status: t.status
72
+ };
73
+ }
74
+ //#endregion
75
+ //#region src/core/request.ts
76
+ var d = "https://devsrv.liknoss.com/cws";
77
+ function f(e) {
78
+ return e.endsWith("/") ? e.slice(0, -1) : e;
79
+ }
80
+ function p(e, n) {
81
+ return n ? e.replace(/\{([^}]+)\}/g, (r, i) => {
82
+ let a = n[i];
83
+ if (a == null) throw new t(`Missing path parameter "${i}" for "${e}".`);
84
+ return encodeURIComponent(String(a));
85
+ }) : e;
86
+ }
87
+ function m(e, t) {
88
+ if (t) {
89
+ for (let [n, r] of Object.entries(t)) if (r != null) {
90
+ if (Array.isArray(r)) {
91
+ for (let t of r) t != null && e.searchParams.append(n, String(t));
92
+ continue;
93
+ }
94
+ e.searchParams.append(n, String(r));
95
+ }
96
+ }
97
+ }
98
+ function h(e) {
99
+ let t = new Headers(e.defaultHeaders);
100
+ return e.headers && new Headers(e.headers).forEach((e, n) => {
101
+ t.set(n, e);
102
+ }), t.set("Accept", "application/json"), e.body !== void 0 && t.set("Content-Type", "application/json"), e.apiKey && t.set("api_key", e.apiKey), t;
103
+ }
104
+ function g(e = {}) {
105
+ let o = e.fetch ?? globalThis.fetch;
106
+ if (typeof o != "function") throw new t("Liknoss client requires a fetch implementation.");
107
+ let s = f(e.baseUrl ?? d);
108
+ return { async request(t) {
109
+ let c = p(t.path, t.pathParams), d = new URL(`${s}${c}`);
110
+ m(d, t.query);
111
+ let f = t.method.toUpperCase(), g = h({
112
+ apiKey: e.apiKey,
113
+ body: t.body,
114
+ defaultHeaders: e.defaultHeaders,
115
+ headers: t.headers
116
+ }), _;
117
+ try {
118
+ _ = await o(d, {
119
+ body: t.body === void 0 ? void 0 : JSON.stringify(t.body),
120
+ headers: g,
121
+ method: f,
122
+ signal: t.signal
123
+ });
124
+ } catch (e) {
125
+ throw new n("Liknoss request failed.", {
126
+ cause: e,
127
+ endpoint: c,
128
+ method: f
129
+ });
130
+ }
131
+ let v = await _.text();
132
+ if (!_.ok) throw new r("Liknoss returned a non-success status.", {
133
+ endpoint: c,
134
+ method: f,
135
+ responseBody: v,
136
+ status: _.status,
137
+ statusText: _.statusText
138
+ });
139
+ if (!v) return {
140
+ data: void 0,
141
+ meta: u(void 0, {
142
+ endpoint: c,
143
+ method: f,
144
+ status: _.status
145
+ }),
146
+ warnings: []
147
+ };
148
+ let y;
149
+ try {
150
+ y = JSON.parse(v);
151
+ } catch (e) {
152
+ throw new i("Liknoss response could not be parsed as JSON.", {
153
+ cause: e,
154
+ endpoint: c,
155
+ method: f,
156
+ rawBody: v,
157
+ status: _.status
158
+ });
159
+ }
160
+ let b = l(y), x = u(y, {
161
+ endpoint: c,
162
+ method: f,
163
+ status: _.status
164
+ });
165
+ if (ee(y)) throw new a(x.message ?? "Liknoss reported a severe API error.", {
166
+ issues: b,
167
+ meta: x,
168
+ payload: y
169
+ });
170
+ return {
171
+ data: y,
172
+ meta: x,
173
+ warnings: b
174
+ };
175
+ } };
176
+ }
177
+ //#endregion
178
+ //#region src/core/methods.ts
179
+ function _(e, t) {
180
+ return (n) => e.request({
181
+ ...n ?? {},
182
+ method: "GET",
183
+ path: t
184
+ });
185
+ }
186
+ function v(e, t) {
187
+ return (n) => e.request({
188
+ ...n,
189
+ method: "POST",
190
+ path: t
191
+ });
192
+ }
193
+ //#endregion
194
+ //#region src/services/accommodation.ts
195
+ var y = "/web-services/v200/b2c/accommodation-plan", b = "/web-services/v200/b2c/lock-accommodation-space", x = "/web-services/v200/b2c/unlock-accommodation-space";
196
+ function S(e) {
197
+ return {
198
+ getAccommodationPlan: v(e, y),
199
+ lockAccommodationSpace: v(e, b),
200
+ unlockAccommodationSpace: v(e, x)
201
+ };
202
+ }
203
+ //#endregion
204
+ //#region src/services/booking.ts
205
+ var te = "/web-services/v200/b2c/booking", C = "/web-services/v200/b2c/booking-identifier", w = "/web-services/v200/b2c/cancellation/{crs_reservation_id}", T = "/web-services/v200/b2c/cancel-multi-booking/{crs_reservation_id}", E = "/web-services/v200/b2c/confirm-payment", D = "/web-services/v200/b2c/generate-voucher/{crs_reservation_id}", O = "/web-services/v200/b2c/multi-booking", k = "/web-services/v200/b2c/multi-pricing", A = "/web-services/v200/b2c/pricing", j = "/web-services/v200/b2c/retrieve-booking-leader/{crs_reservation_id}";
206
+ function M(e) {
207
+ return {
208
+ cancelBooking: _(e, w),
209
+ cancelMultiBooking: _(e, T),
210
+ confirmPayment: v(e, E),
211
+ createBooking: v(e, te),
212
+ createBookingIdentifier: v(e, C),
213
+ createMultiBooking: v(e, O),
214
+ generateVoucher: _(e, D),
215
+ getBookingLeader: _(e, j),
216
+ getMultiPricing: v(e, k),
217
+ getPricing: v(e, A)
218
+ };
219
+ }
220
+ //#endregion
221
+ //#region src/services/catalog.ts
222
+ var N = "/web-services/v200/b2c/analytic-routes", P = "/web-services/v200/b2c/companies", F = "/web-services/v200/b2c/financial-data/{company_abbreviation}", I = "/web-services/v200/b2c/company-redirection", L = "/web-services/v200/b2c/countries", R = "/web-services/v200/b2c/locations", ne = "/web-services/v200/b2c/locations-with-filter", z = "/web-services/v200/b2c/resident-static-data", B = "/web-services/v200/b2c/routes", V = "/web-services/v200/b2c/routes-with-filter", H = "/web-services/v200/b2c/session";
223
+ function U(e) {
224
+ return {
225
+ filterLocations: _(e, ne),
226
+ filterRoutes: _(e, V),
227
+ getCompanyFinancialData: _(e, F),
228
+ getCompanyRedirection: _(e, I),
229
+ getResidentStaticData: _(e, z),
230
+ getSession: _(e, H),
231
+ listAnalyticRoutes: _(e, N),
232
+ listCompanies: _(e, P),
233
+ listCountries: _(e, L),
234
+ listLocations: _(e, R),
235
+ listRoutes: _(e, B)
236
+ };
237
+ }
238
+ //#endregion
239
+ //#region src/services/insurance.ts
240
+ var W = "/web-services/v200/b2c/insurance-offer", G = "/web-services/v200/b2c/insurance-retrieve";
241
+ function K(e) {
242
+ return {
243
+ getInsuranceOffer: v(e, W),
244
+ retrieveInsurance: v(e, G)
245
+ };
246
+ }
247
+ //#endregion
248
+ //#region src/services/trips.ts
249
+ var q = "/web-services/v200/b2c/availability", J = "/web-services/v200/b2c/route-frequency", Y = "/web-services/v200/b2c/simple-trips", X = "/web-services/v200/b2c/trips", Z = "/web-services/v200/b2c/trips-per-day", re = "/web-services/v200/b2c/trips-with-conjunction", ie = "/web-services/v200/b2c/list-of-trips";
250
+ function Q(e) {
251
+ return {
252
+ getAvailability: v(e, q),
253
+ getRouteFrequencies: v(e, J),
254
+ listTrips: v(e, ie),
255
+ searchSimpleTrips: v(e, Y),
256
+ searchTrips: v(e, X),
257
+ searchTripsPerDay: v(e, Z),
258
+ searchTripsWithConjunction: v(e, re)
259
+ };
260
+ }
261
+ //#endregion
262
+ //#region src/services/validation.ts
263
+ var ae = "/web-services/v200/b2c/validate-loyalty-data", oe = "/web-services/v200/b2c/validate-resident-data";
264
+ function $(e) {
265
+ return {
266
+ validateLoyaltyData: v(e, ae),
267
+ validateResidentData: v(e, oe)
268
+ };
269
+ }
270
+ //#endregion
271
+ //#region src/client.ts
272
+ function se(e = {}) {
273
+ let t = g(e);
274
+ return {
275
+ accommodation: S(t),
276
+ booking: M(t),
277
+ catalog: U(t),
278
+ insurance: K(t),
279
+ transport: t,
280
+ trips: Q(t),
281
+ validation: $(t)
282
+ };
283
+ }
284
+ //#endregion
285
+ export { a as LiknossApiError, t as LiknossConfigurationError, e as LiknossError, r as LiknossHttpError, n as LiknossNetworkError, i as LiknossResponseParseError, S as createAccommodationService, M as createBookingService, U as createCatalogService, K as createInsuranceService, se as createLiknossClient, Q as createTripService, $ as createValidationService };
@@ -0,0 +1,7 @@
1
+ import type { LiknossTransport } from "../core/types";
2
+ export declare function createAccommodationService(transport: LiknossTransport): {
3
+ getAccommodationPlan: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/accommodation-plan">;
4
+ lockAccommodationSpace: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/lock-accommodation-space">;
5
+ unlockAccommodationSpace: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/unlock-accommodation-space">;
6
+ };
7
+ export type LiknossAccommodationService = ReturnType<typeof createAccommodationService>;
@@ -0,0 +1,14 @@
1
+ import type { LiknossTransport } from "../core/types";
2
+ export declare function createBookingService(transport: LiknossTransport): {
3
+ cancelBooking: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/cancellation/{crs_reservation_id}">;
4
+ cancelMultiBooking: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/cancel-multi-booking/{crs_reservation_id}">;
5
+ confirmPayment: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/confirm-payment">;
6
+ createBooking: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/booking">;
7
+ createBookingIdentifier: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/booking-identifier">;
8
+ createMultiBooking: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/multi-booking">;
9
+ generateVoucher: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/generate-voucher/{crs_reservation_id}">;
10
+ getBookingLeader: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/retrieve-booking-leader/{crs_reservation_id}">;
11
+ getMultiPricing: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/multi-pricing">;
12
+ getPricing: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/pricing">;
13
+ };
14
+ export type LiknossBookingService = ReturnType<typeof createBookingService>;
@@ -0,0 +1,15 @@
1
+ import type { LiknossTransport } from "../core/types";
2
+ export declare function createCatalogService(transport: LiknossTransport): {
3
+ filterLocations: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/locations-with-filter">;
4
+ filterRoutes: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/routes-with-filter">;
5
+ getCompanyFinancialData: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/financial-data/{company_abbreviation}">;
6
+ getCompanyRedirection: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/company-redirection">;
7
+ getResidentStaticData: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/resident-static-data">;
8
+ getSession: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/session">;
9
+ listAnalyticRoutes: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/analytic-routes">;
10
+ listCompanies: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/companies">;
11
+ listCountries: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/countries">;
12
+ listLocations: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/locations">;
13
+ listRoutes: import("../core/types").LiknossGetMethod<"/web-services/v200/b2c/routes">;
14
+ };
15
+ export type LiknossCatalogService = ReturnType<typeof createCatalogService>;
@@ -0,0 +1,12 @@
1
+ export { createAccommodationService } from "./accommodation";
2
+ export { createBookingService } from "./booking";
3
+ export { createCatalogService } from "./catalog";
4
+ export { createInsuranceService } from "./insurance";
5
+ export { createTripService } from "./trips";
6
+ export { createValidationService } from "./validation";
7
+ export type { LiknossAccommodationService } from "./accommodation";
8
+ export type { LiknossBookingService } from "./booking";
9
+ export type { LiknossCatalogService } from "./catalog";
10
+ export type { LiknossInsuranceService } from "./insurance";
11
+ export type { LiknossTripService } from "./trips";
12
+ export type { LiknossValidationService } from "./validation";
@@ -0,0 +1,6 @@
1
+ import type { LiknossTransport } from "../core/types";
2
+ export declare function createInsuranceService(transport: LiknossTransport): {
3
+ getInsuranceOffer: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/insurance-offer">;
4
+ retrieveInsurance: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/insurance-retrieve">;
5
+ };
6
+ export type LiknossInsuranceService = ReturnType<typeof createInsuranceService>;
@@ -0,0 +1,11 @@
1
+ import type { LiknossTransport } from "../core/types";
2
+ export declare function createTripService(transport: LiknossTransport): {
3
+ getAvailability: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/availability">;
4
+ getRouteFrequencies: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/route-frequency">;
5
+ listTrips: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/list-of-trips">;
6
+ searchSimpleTrips: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/simple-trips">;
7
+ searchTrips: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/trips">;
8
+ searchTripsPerDay: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/trips-per-day">;
9
+ searchTripsWithConjunction: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/trips-with-conjunction">;
10
+ };
11
+ export type LiknossTripService = ReturnType<typeof createTripService>;
@@ -0,0 +1,6 @@
1
+ import type { LiknossTransport } from "../core/types";
2
+ export declare function createValidationService(transport: LiknossTransport): {
3
+ validateLoyaltyData: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/validate-loyalty-data">;
4
+ validateResidentData: import("../core/types").LiknossPostMethod<"/web-services/v200/b2c/validate-resident-data">;
5
+ };
6
+ export type LiknossValidationService = ReturnType<typeof createValidationService>;
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@ferryrsvp/liknoss-client",
3
+ "version": "1.0.3",
4
+ "description": "Typed Liknoss B2C client for Ferry RSVP services and workers.",
5
+ "main": "build/liknoss-client/index.mjs",
6
+ "module": "build/liknoss-client/index.mjs",
7
+ "types": "build/liknoss-client/index.d.ts",
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "files": [
11
+ "README.md",
12
+ "build/liknoss-client"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "import": "./build/liknoss-client/index.mjs",
17
+ "types": "./build/liknoss-client/index.d.ts"
18
+ },
19
+ "./client": {
20
+ "import": "./build/liknoss-client/client.mjs",
21
+ "types": "./build/liknoss-client/client.d.ts"
22
+ },
23
+ "./services/*": {
24
+ "import": "./build/liknoss-client/services/*.mjs",
25
+ "types": "./build/liknoss-client/services/*.d.ts"
26
+ }
27
+ },
28
+ "scripts": {
29
+ "copy_html": "cp ./node_modules/@ferryrsvp/web-tools/build/templates/static/index.html ./index.html",
30
+ "copy_ssl": "cp -r ./node_modules/@ferryrsvp/web-tools/build/templates/ssl ./",
31
+ "copy_github_workflows": "cp -r ./node_modules/@ferryrsvp/web-tools/build/templates/github_workflows/.github ./",
32
+ "copy_ts_configs": "cp -r ./node_modules/@ferryrsvp/web-tools/build/templates/ts_configs/* ./",
33
+ "copy_local_dev": "cp -r ./node_modules/@ferryrsvp/web-tools/build/templates/local-dev ./",
34
+ "setup": "npm run copy_html && npm run copy_local_dev && npm run copy_ssl && npm run copy_github_workflows && npm run copy_ts_configs",
35
+ "generate:spec": "curl -L https://devsrv.liknoss.com/cws/b2c/swagger.json -o openapi/swagger.json && npx swagger2openapi openapi/swagger.json -o openapi/openapi.json",
36
+ "generate:types": "npx openapi-typescript openapi/openapi.json -o src/generated/openapi.ts",
37
+ "build:types": "tsc -p tsconfig.build.json",
38
+ "dev": "vite",
39
+ "build": "npm run generate:types && vite build && npm run build:types",
40
+ "prepublishOnly": "npm run build",
41
+ "watch": "vite build --watch",
42
+ "clean": "rm -rf node_modules package-lock.json index.html tsconfig.dev.json ssl .github local-dev build",
43
+ "deploy": "npx r2-deploy ferry-assets"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "provenance": false,
48
+ "registry": "https://registry.npmjs.org/"
49
+ },
50
+ "keywords": [
51
+ "liknoss",
52
+ "ferry",
53
+ "typescript",
54
+ "api-client",
55
+ "workers"
56
+ ],
57
+ "devDependencies": {
58
+ "@ferryrsvp/web-tools": "latest",
59
+ "@types/node": "^24.0.4",
60
+ "@types/react": "^19.1.8",
61
+ "@types/react-dom": "^19.1.6",
62
+ "openapi-typescript": "^7.13.0",
63
+ "swagger2openapi": "^7.0.8",
64
+ "typescript": "^5.8.3",
65
+ "vite": "latest",
66
+ "vite-plugin-checker": "^0.9.3",
67
+ "vite-plugin-externalize-dependencies": "latest",
68
+ "vite-plugin-html": "^3.2.2",
69
+ "vite-plugin-js-importmap-script": "^1.0.0",
70
+ "wrangler": "^4.10.0"
71
+ },
72
+ "repository": {
73
+ "type": "git",
74
+ "url": "git+ssh://git@github.com/FERRY-RSVP/liknoss-client.git"
75
+ },
76
+ "author": "Angelo",
77
+ "license": "ISC",
78
+ "bugs": {
79
+ "url": "https://github.com/FERRY-RSVP/liknoss-client/issues"
80
+ },
81
+ "homepage": "https://github.com/FERRY-RSVP/liknoss-client#readme"
82
+ }