@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.
- package/README.md +39 -0
- package/build/liknoss-client/client.d.ts +52 -0
- package/build/liknoss-client/core/errors.d.ts +59 -0
- package/build/liknoss-client/core/methods.d.ts +4 -0
- package/build/liknoss-client/core/normalize.d.ts +9 -0
- package/build/liknoss-client/core/openapi.d.ts +61 -0
- package/build/liknoss-client/core/request.d.ts +2 -0
- package/build/liknoss-client/core/types.d.ts +66 -0
- package/build/liknoss-client/generated/openapi.d.ts +3085 -0
- package/build/liknoss-client/index.d.ts +7 -0
- package/build/liknoss-client/index.mjs +285 -0
- package/build/liknoss-client/services/accommodation.d.ts +7 -0
- package/build/liknoss-client/services/booking.d.ts +14 -0
- package/build/liknoss-client/services/catalog.d.ts +15 -0
- package/build/liknoss-client/services/index.d.ts +12 -0
- package/build/liknoss-client/services/insurance.d.ts +6 -0
- package/build/liknoss-client/services/trips.d.ts +11 -0
- package/build/liknoss-client/services/validation.d.ts +6 -0
- package/package.json +82 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @ferryrsvp/liknoss-client
|
|
2
|
+
|
|
3
|
+
Typed Liknoss B2C client for Ferry RSVP services and workers.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ferryrsvp/liknoss-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createLiknossClient } from "@ferryrsvp/liknoss-client";
|
|
15
|
+
|
|
16
|
+
const client = createLiknossClient({
|
|
17
|
+
baseUrl: "https://example.com/b2c",
|
|
18
|
+
fetch,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const countries = await client.catalog.listCountries();
|
|
22
|
+
const locations = await client.catalog.listLocations();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Notes
|
|
26
|
+
|
|
27
|
+
- The client ships ESM output and TypeScript declarations.
|
|
28
|
+
- For server-side Ferry RSVP usage, prefer passing `defaultHeaders` or a custom `fetch` implementation when upstream authentication headers must be injected.
|
|
29
|
+
- OpenAPI generation lives in the repository build flow; consumers only need the published build artifacts.
|
|
30
|
+
|
|
31
|
+
## Publishing
|
|
32
|
+
|
|
33
|
+
This package is configured for public npm publishing.
|
|
34
|
+
|
|
35
|
+
- `npm run build`
|
|
36
|
+
- `npm publish`
|
|
37
|
+
|
|
38
|
+
For GitHub Actions publishing, provide an `NPM_TOKEN` repository secret.
|
|
39
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { LiknossClientOptions } from "./core/types";
|
|
2
|
+
export declare function createLiknossClient(options?: LiknossClientOptions): {
|
|
3
|
+
accommodation: {
|
|
4
|
+
getAccommodationPlan: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/accommodation-plan">;
|
|
5
|
+
lockAccommodationSpace: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/lock-accommodation-space">;
|
|
6
|
+
unlockAccommodationSpace: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/unlock-accommodation-space">;
|
|
7
|
+
};
|
|
8
|
+
booking: {
|
|
9
|
+
cancelBooking: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/cancellation/{crs_reservation_id}">;
|
|
10
|
+
cancelMultiBooking: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/cancel-multi-booking/{crs_reservation_id}">;
|
|
11
|
+
confirmPayment: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/confirm-payment">;
|
|
12
|
+
createBooking: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/booking">;
|
|
13
|
+
createBookingIdentifier: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/booking-identifier">;
|
|
14
|
+
createMultiBooking: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/multi-booking">;
|
|
15
|
+
generateVoucher: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/generate-voucher/{crs_reservation_id}">;
|
|
16
|
+
getBookingLeader: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/retrieve-booking-leader/{crs_reservation_id}">;
|
|
17
|
+
getMultiPricing: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/multi-pricing">;
|
|
18
|
+
getPricing: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/pricing">;
|
|
19
|
+
};
|
|
20
|
+
catalog: {
|
|
21
|
+
filterLocations: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/locations-with-filter">;
|
|
22
|
+
filterRoutes: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/routes-with-filter">;
|
|
23
|
+
getCompanyFinancialData: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/financial-data/{company_abbreviation}">;
|
|
24
|
+
getCompanyRedirection: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/company-redirection">;
|
|
25
|
+
getResidentStaticData: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/resident-static-data">;
|
|
26
|
+
getSession: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/session">;
|
|
27
|
+
listAnalyticRoutes: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/analytic-routes">;
|
|
28
|
+
listCompanies: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/companies">;
|
|
29
|
+
listCountries: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/countries">;
|
|
30
|
+
listLocations: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/locations">;
|
|
31
|
+
listRoutes: import("./core/types").LiknossGetMethod<"/web-services/v200/b2c/routes">;
|
|
32
|
+
};
|
|
33
|
+
insurance: {
|
|
34
|
+
getInsuranceOffer: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/insurance-offer">;
|
|
35
|
+
retrieveInsurance: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/insurance-retrieve">;
|
|
36
|
+
};
|
|
37
|
+
transport: import("./core/types").LiknossTransport;
|
|
38
|
+
trips: {
|
|
39
|
+
getAvailability: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/availability">;
|
|
40
|
+
getRouteFrequencies: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/route-frequency">;
|
|
41
|
+
listTrips: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/list-of-trips">;
|
|
42
|
+
searchSimpleTrips: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/simple-trips">;
|
|
43
|
+
searchTrips: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/trips">;
|
|
44
|
+
searchTripsPerDay: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/trips-per-day">;
|
|
45
|
+
searchTripsWithConjunction: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/trips-with-conjunction">;
|
|
46
|
+
};
|
|
47
|
+
validation: {
|
|
48
|
+
validateLoyaltyData: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/validate-loyalty-data">;
|
|
49
|
+
validateResidentData: import("./core/types").LiknossPostMethod<"/web-services/v200/b2c/validate-resident-data">;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export type LiknossClient = ReturnType<typeof createLiknossClient>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { LiknossResponseMeta, LiknossWarning } from "./types";
|
|
2
|
+
interface LiknossErrorOptions {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
code?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class LiknossError extends Error {
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
readonly code?: string;
|
|
9
|
+
constructor(message: string, options?: LiknossErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
export declare class LiknossConfigurationError extends LiknossError {
|
|
12
|
+
}
|
|
13
|
+
export declare class LiknossNetworkError extends LiknossError {
|
|
14
|
+
readonly endpoint: string;
|
|
15
|
+
readonly method: string;
|
|
16
|
+
constructor(message: string, details: {
|
|
17
|
+
cause?: unknown;
|
|
18
|
+
endpoint: string;
|
|
19
|
+
method: string;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export declare class LiknossHttpError extends LiknossError {
|
|
23
|
+
readonly endpoint: string;
|
|
24
|
+
readonly method: string;
|
|
25
|
+
readonly responseBody?: string;
|
|
26
|
+
readonly status: number;
|
|
27
|
+
readonly statusText: string;
|
|
28
|
+
constructor(message: string, details: {
|
|
29
|
+
endpoint: string;
|
|
30
|
+
method: string;
|
|
31
|
+
responseBody?: string;
|
|
32
|
+
status: number;
|
|
33
|
+
statusText: string;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export declare class LiknossResponseParseError extends LiknossError {
|
|
37
|
+
readonly endpoint: string;
|
|
38
|
+
readonly method: string;
|
|
39
|
+
readonly rawBody: string;
|
|
40
|
+
readonly status: number;
|
|
41
|
+
constructor(message: string, details: {
|
|
42
|
+
cause?: unknown;
|
|
43
|
+
endpoint: string;
|
|
44
|
+
method: string;
|
|
45
|
+
rawBody: string;
|
|
46
|
+
status: number;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export declare class LiknossApiError<TPayload = unknown> extends LiknossError {
|
|
50
|
+
readonly issues: LiknossWarning[];
|
|
51
|
+
readonly meta: LiknossResponseMeta;
|
|
52
|
+
readonly payload: TPayload;
|
|
53
|
+
constructor(message: string, details: {
|
|
54
|
+
issues: LiknossWarning[];
|
|
55
|
+
meta: LiknossResponseMeta;
|
|
56
|
+
payload: TPayload;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PathsWithMethod } from "./openapi";
|
|
2
|
+
import type { LiknossGetMethod, LiknossPostMethod, LiknossTransport } from "./types";
|
|
3
|
+
export declare function createGetMethod<Path extends PathsWithMethod<"get">>(transport: LiknossTransport, path: Path): LiknossGetMethod<Path>;
|
|
4
|
+
export declare function createPostMethod<Path extends PathsWithMethod<"post">>(transport: LiknossTransport, path: Path): LiknossPostMethod<Path>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LiknossApiPayloadShape, LiknossResponseMeta, LiknossWarning } from "./types";
|
|
2
|
+
export declare function isLiknossApiPayload(value: unknown): value is LiknossApiPayloadShape;
|
|
3
|
+
export declare function hasSevereLiknossApiError(value: unknown): boolean;
|
|
4
|
+
export declare function normalizeLiknossWarnings(value: unknown): LiknossWarning[];
|
|
5
|
+
export declare function createLiknossResponseMeta(value: unknown, details: {
|
|
6
|
+
endpoint: string;
|
|
7
|
+
method: string;
|
|
8
|
+
status: number;
|
|
9
|
+
}): LiknossResponseMeta;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { paths } from "../generated/openapi";
|
|
2
|
+
export type LiknossHttpMethod = "get" | "post";
|
|
3
|
+
export type PathsWithMethod<Method extends LiknossHttpMethod> = {
|
|
4
|
+
[Path in keyof paths]: Method extends keyof paths[Path] ? paths[Path][Method] extends undefined ? never : Path : never;
|
|
5
|
+
}[keyof paths];
|
|
6
|
+
export type OperationAt<Path extends PathsWithMethod<Method>, Method extends LiknossHttpMethod> = NonNullable<paths[Path][Method]>;
|
|
7
|
+
type ParametersOf<Operation> = Operation extends {
|
|
8
|
+
parameters: infer Parameters;
|
|
9
|
+
} ? Parameters : never;
|
|
10
|
+
export type QueryOf<Operation> = ParametersOf<Operation> extends {
|
|
11
|
+
query?: infer Query;
|
|
12
|
+
} ? Query : never;
|
|
13
|
+
export type PathParamsOf<Operation> = ParametersOf<Operation> extends {
|
|
14
|
+
path?: infer PathParams;
|
|
15
|
+
} ? PathParams : never;
|
|
16
|
+
export type JsonBodyOf<Operation> = Operation extends {
|
|
17
|
+
requestBody: {
|
|
18
|
+
content: {
|
|
19
|
+
"application/json": infer Body;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
} ? Body : Operation extends {
|
|
23
|
+
requestBody?: {
|
|
24
|
+
content: {
|
|
25
|
+
"application/json": infer Body;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
} ? Body : never;
|
|
29
|
+
export type BodyArgOf<Operation> = [JsonBodyOf<Operation>] extends [never] ? {
|
|
30
|
+
body?: never;
|
|
31
|
+
} : Operation extends {
|
|
32
|
+
requestBody: {
|
|
33
|
+
content: {
|
|
34
|
+
"application/json": infer Body;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
} ? {
|
|
38
|
+
body: Body;
|
|
39
|
+
} : Operation extends {
|
|
40
|
+
requestBody?: {
|
|
41
|
+
content: {
|
|
42
|
+
"application/json": infer Body;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
} ? {
|
|
46
|
+
body?: Body;
|
|
47
|
+
} : {
|
|
48
|
+
body?: never;
|
|
49
|
+
};
|
|
50
|
+
type ResponseBodyOf<Response> = Response extends {
|
|
51
|
+
content: {
|
|
52
|
+
"application/json": infer Body;
|
|
53
|
+
};
|
|
54
|
+
} ? Body : never;
|
|
55
|
+
type ResponsesOf<Operation> = Operation extends {
|
|
56
|
+
responses: infer Responses;
|
|
57
|
+
} ? Responses : never;
|
|
58
|
+
export type SuccessBodyOf<Operation> = ResponsesOf<Operation> extends {
|
|
59
|
+
200: infer Success;
|
|
60
|
+
} ? ResponseBodyOf<Success> : never;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { components } from "../generated/openapi";
|
|
2
|
+
import type { BodyArgOf, LiknossHttpMethod, OperationAt, PathParamsOf, PathsWithMethod, QueryOf, SuccessBodyOf } from "./openapi";
|
|
3
|
+
export type LiknossApiErrorDetail = components["schemas"]["ErrorDetail"];
|
|
4
|
+
export type LiknossBookingStatus = components["schemas"]["BookingStatusPerCompany"];
|
|
5
|
+
export interface LiknossClientOptions {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
defaultHeaders?: HeadersInit;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export interface LiknossRequestOptions {
|
|
12
|
+
headers?: HeadersInit;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
export interface LiknossWarning {
|
|
16
|
+
code?: string;
|
|
17
|
+
company?: string;
|
|
18
|
+
description: string;
|
|
19
|
+
severity?: string;
|
|
20
|
+
source: "bookingStatus" | "perCompanyErrorDetails";
|
|
21
|
+
}
|
|
22
|
+
export interface LiknossResponseMeta {
|
|
23
|
+
abbreviation?: string;
|
|
24
|
+
code?: string;
|
|
25
|
+
endpoint: string;
|
|
26
|
+
message?: string;
|
|
27
|
+
method: Uppercase<LiknossHttpMethod>;
|
|
28
|
+
requestId?: string;
|
|
29
|
+
responseCode?: string;
|
|
30
|
+
responseDescription?: string;
|
|
31
|
+
status: number;
|
|
32
|
+
}
|
|
33
|
+
export interface LiknossResult<TData> {
|
|
34
|
+
data: TData;
|
|
35
|
+
meta: LiknossResponseMeta;
|
|
36
|
+
warnings: LiknossWarning[];
|
|
37
|
+
}
|
|
38
|
+
export interface LiknossApiPayloadShape {
|
|
39
|
+
abbreviation?: string;
|
|
40
|
+
bookingStatusesPerCompany?: LiknossBookingStatus[];
|
|
41
|
+
code?: string;
|
|
42
|
+
message?: string;
|
|
43
|
+
perCompanyErrorDetails?: Record<string, LiknossApiErrorDetail[]>;
|
|
44
|
+
requestId?: string;
|
|
45
|
+
responseCode?: string;
|
|
46
|
+
responseDesciption?: string;
|
|
47
|
+
severeError?: boolean;
|
|
48
|
+
}
|
|
49
|
+
type BaseMethodArgs<Path extends PathsWithMethod<Method>, Method extends LiknossHttpMethod> = LiknossRequestOptions & BodyArgOf<OperationAt<Path, Method>> & {
|
|
50
|
+
pathParams?: PathParamsOf<OperationAt<Path, Method>>;
|
|
51
|
+
query?: QueryOf<OperationAt<Path, Method>>;
|
|
52
|
+
};
|
|
53
|
+
export type LiknossMethodArgs<Path extends PathsWithMethod<Method>, Method extends LiknossHttpMethod> = BaseMethodArgs<Path, Method>;
|
|
54
|
+
export interface LiknossRequestConfig<Path extends PathsWithMethod<Method>, Method extends LiknossHttpMethod> extends LiknossRequestOptions {
|
|
55
|
+
body?: BodyArgOf<OperationAt<Path, Method>>["body"];
|
|
56
|
+
method: Uppercase<Method>;
|
|
57
|
+
path: Path;
|
|
58
|
+
pathParams?: PathParamsOf<OperationAt<Path, Method>>;
|
|
59
|
+
query?: QueryOf<OperationAt<Path, Method>>;
|
|
60
|
+
}
|
|
61
|
+
export interface LiknossTransport {
|
|
62
|
+
request<Path extends PathsWithMethod<Method>, Method extends LiknossHttpMethod>(config: LiknossRequestConfig<Path, Method>): Promise<LiknossResult<SuccessBodyOf<OperationAt<Path, Method>>>>;
|
|
63
|
+
}
|
|
64
|
+
export type LiknossGetMethod<Path extends PathsWithMethod<"get">> = (config?: LiknossMethodArgs<Path, "get">) => Promise<LiknossResult<SuccessBodyOf<OperationAt<Path, "get">>>>;
|
|
65
|
+
export type LiknossPostMethod<Path extends PathsWithMethod<"post">> = (config: LiknossMethodArgs<Path, "post">) => Promise<LiknossResult<SuccessBodyOf<OperationAt<Path, "post">>>>;
|
|
66
|
+
export {};
|