@vrplatform/api 1.2.32 → 1.2.33-952

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 (83) hide show
  1. package/build/main/generated/openapi-fetch.d.ts +1 -1
  2. package/build/main/generated/openapi-fetch.js.map +1 -1
  3. package/build/main/generated/v1.d.ts +10840 -10065
  4. package/build/main/generated/v1.js.map +1 -1
  5. package/build/main/index.d.ts +4 -3
  6. package/build/main/index.js +0 -3
  7. package/build/main/index.js.map +1 -1
  8. package/build/main/ingest/index.d.ts +0 -2
  9. package/build/main/ingest/index.js.map +1 -1
  10. package/build/main/tsconfig.main.tsbuildinfo +1 -1
  11. package/build/main/types.d.ts +0 -1
  12. package/build/main/types.js.map +1 -1
  13. package/build/module/generated/openapi-fetch.d.ts +1 -1
  14. package/build/module/generated/openapi-fetch.js.map +1 -1
  15. package/build/module/generated/v1.d.ts +10840 -10065
  16. package/build/module/generated/v1.js.map +1 -1
  17. package/build/module/index.d.ts +4 -3
  18. package/build/module/index.js +0 -3
  19. package/build/module/index.js.map +1 -1
  20. package/build/module/ingest/index.d.ts +0 -2
  21. package/build/module/ingest/index.js.map +1 -1
  22. package/build/module/tsconfig.esm.tsbuildinfo +1 -1
  23. package/build/module/types.d.ts +0 -1
  24. package/build/module/types.js.map +1 -1
  25. package/package.json +11 -7
  26. package/src/generated/openapi-fetch.ts +1 -1
  27. package/src/generated/v1.ts +10840 -10065
  28. package/src/index.ts +6 -4
  29. package/src/ingest/index.ts +0 -4
  30. package/src/types.ts +0 -1
  31. package/build/main/fetcher.d.ts +0 -18
  32. package/build/main/fetcher.js +0 -68
  33. package/build/main/fetcher.js.map +0 -1
  34. package/build/main/headers.d.ts +0 -18
  35. package/build/main/headers.js +0 -25
  36. package/build/main/headers.js.map +0 -1
  37. package/build/main/ingest-compat/index.d.ts +0 -14
  38. package/build/main/ingest-compat/index.js +0 -92
  39. package/build/main/ingest-compat/index.js.map +0 -1
  40. package/build/main/ingest-compat/map.d.ts +0 -6
  41. package/build/main/ingest-compat/map.js +0 -67
  42. package/build/main/ingest-compat/map.js.map +0 -1
  43. package/build/main/ingest-compat/types.d.ts +0 -8
  44. package/build/main/ingest-compat/types.js +0 -3
  45. package/build/main/ingest-compat/types.js.map +0 -1
  46. package/build/main/middlewares/curl.d.ts +0 -6
  47. package/build/main/middlewares/curl.js +0 -20
  48. package/build/main/middlewares/curl.js.map +0 -1
  49. package/build/main/middlewares/index.d.ts +0 -1
  50. package/build/main/middlewares/index.js +0 -18
  51. package/build/main/middlewares/index.js.map +0 -1
  52. package/build/main/retryable-errors.d.ts +0 -9
  53. package/build/main/retryable-errors.js +0 -38
  54. package/build/main/retryable-errors.js.map +0 -1
  55. package/build/module/fetcher.d.ts +0 -18
  56. package/build/module/fetcher.js +0 -63
  57. package/build/module/fetcher.js.map +0 -1
  58. package/build/module/headers.d.ts +0 -18
  59. package/build/module/headers.js +0 -23
  60. package/build/module/headers.js.map +0 -1
  61. package/build/module/ingest-compat/index.d.ts +0 -14
  62. package/build/module/ingest-compat/index.js +0 -75
  63. package/build/module/ingest-compat/index.js.map +0 -1
  64. package/build/module/ingest-compat/map.d.ts +0 -6
  65. package/build/module/ingest-compat/map.js +0 -64
  66. package/build/module/ingest-compat/map.js.map +0 -1
  67. package/build/module/ingest-compat/types.d.ts +0 -8
  68. package/build/module/ingest-compat/types.js +0 -2
  69. package/build/module/ingest-compat/types.js.map +0 -1
  70. package/build/module/middlewares/curl.d.ts +0 -6
  71. package/build/module/middlewares/curl.js +0 -16
  72. package/build/module/middlewares/curl.js.map +0 -1
  73. package/build/module/middlewares/index.d.ts +0 -1
  74. package/build/module/middlewares/index.js +0 -2
  75. package/build/module/middlewares/index.js.map +0 -1
  76. package/build/module/retryable-errors.d.ts +0 -9
  77. package/build/module/retryable-errors.js +0 -34
  78. package/build/module/retryable-errors.js.map +0 -1
  79. package/src/ingest-compat/index.ts +0 -99
  80. package/src/ingest-compat/map.ts +0 -111
  81. package/src/ingest-compat/types.ts +0 -11
  82. package/src/middlewares/curl.ts +0 -23
  83. package/src/middlewares/index.ts +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher.js","sourceRoot":"src/","sources":["fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAEL,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,wCAAwC;AACxC,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,GAAG,CAAC,EACZ,IAAI,EACJ,KAAK,EAAE,CAAC,EACR,SAAS,EACT,OAAO,EAAE,CAAC,EACV,KAAK,GAQN;IACC,OAAO,KAAK,EAAE,GAAY,EAAE,EAAE;QAC5B,iDAAiD;QACjD,IAAI,SAAS,GAAiB,IAAI,CAAC;QAEnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;YACpD,MAAM,aAAa,GAAG,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC;YAC/C,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE;oBAC/B,IAAI;oBACJ,OAAO,EAAE,CAAC;oBACV,SAAS;oBACT,KAAK;iBACN,CAAC,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,aAAa;oBAChB,uBAAuB,CACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;wBACjC,CAAC,CAAC,MAAM,CAAC,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, HeadersOptions } from 'openapi-fetch';\nimport type { CacheResult } from './cache';\nimport { ApiClientError } from './error';\nimport { injectHeaders } from './headers';\nimport {\n type RetryableError,\n assertRetryableResponse,\n isRetryableError,\n} from './retryable-errors';\nimport type { ApiClientAuth } from './types';\n\n// Create query fetcher with retry logic\nexport function createQueryFetcher({\n attempts = 3,\n auth,\n fetch: f,\n sessionId,\n headers: h,\n cache,\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n sessionId: string;\n fetch?: ClientOptions['fetch'];\n headers?: HeadersOptions | (() => HeadersOptions);\n cache: CacheResult<string, string>;\n}) {\n return async (req: Request) => {\n // Implement retry logic with exponential backoff\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < attempts; attempt++) {\n const isLastAttempt = attempt === attempts - 1;\n try {\n const dup = new Request(req);\n await injectHeaders(dup.headers, {\n auth,\n headers: h,\n sessionId,\n cache,\n });\n const response = await (f || fetch)(dup);\n if (!isLastAttempt)\n assertRetryableResponse(\n response.status,\n response.headers.has('Retry-After')\n ? Number(response.headers.get('Retry-After')) * 1000\n : undefined\n );\n return response;\n } catch (e: any) {\n const error = e instanceof Error ? e : new Error(String(e));\n lastError = error;\n\n // Only retry if this is a retryable error and we haven't exceeded max retries\n if (isRetryableError(lastError) && !isLastAttempt) {\n // Exponential backoff: 2^retries * 100ms + some random jitter\n const backoff =\n typeof (lastError as RetryableError).retryAfterMs === 'number'\n ? (lastError as RetryableError).retryAfterMs!\n : Math.min(100 * 2 ** attempt + Math.random() * 100, 10000);\n\n // Wait before the next retry\n await waitFor(backoff);\n cache.invalidate();\n } else break;\n }\n }\n const e = lastError || new Error('Max retries exceeded');\n const error = new ApiClientError({\n code: 'FETCH_ERROR',\n message: e.message,\n context: e,\n issues: [],\n });\n error.stack = e.stack;\n throw error;\n };\n}\n"]}
@@ -1,18 +0,0 @@
1
- import type { HeadersOptions } from 'openapi-fetch';
2
- import type { CacheResult } from './cache';
3
- import type { ApiClientAuth } from './types';
4
- export type HeaderInject = ReturnType<typeof injectHeaders>;
5
- export declare function injectHeaders(
6
- head: Headers,
7
- {
8
- auth,
9
- headers,
10
- sessionId,
11
- cache,
12
- }: {
13
- auth?: ApiClientAuth | (() => ApiClientAuth);
14
- headers?: HeadersOptions | (() => HeadersOptions);
15
- sessionId: string;
16
- cache: CacheResult<string, string>;
17
- }
18
- ): Promise<void>;
@@ -1,23 +0,0 @@
1
- export async function injectHeaders(head, { auth, headers, sessionId, cache }) {
2
- const temporary = new Headers(
3
- typeof headers === 'function' ? headers() : headers
4
- );
5
- const a = (typeof auth === 'function' ? auth() : auth) || {};
6
- if (sessionId) temporary.set('X-Session-Id', sessionId);
7
- if (a.sec) temporary.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);
8
- if (a.apiKey) temporary.set('X-Api-Key', a.apiKey);
9
- if (a.tenantId) temporary.set('X-Team-Id', a.tenantId);
10
- if (a.accessToken)
11
- temporary.set(
12
- 'Authorization',
13
- a.accessToken.startsWith('Bearer ')
14
- ? a.accessToken
15
- : `Bearer ${a.accessToken}`
16
- );
17
- temporary.forEach((value, key) => {
18
- if (!head.has(key)) {
19
- head.set(key, value);
20
- }
21
- });
22
- }
23
- //# sourceMappingURL=headers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"src/","sources":["headers.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAa,EACb,EACE,IAAI,EACJ,OAAO,EACP,SAAS,EACT,KAAK,GAMN;IAED,MAAM,SAAS,GAAG,IAAI,OAAO,CAC3B,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAE,OAAe,CAC7D,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7D,IAAI,SAAS;QAAE,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACxD,IAAI,CAAC,CAAC,GAAG;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,CAAC,MAAM;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,QAAQ;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,WAAW;QACf,SAAS,CAAC,GAAG,CACX,eAAe,EACf,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC;YACjC,CAAC,CAAC,CAAC,CAAC,WAAW;YACf,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAC9B,CAAC;IACJ,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HeadersOptions } from 'openapi-fetch';\nimport type { CacheResult } from './cache';\nimport type { ApiClientAuth } from './types';\n\nexport type HeaderInject = ReturnType<typeof injectHeaders>;\nexport async function injectHeaders(\n head: Headers,\n {\n auth,\n headers,\n sessionId,\n cache,\n }: {\n auth?: ApiClientAuth | (() => ApiClientAuth);\n headers?: HeadersOptions | (() => HeadersOptions);\n sessionId: string;\n cache: CacheResult<string, string>;\n }\n) {\n const temporary = new Headers(\n typeof headers === 'function' ? headers() : (headers as any)\n );\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) temporary.set('X-Session-Id', sessionId);\n if (a.sec) temporary.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) temporary.set('X-Api-Key', a.apiKey);\n if (a.tenantId) temporary.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n temporary.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n temporary.forEach((value, key) => {\n if (!head.has(key)) {\n head.set(key, value);\n }\n });\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { type IngestArg, type IngestFnArg, type PartialBy, type Source } from '../ingest';
2
- import type { ApiClient } from '../types';
3
- import type { ListingInput, PaymentInput, ReservationInput } from './types';
4
- export * from './map';
5
- export * from './types';
6
- export type ApiIngestCompat = ReturnType<typeof useIngestCompat>;
7
- export declare function useIngestCompat(api: ApiClient, config: IngestArg): {
8
- api: ApiClient;
9
- readonly sessionId: string;
10
- sources(changes: Source[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<undefined>[] | undefined>;
11
- reservations(changes: PartialBy<Source<ReservationInput>, "type">[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<ReservationInput>[]>;
12
- payments(changes: PartialBy<Source<PaymentInput>, "type">[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<PaymentInput>[] | undefined>;
13
- listings(changes: PartialBy<Source<ListingInput>, "type">[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<ListingInput>[] | undefined>;
14
- };
@@ -1,75 +0,0 @@
1
- import { usePostSources, } from '../ingest';
2
- import { mapTransform } from './map';
3
- export * from './map';
4
- export * from './types';
5
- export function useIngestCompat(api, config) {
6
- const post = usePostSources(api, config);
7
- return {
8
- api,
9
- get sessionId() {
10
- return api.sessionId;
11
- },
12
- async sources(changes, configOverwrites) {
13
- if (!changes.length)
14
- return undefined;
15
- return await post(changes, configOverwrites);
16
- },
17
- async reservations(changes, configOverwrites) {
18
- if (!changes.length)
19
- return [];
20
- return await post(changes.map(({ transform, ...source }) => {
21
- const data = mapTransform.reservation(transform.data);
22
- return {
23
- ...source,
24
- type: source.type || 'reservation',
25
- description: source.description || data.confirmationCode,
26
- uniqueRef: source.uniqueRef || data.uniqueRef,
27
- date: source.date || data.bookedAt,
28
- status: source.status || 'active',
29
- transform: {
30
- data,
31
- type: 'reservation',
32
- },
33
- };
34
- }), configOverwrites);
35
- },
36
- async payments(changes, configOverwrites) {
37
- if (!changes.length)
38
- return undefined;
39
- return await post(changes.map(({ transform, ...source }) => {
40
- const data = mapTransform.payment(transform.data);
41
- return {
42
- ...source,
43
- type: source.type || 'payment',
44
- description: source.description || data.description,
45
- uniqueRef: source.uniqueRef || data.uniqueRef,
46
- date: source.date || data.paidAt,
47
- status: source.status || 'active',
48
- transform: {
49
- data,
50
- type: 'payment',
51
- },
52
- };
53
- }), configOverwrites);
54
- },
55
- async listings(changes, configOverwrites) {
56
- if (!changes.length)
57
- return undefined;
58
- return await post(changes.map(({ transform, ...source }) => {
59
- const data = mapTransform.listing(transform.data);
60
- return {
61
- ...source,
62
- type: source.type || 'listing',
63
- description: source.description || data.name,
64
- uniqueRef: source.uniqueRef || data.uniqueRef,
65
- status: source.status || 'active',
66
- transform: {
67
- data,
68
- type: 'listing',
69
- },
70
- };
71
- }), configOverwrites);
72
- },
73
- };
74
- }
75
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["ingest-compat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,cAAc,GACf,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGrC,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AAGxB,MAAM,UAAU,eAAe,CAAC,GAAc,EAAE,MAAiB;IAC/D,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,OA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;AACJ,CAAC","sourcesContent":["import {\n type IngestArg,\n type IngestFnArg,\n type PartialBy,\n type Source,\n usePostSources,\n} from '../ingest';\nimport type { ApiClient } from '../types';\nimport { mapTransform } from './map';\nimport type { ListingInput, PaymentInput, ReservationInput } from './types';\n\nexport * from './map';\nexport * from './types';\n\nexport type ApiIngestCompat = ReturnType<typeof useIngestCompat>;\nexport function useIngestCompat(api: ApiClient, config: IngestArg) {\n const post = usePostSources(api, config);\n return {\n api,\n get sessionId() {\n return api.sessionId;\n },\n async sources(changes: Source[], configOverwrites?: IngestFnArg) {\n if (!changes.length) return undefined;\n return await post(changes, configOverwrites);\n },\n async reservations(\n changes: PartialBy<Source<ReservationInput>, 'type'>[],\n configOverwrites?: IngestFnArg\n ) {\n if (!changes.length) return [];\n return await post<ReservationInput>(\n changes.map(({ transform, ...source }) => {\n const data = mapTransform.reservation(transform.data);\n return {\n ...source,\n type: source.type || 'reservation',\n description: source.description || data.confirmationCode,\n uniqueRef: source.uniqueRef || data.uniqueRef!,\n date: source.date || data.bookedAt,\n status: source.status || 'active',\n transform: {\n data,\n type: 'reservation',\n },\n };\n }),\n configOverwrites\n );\n },\n async payments(\n changes: PartialBy<Source<PaymentInput>, 'type'>[],\n configOverwrites?: IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<PaymentInput>(\n changes.map(({ transform, ...source }) => {\n const data = mapTransform.payment(transform.data);\n return {\n ...source,\n type: source.type || 'payment',\n description: source.description || data.description,\n uniqueRef: source.uniqueRef || data.uniqueRef!,\n date: source.date || data.paidAt,\n status: source.status || 'active',\n transform: {\n data,\n type: 'payment',\n },\n };\n }),\n configOverwrites\n );\n },\n async listings(\n changes: PartialBy<Source<ListingInput>, 'type'>[],\n configOverwrites?: IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<ListingInput>(\n changes.map(({ transform, ...source }) => {\n const data = mapTransform.listing(transform.data);\n return {\n ...source,\n type: source.type || 'listing',\n description: source.description || data.name,\n uniqueRef: source.uniqueRef || data.uniqueRef!,\n status: source.status || 'active',\n transform: {\n data,\n type: 'listing',\n },\n };\n }),\n configOverwrites\n );\n },\n };\n}\n"]}
@@ -1,6 +0,0 @@
1
- import type { ListingInput, ListingOutput, PaymentInput, PaymentOutput, ReservationInput, ReservationOutput } from './types';
2
- export declare const mapTransform: {
3
- reservation: ({ id, uniqueRef, cancelledAt, status, listingConnectionId, listingConnectionRef, guestName, checkIn, checkOut, metadata, currency, bookedAt, bookingPlatform, pmsReferenceCode, bookerName, guests, confirmationCode, paymentLines, centTotal: _, nights: __, sourceId: ___, }: ReservationInput) => ReservationOutput;
4
- payment: ({ currency, description, uniqueRef, payedAt, etaAt, metadata, lines, }: PaymentInput) => PaymentOutput;
5
- listing: (item: ListingInput) => ListingOutput;
6
- };
@@ -1,64 +0,0 @@
1
- export const mapTransform = {
2
- reservation: ({ id, uniqueRef, cancelledAt, status, listingConnectionId, listingConnectionRef, guestName, checkIn, checkOut, metadata, currency, bookedAt, bookingPlatform, pmsReferenceCode, bookerName, guests, confirmationCode, paymentLines, centTotal: _, nights: __, sourceId: ___, }) => ({
3
- id,
4
- uniqueRef,
5
- cancelledAt,
6
- status: status === 'inactive' ? null : status,
7
- listingId: listingConnectionId?.toString() || listingConnectionRef?.toString(),
8
- guestName,
9
- checkIn,
10
- checkOut,
11
- metadata,
12
- currency,
13
- bookedAt,
14
- bookingPlatform,
15
- pmsReferenceCode,
16
- bookerName,
17
- guests,
18
- confirmationCode,
19
- lines: paymentLines?.map((line) => ({
20
- type: line.type2,
21
- amount: line.centTotal || 0,
22
- uniqueRef: line.uniqueRef,
23
- description: line.description,
24
- metadata: line.metadata,
25
- })) || [],
26
- }),
27
- payment: ({ currency, description, uniqueRef, payedAt, etaAt, metadata, lines, }) => ({
28
- uniqueRef,
29
- metadata,
30
- currency,
31
- paidAt: payedAt,
32
- etaAt,
33
- description: description ?? 'Payment',
34
- lines: lines?.map((line) => ({
35
- type: line.type2,
36
- amount: line.centTotal || 0,
37
- uniqueRef: line.uniqueRef,
38
- description: line.description,
39
- metadata: line.metadata,
40
- })) || [],
41
- }),
42
- listing: (item) => {
43
- let status = item.status === 'disabled'
44
- ? 'inactive'
45
- : item.status === 'enabled'
46
- ? 'active'
47
- : item.status;
48
- if (!item.status && item.pmsStatus) {
49
- status =
50
- item.pmsStatus === 'disabled' || item.pmsStatus === 'inactive'
51
- ? 'inactive'
52
- : item.pmsStatus === 'enabled' || item.pmsStatus === 'active'
53
- ? 'active'
54
- : null;
55
- }
56
- return {
57
- name: `${item.name}`,
58
- status: status || 'active',
59
- uniqueRef: item.uniqueRef,
60
- defaultCurrency: item.defaultCurrency,
61
- };
62
- },
63
- };
64
- //# sourceMappingURL=map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map.js","sourceRoot":"src/","sources":["ingest-compat/map.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,CAAC,EACZ,EAAE,EACF,SAAS,EACT,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,EAAE,EACV,QAAQ,EAAE,GAAG,GACI,EAAqB,EAAE,CAAC,CAAC;QAC1C,EAAE;QACF,SAAS;QACT,WAAW;QACX,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;QAC7C,SAAS,EACP,mBAAmB,EAAE,QAAQ,EAAE,IAAI,oBAAoB,EAAE,QAAQ,EAAE;QACrE,SAAS;QACT,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,eAAe;QACf,gBAAgB;QAChB,UAAU;QACV,MAAM;QACN,gBAAgB;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AAI,IAAI,CAAC,SAAS,KAAK,UAAU;oBAC5D,CAAC,CAAC,UAAU;oBACZ,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ;wBAC3D,CAAC,CAAC,QAAQ;wBACV,CAAC,CAAC,IAAI,CAAC;QACf,CAAC;QACD,OAAO;YACL,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE;YACpB,MAAM,EAAE,MAAM,IAAI,QAAQ;YAC1B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { RequestBody } from '../types';\nimport type {\n ListingInput,\n ListingOutput,\n PaymentInput,\n PaymentOutput,\n ReservationInput,\n ReservationOutput,\n} from './types';\n\nexport const mapTransform = {\n reservation: ({\n id,\n uniqueRef,\n cancelledAt,\n status,\n listingConnectionId,\n listingConnectionRef,\n guestName,\n checkIn,\n checkOut,\n metadata,\n currency,\n bookedAt,\n bookingPlatform,\n pmsReferenceCode,\n bookerName,\n guests,\n confirmationCode,\n paymentLines,\n centTotal: _,\n nights: __,\n sourceId: ___,\n }: ReservationInput): ReservationOutput => ({\n id,\n uniqueRef,\n cancelledAt,\n status: status === 'inactive' ? null : status,\n listingId:\n listingConnectionId?.toString() || listingConnectionRef?.toString(),\n guestName,\n checkIn,\n checkOut,\n metadata,\n currency,\n bookedAt,\n bookingPlatform,\n pmsReferenceCode,\n bookerName,\n guests,\n confirmationCode,\n lines:\n (paymentLines as any[])?.map<\n RequestBody<'post:/reservations/batch'>['data'][0]['lines'][0]\n >((line) => ({\n type: line.type2!,\n amount: line.centTotal || 0,\n uniqueRef: line.uniqueRef,\n description: line.description,\n metadata: line.metadata,\n })) || [],\n }),\n payment: ({\n currency,\n description,\n uniqueRef,\n payedAt,\n etaAt,\n metadata,\n lines,\n }: PaymentInput): PaymentOutput => ({\n uniqueRef,\n metadata,\n currency,\n paidAt: payedAt,\n etaAt,\n description: description ?? 'Payment',\n lines:\n (lines as any[])?.map<\n RequestBody<'post:/payments/batch'>['data'][0]['lines'][0]\n >((line) => ({\n type: line.type2!,\n amount: line.centTotal || 0,\n uniqueRef: line.uniqueRef,\n description: line.description,\n metadata: line.metadata,\n })) || [],\n }),\n listing: (item: ListingInput): ListingOutput => {\n let status =\n item.status === 'disabled'\n ? 'inactive'\n : item.status === 'enabled'\n ? 'active'\n : item.status;\n if (!item.status && item.pmsStatus) {\n status =\n item.pmsStatus === 'disabled' || item.pmsStatus === 'inactive'\n ? 'inactive'\n : item.pmsStatus === 'enabled' || item.pmsStatus === 'active'\n ? 'active'\n : null;\n }\n return {\n name: `${item.name}`,\n status: status || 'active',\n uniqueRef: item.uniqueRef,\n defaultCurrency: item.defaultCurrency,\n };\n },\n};\n"]}
@@ -1,8 +0,0 @@
1
- import type { RequestBody } from '../types';
2
- export type PaymentLine = Record<string, any>;
3
- export type ReservationInput = Record<string, any>;
4
- export type ReservationOutput = RequestBody<'post:/reservations/batch'>['data'][0];
5
- export type PaymentInput = Record<string, any>;
6
- export type PaymentOutput = RequestBody<'post:/payments/batch'>['data'][0];
7
- export type ListingInput = Record<string, any>;
8
- export type ListingOutput = RequestBody<'post:/listings/batch'>['data'][0];
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"src/","sources":["ingest-compat/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RequestBody } from '../types';\n\nexport type PaymentLine = Record<string, any>;\n\nexport type ReservationInput = Record<string, any>;\nexport type ReservationOutput =\n RequestBody<'post:/reservations/batch'>['data'][0];\nexport type PaymentInput = Record<string, any>;\nexport type PaymentOutput = RequestBody<'post:/payments/batch'>['data'][0];\nexport type ListingInput = Record<string, any>;\nexport type ListingOutput = RequestBody<'post:/listings/batch'>['data'][0];\n"]}
@@ -1,6 +0,0 @@
1
- import type createClient from 'openapi-fetch';
2
- type Client = ReturnType<typeof createClient>;
3
- type LogFn = (t: string) => void;
4
- export declare function useCurlMiddleware(client: Client, log?: LogFn): void;
5
- export declare function curl(request: Request, log?: LogFn): Promise<void>;
6
- export {};
@@ -1,16 +0,0 @@
1
- import { fetchToCurl } from '@finalytic/utils';
2
- export function useCurlMiddleware(client, log) {
3
- client.use({
4
- async onRequest({ request }) {
5
- await curl(request, log);
6
- },
7
- });
8
- }
9
- export async function curl(request, log = console.log) {
10
- log(fetchToCurl(request.url, {
11
- method: request.method,
12
- headers: Object.fromEntries(request.headers.entries()),
13
- body: await request.clone().text(),
14
- }));
15
- }
16
- //# sourceMappingURL=curl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"curl.js","sourceRoot":"src/","sources":["middlewares/curl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,GAAW;IAC3D,MAAM,CAAC,GAAG,CAAC;QACT,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE;YACzB,MAAM,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAgB,EAAE,MAAa,OAAO,CAAC,GAAG;IACnE,GAAG,CACD,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE;QACvB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,MAAM,CAAC,WAAW,CAAE,OAAO,CAAC,OAAe,CAAC,OAAO,EAAE,CAAC;QAC/D,IAAI,EAAE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE;KACnC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { fetchToCurl } from '@finalytic/utils';\nimport type createClient from 'openapi-fetch';\n\ntype Client = ReturnType<typeof createClient>;\n\ntype LogFn = (t: string) => void;\nexport function useCurlMiddleware(client: Client, log?: LogFn) {\n client.use({\n async onRequest({ request }) {\n await curl(request, log);\n },\n });\n}\n\nexport async function curl(request: Request, log: LogFn = console.log) {\n log(\n fetchToCurl(request.url, {\n method: request.method,\n headers: Object.fromEntries((request.headers as any).entries()),\n body: await request.clone().text(),\n })\n );\n}\n"]}
@@ -1 +0,0 @@
1
- export * from './curl';
@@ -1,2 +0,0 @@
1
- export * from './curl';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC","sourcesContent":["export * from './curl';\n"]}
@@ -1,9 +0,0 @@
1
- export declare function isRetryableError(error: Error): boolean;
2
- export declare class RetryableError extends Error {
3
- readonly retryAfterMs?: number | undefined;
4
- constructor(message: string, retryAfterMs?: number | undefined);
5
- }
6
- export declare function assertRetryableResponse(
7
- status: number,
8
- retryAfterMs?: number
9
- ): void;
@@ -1,34 +0,0 @@
1
- // Add helper to check if an error is retryable
2
- export function isRetryableError(error) {
3
- // Network errors, connection timeouts, and other temporary issues
4
- if (error instanceof RetryableError) return true;
5
- const lowerCaseMessage = error.message?.toLowerCase() || '';
6
- return (
7
- lowerCaseMessage.includes('network connection lost') ||
8
- lowerCaseMessage.includes('failed to fetch') ||
9
- lowerCaseMessage.includes('network request failed') ||
10
- lowerCaseMessage.includes('timeout') ||
11
- lowerCaseMessage.includes('fetch failed') ||
12
- lowerCaseMessage.includes('econnrefused') ||
13
- lowerCaseMessage.includes('econnreset')
14
- );
15
- }
16
- export class RetryableError extends Error {
17
- retryAfterMs;
18
- constructor(message, retryAfterMs) {
19
- super(message);
20
- this.retryAfterMs = retryAfterMs;
21
- }
22
- }
23
- // Status codes that should trigger a retry
24
- const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 520]);
25
- export function assertRetryableResponse(status, retryAfterMs) {
26
- if (RETRYABLE_STATUS_CODES.has(status) || typeof retryAfterMs === 'number') {
27
- // Throw an error that will be caught by the catch block below
28
- throw new RetryableError(
29
- `Retryable HTTP status code: ${status}`,
30
- retryAfterMs
31
- );
32
- }
33
- }
34
- //# sourceMappingURL=retryable-errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retryable-errors.js","sourceRoot":"src/","sources":["retryable-errors.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,kEAAkE;IAClE,IAAI,KAAK,YAAY,cAAc;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC5D,OAAO,CACL,gBAAgB,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QACpD,gBAAgB,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAC5C,gBAAgB,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACnD,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC;QACpC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC;QACzC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC;QACzC,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,CACxC,CAAC;AACJ,CAAC;AACD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrB;IAFlB,YACE,OAAe,EACC,YAAqB;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,iBAAY,GAAZ,YAAY,CAAS;IAGvC,CAAC;CACF;AAED,2CAA2C;AAC3C,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE5E,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,YAAqB;IAC3E,IAAI,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC3E,8DAA8D;QAC9D,MAAM,IAAI,cAAc,CACtB,+BAA+B,MAAM,EAAE,EACvC,YAAY,CACb,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Add helper to check if an error is retryable\nexport function isRetryableError(error: Error): boolean {\n // Network errors, connection timeouts, and other temporary issues\n if (error instanceof RetryableError) return true;\n const lowerCaseMessage = error.message?.toLowerCase() || '';\n return (\n lowerCaseMessage.includes('network connection lost') ||\n lowerCaseMessage.includes('failed to fetch') ||\n lowerCaseMessage.includes('network request failed') ||\n lowerCaseMessage.includes('timeout') ||\n lowerCaseMessage.includes('fetch failed') ||\n lowerCaseMessage.includes('econnrefused') ||\n lowerCaseMessage.includes('econnreset')\n );\n}\nexport class RetryableError extends Error {\n constructor(\n message: string,\n public readonly retryAfterMs?: number\n ) {\n super(message);\n }\n}\n\n// Status codes that should trigger a retry\nconst RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 520]);\n\nexport function assertRetryableResponse(status: number, retryAfterMs?: number) {\n if (RETRYABLE_STATUS_CODES.has(status) || typeof retryAfterMs === 'number') {\n // Throw an error that will be caught by the catch block below\n throw new RetryableError(\n `Retryable HTTP status code: ${status}`,\n retryAfterMs\n );\n }\n}\n"]}
@@ -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';