@vrplatform/api 1.2.33 → 1.2.34
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/build/main/client.d.ts +1 -1
- package/build/main/client.js +1 -1
- package/build/main/client.js.map +1 -1
- package/build/main/error.js +1 -1
- package/build/main/error.js.map +1 -1
- package/build/main/generated/openapi-fetch.d.ts +1 -1
- package/build/main/generated/openapi-fetch.js.map +1 -1
- package/build/main/generated/v1.d.ts +10139 -9185
- package/build/main/generated/v1.js.map +1 -1
- package/build/main/index.d.ts +4 -3
- package/build/main/index.js +0 -3
- package/build/main/index.js.map +1 -1
- package/build/main/ingest/index.d.ts +0 -2
- package/build/main/ingest/index.js.map +1 -1
- package/build/main/ingest/types.d.ts +1 -1
- package/build/main/ingest/types.js.map +1 -1
- package/build/main/ingest-compat/index.d.ts +0 -1
- package/build/main/ingest-compat/index.js.map +1 -1
- package/build/main/ingest-compat/types.d.ts +0 -1
- package/build/main/ingest-compat/types.js.map +1 -1
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/types.d.ts +0 -1
- package/build/main/types.js.map +1 -1
- package/build/module/client.d.ts +1 -1
- package/build/module/client.js +1 -1
- package/build/module/client.js.map +1 -1
- package/build/module/error.js +1 -1
- package/build/module/error.js.map +1 -1
- package/build/module/generated/openapi-fetch.d.ts +1 -1
- package/build/module/generated/openapi-fetch.js.map +1 -1
- package/build/module/generated/v1.d.ts +10139 -9185
- package/build/module/generated/v1.js.map +1 -1
- package/build/module/index.d.ts +4 -3
- package/build/module/index.js +0 -3
- package/build/module/index.js.map +1 -1
- package/build/module/ingest/index.d.ts +0 -2
- package/build/module/ingest/index.js.map +1 -1
- package/build/module/ingest/types.d.ts +1 -1
- package/build/module/ingest/types.js.map +1 -1
- package/build/module/ingest-compat/index.d.ts +0 -1
- package/build/module/ingest-compat/index.js.map +1 -1
- package/build/module/ingest-compat/types.d.ts +0 -1
- package/build/module/ingest-compat/types.js.map +1 -1
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/types.d.ts +0 -1
- package/build/module/types.js.map +1 -1
- package/package.json +14 -8
- package/src/client.ts +4 -1
- package/src/error.ts +1 -1
- package/src/generated/openapi-fetch.ts +1 -1
- package/src/generated/v1.ts +10139 -9185
- package/src/index.ts +6 -4
- package/src/ingest/index.ts +0 -4
- package/src/ingest/types.ts +1 -1
- package/src/types.ts +0 -1
- package/build/main/fetcher.d.ts +0 -18
- package/build/main/fetcher.js +0 -68
- package/build/main/fetcher.js.map +0 -1
- package/build/main/headers.d.ts +0 -18
- package/build/main/headers.js +0 -25
- package/build/main/headers.js.map +0 -1
- package/build/main/middlewares/curl.d.ts +0 -6
- package/build/main/middlewares/curl.js +0 -20
- package/build/main/middlewares/curl.js.map +0 -1
- package/build/main/middlewares/index.d.ts +0 -1
- package/build/main/middlewares/index.js +0 -18
- package/build/main/middlewares/index.js.map +0 -1
- package/build/main/retryable-errors.d.ts +0 -9
- package/build/main/retryable-errors.js +0 -38
- package/build/main/retryable-errors.js.map +0 -1
- package/build/module/fetcher.d.ts +0 -18
- package/build/module/fetcher.js +0 -63
- package/build/module/fetcher.js.map +0 -1
- package/build/module/headers.d.ts +0 -18
- package/build/module/headers.js +0 -23
- package/build/module/headers.js.map +0 -1
- package/build/module/middlewares/curl.d.ts +0 -6
- package/build/module/middlewares/curl.js +0 -16
- package/build/module/middlewares/curl.js.map +0 -1
- package/build/module/middlewares/index.d.ts +0 -1
- package/build/module/middlewares/index.js +0 -2
- package/build/module/middlewares/index.js.map +0 -1
- package/build/module/retryable-errors.d.ts +0 -9
- package/build/module/retryable-errors.js +0 -34
- package/build/module/retryable-errors.js.map +0 -1
- package/src/ingest-compat/index.ts +0 -99
- package/src/ingest-compat/map.ts +0 -111
- package/src/ingest-compat/types.ts +0 -11
- package/src/middlewares/curl.ts +0 -23
- package/src/middlewares/index.ts +0 -1
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IngestArg,
|
|
3
|
-
type IngestFnArg,
|
|
4
|
-
type PartialBy,
|
|
5
|
-
type Source,
|
|
6
|
-
usePostSources,
|
|
7
|
-
} from '../ingest';
|
|
8
|
-
import type { ApiClient } from '../types';
|
|
9
|
-
import { mapTransform } from './map';
|
|
10
|
-
import type { ListingInput, PaymentInput, ReservationInput } from './types';
|
|
11
|
-
|
|
12
|
-
export * from './map';
|
|
13
|
-
export * from './types';
|
|
14
|
-
|
|
15
|
-
export type ApiIngestCompat = ReturnType<typeof useIngestCompat>;
|
|
16
|
-
export function useIngestCompat(api: ApiClient, config: IngestArg) {
|
|
17
|
-
const post = usePostSources(api, config);
|
|
18
|
-
return {
|
|
19
|
-
api,
|
|
20
|
-
get sessionId() {
|
|
21
|
-
return api.sessionId;
|
|
22
|
-
},
|
|
23
|
-
async sources(changes: Source[], configOverwrites?: IngestFnArg) {
|
|
24
|
-
if (!changes.length) return undefined;
|
|
25
|
-
return await post(changes, configOverwrites);
|
|
26
|
-
},
|
|
27
|
-
async reservations(
|
|
28
|
-
changes: PartialBy<Source<ReservationInput>, 'type'>[],
|
|
29
|
-
configOverwrites?: IngestFnArg
|
|
30
|
-
) {
|
|
31
|
-
if (!changes.length) return [];
|
|
32
|
-
return await post<ReservationInput>(
|
|
33
|
-
changes.map(({ transform, ...source }) => {
|
|
34
|
-
const data = mapTransform.reservation(transform.data);
|
|
35
|
-
return {
|
|
36
|
-
...source,
|
|
37
|
-
type: source.type || 'reservation',
|
|
38
|
-
description: source.description || data.confirmationCode,
|
|
39
|
-
uniqueRef: source.uniqueRef || data.uniqueRef!,
|
|
40
|
-
date: source.date || data.bookedAt,
|
|
41
|
-
status: source.status || 'active',
|
|
42
|
-
transform: {
|
|
43
|
-
data,
|
|
44
|
-
type: 'reservation',
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}),
|
|
48
|
-
configOverwrites
|
|
49
|
-
);
|
|
50
|
-
},
|
|
51
|
-
async payments(
|
|
52
|
-
changes: PartialBy<Source<PaymentInput>, 'type'>[],
|
|
53
|
-
configOverwrites?: IngestFnArg
|
|
54
|
-
) {
|
|
55
|
-
if (!changes.length) return undefined;
|
|
56
|
-
return await post<PaymentInput>(
|
|
57
|
-
changes.map(({ transform, ...source }) => {
|
|
58
|
-
const data = mapTransform.payment(transform.data);
|
|
59
|
-
return {
|
|
60
|
-
...source,
|
|
61
|
-
type: source.type || 'payment',
|
|
62
|
-
description: source.description || data.description,
|
|
63
|
-
uniqueRef: source.uniqueRef || data.uniqueRef!,
|
|
64
|
-
date: source.date || data.paidAt,
|
|
65
|
-
status: source.status || 'active',
|
|
66
|
-
transform: {
|
|
67
|
-
data,
|
|
68
|
-
type: 'payment',
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}),
|
|
72
|
-
configOverwrites
|
|
73
|
-
);
|
|
74
|
-
},
|
|
75
|
-
async listings(
|
|
76
|
-
changes: PartialBy<Source<ListingInput>, 'type'>[],
|
|
77
|
-
configOverwrites?: IngestFnArg
|
|
78
|
-
) {
|
|
79
|
-
if (!changes.length) return undefined;
|
|
80
|
-
return await post<ListingInput>(
|
|
81
|
-
changes.map(({ transform, ...source }) => {
|
|
82
|
-
const data = mapTransform.listing(transform.data);
|
|
83
|
-
return {
|
|
84
|
-
...source,
|
|
85
|
-
type: source.type || 'listing',
|
|
86
|
-
description: source.description || data.name,
|
|
87
|
-
uniqueRef: source.uniqueRef || data.uniqueRef!,
|
|
88
|
-
status: source.status || 'active',
|
|
89
|
-
transform: {
|
|
90
|
-
data,
|
|
91
|
-
type: 'listing',
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}),
|
|
95
|
-
configOverwrites
|
|
96
|
-
);
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
}
|
package/src/ingest-compat/map.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { RequestBody } from '../types';
|
|
2
|
-
import type {
|
|
3
|
-
ListingInput,
|
|
4
|
-
ListingOutput,
|
|
5
|
-
PaymentInput,
|
|
6
|
-
PaymentOutput,
|
|
7
|
-
ReservationInput,
|
|
8
|
-
ReservationOutput,
|
|
9
|
-
} from './types';
|
|
10
|
-
|
|
11
|
-
export const mapTransform = {
|
|
12
|
-
reservation: ({
|
|
13
|
-
id,
|
|
14
|
-
uniqueRef,
|
|
15
|
-
cancelledAt,
|
|
16
|
-
status,
|
|
17
|
-
listingConnectionId,
|
|
18
|
-
listingConnectionRef,
|
|
19
|
-
guestName,
|
|
20
|
-
checkIn,
|
|
21
|
-
checkOut,
|
|
22
|
-
metadata,
|
|
23
|
-
currency,
|
|
24
|
-
bookedAt,
|
|
25
|
-
bookingPlatform,
|
|
26
|
-
pmsReferenceCode,
|
|
27
|
-
bookerName,
|
|
28
|
-
guests,
|
|
29
|
-
confirmationCode,
|
|
30
|
-
paymentLines,
|
|
31
|
-
centTotal: _,
|
|
32
|
-
nights: __,
|
|
33
|
-
sourceId: ___,
|
|
34
|
-
}: ReservationInput): ReservationOutput => ({
|
|
35
|
-
id,
|
|
36
|
-
uniqueRef,
|
|
37
|
-
cancelledAt,
|
|
38
|
-
status: status === 'inactive' ? null : status,
|
|
39
|
-
listingId:
|
|
40
|
-
listingConnectionId?.toString() || listingConnectionRef?.toString(),
|
|
41
|
-
guestName,
|
|
42
|
-
checkIn,
|
|
43
|
-
checkOut,
|
|
44
|
-
metadata,
|
|
45
|
-
currency,
|
|
46
|
-
bookedAt,
|
|
47
|
-
bookingPlatform,
|
|
48
|
-
pmsReferenceCode,
|
|
49
|
-
bookerName,
|
|
50
|
-
guests,
|
|
51
|
-
confirmationCode,
|
|
52
|
-
lines:
|
|
53
|
-
(paymentLines as any[])?.map<
|
|
54
|
-
RequestBody<'post:/reservations/batch'>['data'][0]['lines'][0]
|
|
55
|
-
>((line) => ({
|
|
56
|
-
type: line.type2!,
|
|
57
|
-
amount: line.centTotal || 0,
|
|
58
|
-
uniqueRef: line.uniqueRef,
|
|
59
|
-
description: line.description,
|
|
60
|
-
metadata: line.metadata,
|
|
61
|
-
})) || [],
|
|
62
|
-
}),
|
|
63
|
-
payment: ({
|
|
64
|
-
currency,
|
|
65
|
-
description,
|
|
66
|
-
uniqueRef,
|
|
67
|
-
payedAt,
|
|
68
|
-
etaAt,
|
|
69
|
-
metadata,
|
|
70
|
-
lines,
|
|
71
|
-
}: PaymentInput): PaymentOutput => ({
|
|
72
|
-
uniqueRef,
|
|
73
|
-
metadata,
|
|
74
|
-
currency,
|
|
75
|
-
paidAt: payedAt,
|
|
76
|
-
etaAt,
|
|
77
|
-
description: description ?? 'Payment',
|
|
78
|
-
lines:
|
|
79
|
-
(lines as any[])?.map<
|
|
80
|
-
RequestBody<'post:/payments/batch'>['data'][0]['lines'][0]
|
|
81
|
-
>((line) => ({
|
|
82
|
-
type: line.type2!,
|
|
83
|
-
amount: line.centTotal || 0,
|
|
84
|
-
uniqueRef: line.uniqueRef,
|
|
85
|
-
description: line.description,
|
|
86
|
-
metadata: line.metadata,
|
|
87
|
-
})) || [],
|
|
88
|
-
}),
|
|
89
|
-
listing: (item: ListingInput): ListingOutput => {
|
|
90
|
-
let status =
|
|
91
|
-
item.status === 'disabled'
|
|
92
|
-
? 'inactive'
|
|
93
|
-
: item.status === 'enabled'
|
|
94
|
-
? 'active'
|
|
95
|
-
: item.status;
|
|
96
|
-
if (!item.status && item.pmsStatus) {
|
|
97
|
-
status =
|
|
98
|
-
item.pmsStatus === 'disabled' || item.pmsStatus === 'inactive'
|
|
99
|
-
? 'inactive'
|
|
100
|
-
: item.pmsStatus === 'enabled' || item.pmsStatus === 'active'
|
|
101
|
-
? 'active'
|
|
102
|
-
: null;
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
name: `${item.name}`,
|
|
106
|
-
status: status || 'active',
|
|
107
|
-
uniqueRef: item.uniqueRef,
|
|
108
|
-
defaultCurrency: item.defaultCurrency,
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RequestBody } from '../types';
|
|
2
|
-
|
|
3
|
-
export type PaymentLine = Record<string, any>;
|
|
4
|
-
|
|
5
|
-
export type ReservationInput = Record<string, any>;
|
|
6
|
-
export type ReservationOutput =
|
|
7
|
-
RequestBody<'post:/reservations/batch'>['data'][0];
|
|
8
|
-
export type PaymentInput = Record<string, any>;
|
|
9
|
-
export type PaymentOutput = RequestBody<'post:/payments/batch'>['data'][0];
|
|
10
|
-
export type ListingInput = Record<string, any>;
|
|
11
|
-
export type ListingOutput = RequestBody<'post:/listings/batch'>['data'][0];
|
package/src/middlewares/curl.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { fetchToCurl } from '@finalytic/utils';
|
|
2
|
-
import type createClient from 'openapi-fetch';
|
|
3
|
-
|
|
4
|
-
type Client = ReturnType<typeof createClient>;
|
|
5
|
-
|
|
6
|
-
type LogFn = (t: string) => void;
|
|
7
|
-
export function useCurlMiddleware(client: Client, log?: LogFn) {
|
|
8
|
-
client.use({
|
|
9
|
-
async onRequest({ request }) {
|
|
10
|
-
await curl(request, log);
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function curl(request: Request, log: LogFn = console.log) {
|
|
16
|
-
log(
|
|
17
|
-
fetchToCurl(request.url, {
|
|
18
|
-
method: request.method,
|
|
19
|
-
headers: Object.fromEntries((request.headers as any).entries()),
|
|
20
|
-
body: await request.clone().text(),
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
}
|
package/src/middlewares/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './curl';
|