@vrplatform/api 1.2.33 → 1.2.35

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.
Files changed (90) hide show
  1. package/build/main/client.d.ts +1 -1
  2. package/build/main/client.js +1 -1
  3. package/build/main/client.js.map +1 -1
  4. package/build/main/error.js +1 -1
  5. package/build/main/error.js.map +1 -1
  6. package/build/main/generated/openapi-fetch.d.ts +1 -1
  7. package/build/main/generated/openapi-fetch.js.map +1 -1
  8. package/build/main/generated/v1.d.ts +10146 -9184
  9. package/build/main/generated/v1.js.map +1 -1
  10. package/build/main/index.d.ts +4 -3
  11. package/build/main/index.js +0 -3
  12. package/build/main/index.js.map +1 -1
  13. package/build/main/ingest/index.d.ts +0 -2
  14. package/build/main/ingest/index.js.map +1 -1
  15. package/build/main/ingest/types.d.ts +1 -1
  16. package/build/main/ingest/types.js.map +1 -1
  17. package/build/main/ingest-compat/index.d.ts +0 -1
  18. package/build/main/ingest-compat/index.js.map +1 -1
  19. package/build/main/ingest-compat/types.d.ts +0 -1
  20. package/build/main/ingest-compat/types.js.map +1 -1
  21. package/build/main/tsconfig.main.tsbuildinfo +1 -1
  22. package/build/main/types.d.ts +0 -1
  23. package/build/main/types.js.map +1 -1
  24. package/build/module/client.d.ts +1 -1
  25. package/build/module/client.js +1 -1
  26. package/build/module/client.js.map +1 -1
  27. package/build/module/error.js +1 -1
  28. package/build/module/error.js.map +1 -1
  29. package/build/module/generated/openapi-fetch.d.ts +1 -1
  30. package/build/module/generated/openapi-fetch.js.map +1 -1
  31. package/build/module/generated/v1.d.ts +10146 -9184
  32. package/build/module/generated/v1.js.map +1 -1
  33. package/build/module/index.d.ts +4 -3
  34. package/build/module/index.js +0 -3
  35. package/build/module/index.js.map +1 -1
  36. package/build/module/ingest/index.d.ts +0 -2
  37. package/build/module/ingest/index.js.map +1 -1
  38. package/build/module/ingest/types.d.ts +1 -1
  39. package/build/module/ingest/types.js.map +1 -1
  40. package/build/module/ingest-compat/index.d.ts +0 -1
  41. package/build/module/ingest-compat/index.js.map +1 -1
  42. package/build/module/ingest-compat/types.d.ts +0 -1
  43. package/build/module/ingest-compat/types.js.map +1 -1
  44. package/build/module/tsconfig.esm.tsbuildinfo +1 -1
  45. package/build/module/types.d.ts +0 -1
  46. package/build/module/types.js.map +1 -1
  47. package/package.json +14 -8
  48. package/src/client.ts +4 -1
  49. package/src/error.ts +1 -1
  50. package/src/generated/openapi-fetch.ts +1 -1
  51. package/src/generated/v1.ts +10146 -9184
  52. package/src/index.ts +6 -4
  53. package/src/ingest/index.ts +0 -4
  54. package/src/ingest/types.ts +1 -1
  55. package/src/types.ts +0 -1
  56. package/build/main/fetcher.d.ts +0 -18
  57. package/build/main/fetcher.js +0 -68
  58. package/build/main/fetcher.js.map +0 -1
  59. package/build/main/headers.d.ts +0 -18
  60. package/build/main/headers.js +0 -25
  61. package/build/main/headers.js.map +0 -1
  62. package/build/main/middlewares/curl.d.ts +0 -6
  63. package/build/main/middlewares/curl.js +0 -20
  64. package/build/main/middlewares/curl.js.map +0 -1
  65. package/build/main/middlewares/index.d.ts +0 -1
  66. package/build/main/middlewares/index.js +0 -18
  67. package/build/main/middlewares/index.js.map +0 -1
  68. package/build/main/retryable-errors.d.ts +0 -9
  69. package/build/main/retryable-errors.js +0 -38
  70. package/build/main/retryable-errors.js.map +0 -1
  71. package/build/module/fetcher.d.ts +0 -18
  72. package/build/module/fetcher.js +0 -63
  73. package/build/module/fetcher.js.map +0 -1
  74. package/build/module/headers.d.ts +0 -18
  75. package/build/module/headers.js +0 -23
  76. package/build/module/headers.js.map +0 -1
  77. package/build/module/middlewares/curl.d.ts +0 -6
  78. package/build/module/middlewares/curl.js +0 -16
  79. package/build/module/middlewares/curl.js.map +0 -1
  80. package/build/module/middlewares/index.d.ts +0 -1
  81. package/build/module/middlewares/index.js +0 -2
  82. package/build/module/middlewares/index.js.map +0 -1
  83. package/build/module/retryable-errors.d.ts +0 -9
  84. package/build/module/retryable-errors.js +0 -34
  85. package/build/module/retryable-errors.js.map +0 -1
  86. package/src/ingest-compat/index.ts +0 -99
  87. package/src/ingest-compat/map.ts +0 -111
  88. package/src/ingest-compat/types.ts +0 -11
  89. package/src/middlewares/curl.ts +0 -23
  90. 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
- }
@@ -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];
@@ -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
- }
@@ -1 +0,0 @@
1
- export * from './curl';