@vrplatform/api 1.2.33-stage.943 → 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/v1.d.ts +745 -657
- package/build/main/generated/v1.js.map +1 -1
- package/build/main/index.d.ts +4 -4
- package/build/main/index.js +0 -1
- package/build/main/index.js.map +1 -1
- package/build/main/ingest/index.d.ts +0 -1
- 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/tsconfig.main.tsbuildinfo +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/v1.d.ts +745 -657
- package/build/module/generated/v1.js.map +1 -1
- package/build/module/index.d.ts +4 -4
- package/build/module/index.js +0 -1
- package/build/module/index.js.map +1 -1
- package/build/module/ingest/index.d.ts +0 -1
- 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/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/src/client.ts +4 -1
- package/src/error.ts +1 -1
- package/src/generated/v1.ts +745 -657
- package/src/index.ts +5 -10
- package/src/ingest/index.ts +0 -2
- package/src/ingest/types.ts +1 -1
- package/src/ingest-compat/index.ts +0 -98
- package/src/ingest-compat/map.ts +0 -111
- package/src/ingest-compat/types.ts +0 -9
package/src/index.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
+
import type { useIngest } from './ingest';
|
|
2
|
+
import type { ApiClient } from './types';
|
|
3
|
+
|
|
1
4
|
export * from './client';
|
|
2
5
|
export * from './error';
|
|
3
6
|
export * from './generated/v1';
|
|
4
7
|
export * from './ingest';
|
|
5
|
-
export * from './ingest-compat';
|
|
6
8
|
export * from './types';
|
|
7
9
|
|
|
8
|
-
export type ApiIngest = ReturnType<typeof
|
|
9
|
-
export type
|
|
10
|
-
typeof import('./ingest-compat').useIngestCompat
|
|
11
|
-
>;
|
|
12
|
-
export type VRPlatformApi = import('./types').ApiClient;
|
|
13
|
-
|
|
14
|
-
type _EnsureApiIngest = ApiIngest;
|
|
15
|
-
type _EnsureApiIngestCompat = ApiIngestCompat;
|
|
16
|
-
type _EnsureVRPlatformApi = VRPlatformApi;
|
|
10
|
+
export type ApiIngest = ReturnType<typeof useIngest>;
|
|
11
|
+
export type VRPlatformApi = ApiClient;
|
package/src/ingest/index.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { throwIfError } from '../error';
|
|
|
2
2
|
import type { ApiClient, RequestBody } from '../types';
|
|
3
3
|
import type * as t from './types';
|
|
4
4
|
|
|
5
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
6
|
-
|
|
7
5
|
export * from './types';
|
|
8
6
|
|
|
9
7
|
function mergeConfig(
|
package/src/ingest/types.ts
CHANGED
|
@@ -1,98 +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 function useIngestCompat(api: ApiClient, config: IngestArg) {
|
|
16
|
-
const post = usePostSources(api, config);
|
|
17
|
-
return {
|
|
18
|
-
api,
|
|
19
|
-
get sessionId() {
|
|
20
|
-
return api.sessionId;
|
|
21
|
-
},
|
|
22
|
-
async sources(changes: Source[], configOverwrites?: IngestFnArg) {
|
|
23
|
-
if (!changes.length) return undefined;
|
|
24
|
-
return await post(changes, configOverwrites);
|
|
25
|
-
},
|
|
26
|
-
async reservations(
|
|
27
|
-
changes: PartialBy<Source<ReservationInput>, 'type'>[],
|
|
28
|
-
configOverwrites?: IngestFnArg
|
|
29
|
-
) {
|
|
30
|
-
if (!changes.length) return [];
|
|
31
|
-
return await post<ReservationInput>(
|
|
32
|
-
changes.map(({ transform, ...source }) => {
|
|
33
|
-
const data = mapTransform.reservation(transform.data);
|
|
34
|
-
return {
|
|
35
|
-
...source,
|
|
36
|
-
type: source.type || 'reservation',
|
|
37
|
-
description: source.description || data.confirmationCode,
|
|
38
|
-
uniqueRef: source.uniqueRef || data.uniqueRef!,
|
|
39
|
-
date: source.date || data.bookedAt,
|
|
40
|
-
status: source.status || 'active',
|
|
41
|
-
transform: {
|
|
42
|
-
data,
|
|
43
|
-
type: 'reservation',
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}),
|
|
47
|
-
configOverwrites
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
async payments(
|
|
51
|
-
changes: PartialBy<Source<PaymentInput>, 'type'>[],
|
|
52
|
-
configOverwrites?: IngestFnArg
|
|
53
|
-
) {
|
|
54
|
-
if (!changes.length) return undefined;
|
|
55
|
-
return await post<PaymentInput>(
|
|
56
|
-
changes.map(({ transform, ...source }) => {
|
|
57
|
-
const data = mapTransform.payment(transform.data);
|
|
58
|
-
return {
|
|
59
|
-
...source,
|
|
60
|
-
type: source.type || 'payment',
|
|
61
|
-
description: source.description || data.description,
|
|
62
|
-
uniqueRef: source.uniqueRef || data.uniqueRef!,
|
|
63
|
-
date: source.date || data.paidAt,
|
|
64
|
-
status: source.status || 'active',
|
|
65
|
-
transform: {
|
|
66
|
-
data,
|
|
67
|
-
type: 'payment',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
}),
|
|
71
|
-
configOverwrites
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
async listings(
|
|
75
|
-
changes: PartialBy<Source<ListingInput>, 'type'>[],
|
|
76
|
-
configOverwrites?: IngestFnArg
|
|
77
|
-
) {
|
|
78
|
-
if (!changes.length) return undefined;
|
|
79
|
-
return await post<ListingInput>(
|
|
80
|
-
changes.map(({ transform, ...source }) => {
|
|
81
|
-
const data = mapTransform.listing(transform.data);
|
|
82
|
-
return {
|
|
83
|
-
...source,
|
|
84
|
-
type: source.type || 'listing',
|
|
85
|
-
description: source.description || data.name,
|
|
86
|
-
uniqueRef: source.uniqueRef || data.uniqueRef!,
|
|
87
|
-
status: source.status || 'active',
|
|
88
|
-
transform: {
|
|
89
|
-
data,
|
|
90
|
-
type: 'listing',
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}),
|
|
94
|
-
configOverwrites
|
|
95
|
-
);
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { RequestBody } from '../types';
|
|
2
|
-
|
|
3
|
-
export type ReservationInput = Record<string, any>;
|
|
4
|
-
export type ReservationOutput =
|
|
5
|
-
RequestBody<'post:/reservations/batch'>['data'][0];
|
|
6
|
-
export type PaymentInput = Record<string, any>;
|
|
7
|
-
export type PaymentOutput = RequestBody<'post:/payments/batch'>['data'][0];
|
|
8
|
-
export type ListingInput = Record<string, any>;
|
|
9
|
-
export type ListingOutput = RequestBody<'post:/listings/batch'>['data'][0];
|