@vrplatform/api 1.3.0 → 1.3.1-1345
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.js +6 -0
- package/build/main/client.js.map +1 -1
- package/build/main/generated/v1.d.ts +3840 -2763
- package/build/main/generated/v1.js.map +1 -1
- package/build/main/index.d.ts +0 -3
- package/build/main/index.js +0 -1
- package/build/main/index.js.map +1 -1
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/module/client.js +6 -0
- package/build/module/client.js.map +1 -1
- package/build/module/generated/v1.d.ts +3840 -2763
- package/build/module/generated/v1.js.map +1 -1
- package/build/module/index.d.ts +0 -3
- package/build/module/index.js +0 -1
- package/build/module/index.js.map +1 -1
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +23 -19
- package/src/client.ts +7 -1
- package/src/generated/v1.ts +3840 -2763
- package/src/index.ts +0 -3
- package/build/main/ingest/index.d.ts +0 -21
- package/build/main/ingest/index.js +0 -189
- package/build/main/ingest/index.js.map +0 -1
- package/build/main/ingest/types.d.ts +0 -48
- package/build/main/ingest/types.js +0 -3
- package/build/main/ingest/types.js.map +0 -1
- package/build/main/ingest-compat/index.d.ts +0 -13
- package/build/main/ingest-compat/index.js +0 -92
- package/build/main/ingest-compat/index.js.map +0 -1
- package/build/main/ingest-compat/map.d.ts +0 -6
- package/build/main/ingest-compat/map.js +0 -67
- package/build/main/ingest-compat/map.js.map +0 -1
- package/build/main/ingest-compat/types.d.ts +0 -7
- package/build/main/ingest-compat/types.js +0 -3
- package/build/main/ingest-compat/types.js.map +0 -1
- package/build/module/ingest/index.d.ts +0 -21
- package/build/module/ingest/index.js +0 -171
- package/build/module/ingest/index.js.map +0 -1
- package/build/module/ingest/types.d.ts +0 -48
- package/build/module/ingest/types.js +0 -2
- package/build/module/ingest/types.js.map +0 -1
- package/build/module/ingest-compat/index.d.ts +0 -13
- package/build/module/ingest-compat/index.js +0 -75
- package/build/module/ingest-compat/index.js.map +0 -1
- package/build/module/ingest-compat/map.d.ts +0 -6
- package/build/module/ingest-compat/map.js +0 -64
- package/build/module/ingest-compat/map.js.map +0 -1
- package/build/module/ingest-compat/types.d.ts +0 -7
- package/build/module/ingest-compat/types.js +0 -2
- package/build/module/ingest-compat/types.js.map +0 -1
- package/src/ingest/index.ts +0 -227
- package/src/ingest/types.ts +0 -91
package/src/index.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { useIngest } from './ingest';
|
|
2
1
|
import type { ApiClient } from './types';
|
|
3
2
|
|
|
4
3
|
export * from './client';
|
|
5
4
|
export * from './error';
|
|
6
5
|
export * from './generated/v1';
|
|
7
|
-
export * from './ingest';
|
|
8
6
|
export * from './types';
|
|
9
7
|
|
|
10
|
-
export type ApiIngest = ReturnType<typeof useIngest>;
|
|
11
8
|
export type VRPlatformApi = ApiClient;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ApiClient, RequestBody } from '../types';
|
|
2
|
-
import type * as t from './types';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export declare function usePostSources(api: ApiClient, config: t.IngestArg): <T = undefined>(data: RequestBody<"post:/sources/batch">["data"], configOverwrites?: t.IngestFnArg) => Promise<t.TypedResponseData<T>[]>;
|
|
5
|
-
export declare function useIngest(api: ApiClient, config: t.IngestArg): {
|
|
6
|
-
api: ApiClient;
|
|
7
|
-
readonly sessionId: string;
|
|
8
|
-
sources(changes: t.IngestSourceInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<undefined>[] | undefined>;
|
|
9
|
-
updateSources(data: RequestBody<"put:/sources/batch">["data"], configOverwrites?: t.IngestFnArg): Promise<{
|
|
10
|
-
id: string;
|
|
11
|
-
}[]>;
|
|
12
|
-
reservations(changes: t.IngestReservationInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.ReservationParam>[]>;
|
|
13
|
-
payments(changes: t.IngestPaymentInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.PaymentParam>[] | undefined>;
|
|
14
|
-
listings(changes: t.IngestListingInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.ListingParam>[] | undefined>;
|
|
15
|
-
cleanup(type: string | "listing", configOverwrites?: t.IngestFnArg & {
|
|
16
|
-
whereRange?: RequestBody<"put:/sources/cleanup">["whereRange"];
|
|
17
|
-
}): Promise<any>;
|
|
18
|
-
bankRecords(changes: t.IngestBankRecordInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.BankRecordParam>[] | undefined>;
|
|
19
|
-
transactions(changes: t.IngestTransactionInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.TransactionParam>[] | undefined>;
|
|
20
|
-
contacts(changes: t.IngestContactInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.ContactParam>[] | undefined>;
|
|
21
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.usePostSources = usePostSources;
|
|
18
|
-
exports.useIngest = useIngest;
|
|
19
|
-
const error_1 = require("../error");
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
21
|
-
function mergeConfig(body, config, configOverwrites) {
|
|
22
|
-
const headers = {};
|
|
23
|
-
if (configOverwrites) {
|
|
24
|
-
const { correlationId, ...restOverwrites } = configOverwrites;
|
|
25
|
-
for (const [key, value] of Object.entries(restOverwrites))
|
|
26
|
-
if (value)
|
|
27
|
-
body[key] = value;
|
|
28
|
-
if (correlationId)
|
|
29
|
-
headers['X-Correlation-Id'] = correlationId;
|
|
30
|
-
}
|
|
31
|
-
if (config.sessionId)
|
|
32
|
-
headers['X-Session-Id'] = config.sessionId;
|
|
33
|
-
return headers;
|
|
34
|
-
}
|
|
35
|
-
function usePostSources(api, config) {
|
|
36
|
-
const { sessionId: _, ...restConfig } = config;
|
|
37
|
-
async function post(data, configOverwrites) {
|
|
38
|
-
const body = {
|
|
39
|
-
...restConfig,
|
|
40
|
-
data,
|
|
41
|
-
};
|
|
42
|
-
const headers = mergeConfig(body, config, configOverwrites);
|
|
43
|
-
const response = (0, error_1.throwIfError)(await api.POST('/sources/batch', { body, headers }));
|
|
44
|
-
return response.data;
|
|
45
|
-
}
|
|
46
|
-
return post;
|
|
47
|
-
}
|
|
48
|
-
function useIngest(api, config) {
|
|
49
|
-
const post = usePostSources(api, config);
|
|
50
|
-
return {
|
|
51
|
-
api,
|
|
52
|
-
get sessionId() {
|
|
53
|
-
return api.sessionId;
|
|
54
|
-
},
|
|
55
|
-
async sources(changes, configOverwrites) {
|
|
56
|
-
if (!changes.length)
|
|
57
|
-
return undefined;
|
|
58
|
-
return await post(changes, configOverwrites);
|
|
59
|
-
},
|
|
60
|
-
async updateSources(data, configOverwrites) {
|
|
61
|
-
const { sessionId: _, ...restConfig } = config;
|
|
62
|
-
const body = {
|
|
63
|
-
...restConfig,
|
|
64
|
-
data,
|
|
65
|
-
};
|
|
66
|
-
const headers = mergeConfig(body, config, configOverwrites);
|
|
67
|
-
const response = (0, error_1.throwIfError)(await api.PUT('/sources/batch', { body, headers }));
|
|
68
|
-
return response.data;
|
|
69
|
-
},
|
|
70
|
-
async reservations(changes, configOverwrites) {
|
|
71
|
-
if (!changes.length)
|
|
72
|
-
return [];
|
|
73
|
-
return await post(changes.map(({ source, ...transform }) => {
|
|
74
|
-
return {
|
|
75
|
-
...source,
|
|
76
|
-
type: source.type || 'reservation',
|
|
77
|
-
description: source.description || transform.confirmationCode,
|
|
78
|
-
uniqueRef: source.uniqueRef || transform.uniqueRef,
|
|
79
|
-
date: source.date || transform.bookedAt,
|
|
80
|
-
status: source.status || 'active',
|
|
81
|
-
transform: {
|
|
82
|
-
data: transform,
|
|
83
|
-
type: 'reservation',
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}), configOverwrites);
|
|
87
|
-
},
|
|
88
|
-
async payments(changes, configOverwrites) {
|
|
89
|
-
if (!changes.length)
|
|
90
|
-
return undefined;
|
|
91
|
-
return await post(changes.map(({ source, ...transform }) => {
|
|
92
|
-
return {
|
|
93
|
-
...source,
|
|
94
|
-
type: source.type || 'payment',
|
|
95
|
-
description: source.description || transform.description,
|
|
96
|
-
uniqueRef: source.uniqueRef || transform.uniqueRef,
|
|
97
|
-
date: source.date || transform.paidAt,
|
|
98
|
-
status: source.status || 'active',
|
|
99
|
-
transform: {
|
|
100
|
-
data: transform,
|
|
101
|
-
type: 'payment',
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}), configOverwrites);
|
|
105
|
-
},
|
|
106
|
-
async listings(changes, configOverwrites) {
|
|
107
|
-
if (!changes.length)
|
|
108
|
-
return undefined;
|
|
109
|
-
return await post(changes.map(({ source, ...transform }) => {
|
|
110
|
-
return {
|
|
111
|
-
...source,
|
|
112
|
-
type: source.type || 'listing',
|
|
113
|
-
description: source.description || transform.name,
|
|
114
|
-
uniqueRef: source.uniqueRef || transform.uniqueRef,
|
|
115
|
-
status: source.status || 'active',
|
|
116
|
-
transform: {
|
|
117
|
-
data: transform,
|
|
118
|
-
type: 'listing',
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}), configOverwrites);
|
|
122
|
-
},
|
|
123
|
-
async cleanup(type, configOverwrites) {
|
|
124
|
-
const body = {
|
|
125
|
-
syncId: configOverwrites?.syncId || config.syncId,
|
|
126
|
-
connectionId: configOverwrites?.connectionId || config.connectionId,
|
|
127
|
-
type,
|
|
128
|
-
};
|
|
129
|
-
if (configOverwrites?.whereRange) {
|
|
130
|
-
body.whereRange = configOverwrites.whereRange;
|
|
131
|
-
}
|
|
132
|
-
const headers = mergeConfig(body, config, configOverwrites);
|
|
133
|
-
const response = (0, error_1.throwIfError)(await api.PUT('/sources/cleanup', { body, headers }));
|
|
134
|
-
return response.ok;
|
|
135
|
-
},
|
|
136
|
-
async bankRecords(changes, configOverwrites) {
|
|
137
|
-
if (!changes.length)
|
|
138
|
-
return undefined;
|
|
139
|
-
return await post(changes.map(({ source, ...transform }) => {
|
|
140
|
-
return {
|
|
141
|
-
...source,
|
|
142
|
-
type: source.type || 'bankRecord',
|
|
143
|
-
description: source.description || transform.description,
|
|
144
|
-
uniqueRef: source.uniqueRef || transform.uniqueRef,
|
|
145
|
-
status: source.status || 'active',
|
|
146
|
-
transform: {
|
|
147
|
-
data: transform,
|
|
148
|
-
type: 'bankRecord',
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
}), configOverwrites);
|
|
152
|
-
},
|
|
153
|
-
async transactions(changes, configOverwrites) {
|
|
154
|
-
if (!changes.length)
|
|
155
|
-
return undefined;
|
|
156
|
-
return await post(changes.map(({ source, ...transform }) => {
|
|
157
|
-
return {
|
|
158
|
-
...source,
|
|
159
|
-
type: source.type || 'transaction',
|
|
160
|
-
description: source.description || transform.description,
|
|
161
|
-
uniqueRef: source.uniqueRef || transform.uniqueRef,
|
|
162
|
-
status: source.status || 'active',
|
|
163
|
-
transform: {
|
|
164
|
-
data: transform,
|
|
165
|
-
type: 'transaction',
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}), configOverwrites);
|
|
169
|
-
},
|
|
170
|
-
async contacts(changes, configOverwrites) {
|
|
171
|
-
if (!changes.length)
|
|
172
|
-
return undefined;
|
|
173
|
-
return await post(changes.map(({ source, ...transform }) => {
|
|
174
|
-
return {
|
|
175
|
-
...source,
|
|
176
|
-
type: source.type || 'contact',
|
|
177
|
-
description: source.description || transform.name,
|
|
178
|
-
uniqueRef: source.uniqueRef || transform.email,
|
|
179
|
-
status: source.status || 'active',
|
|
180
|
-
transform: {
|
|
181
|
-
data: transform,
|
|
182
|
-
type: 'contact',
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
}), configOverwrites);
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["ingest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBA,wCAiBC;AAED,8BAwLC;AAlOD,oCAAwC;AAIxC,0CAAwB;AAExB,SAAS,WAAW,CAClB,IAAS,EACT,MAAmB,EACnB,gBAAgC;IAEhC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,EAAE,aAAa,EAAE,GAAG,cAAc,EAAE,GAAG,gBAAgB,CAAC;QAC9D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;YACvD,IAAI,KAAK;gBAAE,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC/B,IAAI,aAAa;YAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,aAAa,CAAC;IACjE,CAAC;IACD,IAAI,MAAM,CAAC,SAAS;QAAE,OAAO,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC;IAEjE,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,c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AAS,CAAC,WAAW;oBACxD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS,CAAC,SAAU;oBACnD,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;oBACjC,SAAS,EAAE;wBACT,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,aAAa;qBACpB;iBACF,CAAC;YACJ,CAAC,CAAC,EACF,gBAAgB,CACjB,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,QAAQ,CACZ,OAA+B,EAC/B,gBAAgC;YAEhC,IAAI,CAAC,OAAO,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAC;YACtC,OAAO,MAAM,IAAI,CACf,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;gBACvC,OAAO;oBACL,GAAG,MAAM;oBACT,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS;oBAC9B,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI;oBACjD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS,CAAC,KAAM;oBAC/C,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;oBACjC,SAAS,EAAE;wBACT,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;qBAChB;iBACF,CAAC;YACJ,CAAC,CAAC,EACF,gBAAgB,CACjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { throwIfError } from '../error';\nimport type { ApiClient, RequestBody } from '../types';\nimport type * as t from './types';\n\nexport * from './types';\n\nfunction mergeConfig(\n body: any,\n config: t.IngestArg,\n configOverwrites?: t.IngestFnArg\n) {\n const headers: Record<string, string> = {};\n if (configOverwrites) {\n const { correlationId, ...restOverwrites } = configOverwrites;\n for (const [key, value] of Object.entries(restOverwrites))\n if (value) body[key] = value;\n if (correlationId) headers['X-Correlation-Id'] = correlationId;\n }\n if (config.sessionId) headers['X-Session-Id'] = config.sessionId;\n\n return headers;\n}\n\nexport function usePostSources(api: ApiClient, config: t.IngestArg) {\n const { sessionId: _, ...restConfig } = config;\n async function post<T = undefined>(\n data: RequestBody<'post:/sources/batch'>['data'],\n configOverwrites?: t.IngestFnArg\n ): Promise<t.TypedResponseData<T>[]> {\n const body: RequestBody<'post:/sources/batch'> = {\n ...restConfig,\n data,\n };\n const headers = mergeConfig(body, config, configOverwrites);\n const response = throwIfError(\n await api.POST('/sources/batch', { body, headers })\n );\n return response.data as any;\n }\n return post;\n}\n\nexport function useIngest(api: ApiClient, config: t.IngestArg) {\n const post = usePostSources(api, config);\n return {\n api,\n get sessionId() {\n return api.sessionId;\n },\n async sources(\n changes: t.IngestSourceInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post(changes, configOverwrites);\n },\n async updateSources(\n data: RequestBody<'put:/sources/batch'>['data'],\n configOverwrites?: t.IngestFnArg\n ) {\n const { sessionId: _, ...restConfig } = config;\n const body: RequestBody<'put:/sources/batch'> = {\n ...restConfig,\n data,\n };\n const headers = mergeConfig(body, config, configOverwrites);\n const response = throwIfError(\n await api.PUT('/sources/batch', { body, headers })\n );\n return response.data;\n },\n async reservations(\n changes: t.IngestReservationInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return [];\n return await post<t.ReservationParam>(\n changes.map(({ source, ...transform }) => {\n return {\n ...source,\n type: source.type || 'reservation',\n description: source.description || transform.confirmationCode,\n uniqueRef: source.uniqueRef || transform.uniqueRef!,\n date: source.date || transform.bookedAt,\n status: source.status || 'active',\n transform: {\n data: transform,\n type: 'reservation',\n },\n };\n }),\n configOverwrites\n );\n },\n async payments(\n changes: t.IngestPaymentInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<t.PaymentParam>(\n changes.map(({ source, ...transform }) => {\n return {\n ...source,\n type: source.type || 'payment',\n description: source.description || transform.description,\n uniqueRef: source.uniqueRef || transform.uniqueRef!,\n date: source.date || transform.paidAt,\n status: source.status || 'active',\n transform: {\n data: transform,\n type: 'payment',\n },\n };\n }),\n configOverwrites\n );\n },\n async listings(\n changes: t.IngestListingInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<t.ListingParam>(\n changes.map(({ source, ...transform }) => {\n return {\n ...source,\n type: source.type || 'listing',\n description: source.description || transform.name,\n uniqueRef: source.uniqueRef || transform.uniqueRef!,\n status: source.status || 'active',\n transform: {\n data: transform,\n type: 'listing',\n },\n };\n }),\n configOverwrites\n );\n },\n async cleanup(\n type: string | 'listing',\n configOverwrites?: t.IngestFnArg & {\n whereRange?: RequestBody<'put:/sources/cleanup'>['whereRange'];\n }\n ) {\n const body: RequestBody<'put:/sources/cleanup'> = {\n syncId: configOverwrites?.syncId || config.syncId,\n connectionId: configOverwrites?.connectionId || config.connectionId,\n type,\n };\n if (configOverwrites?.whereRange) {\n body.whereRange = configOverwrites.whereRange;\n }\n const headers = mergeConfig(body, config, configOverwrites);\n const response = throwIfError(\n await api.PUT('/sources/cleanup', { body, headers })\n );\n return response.ok as any;\n },\n async bankRecords(\n changes: t.IngestBankRecordInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<t.BankRecordParam>(\n changes.map(({ source, ...transform }) => {\n return {\n ...source,\n type: source.type || 'bankRecord',\n description: source.description || transform.description,\n uniqueRef: source.uniqueRef || transform.uniqueRef!,\n status: source.status || 'active',\n transform: {\n data: transform,\n type: 'bankRecord',\n },\n };\n }),\n configOverwrites\n );\n },\n async transactions(\n changes: t.IngestTransactionInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<t.TransactionParam>(\n changes.map(({ source, ...transform }) => {\n return {\n ...source,\n type: source.type || 'transaction',\n description: source.description || transform.description,\n uniqueRef: source.uniqueRef || transform.uniqueRef!,\n status: source.status || 'active',\n transform: {\n data: transform,\n type: 'transaction',\n },\n };\n }),\n configOverwrites\n );\n },\n async contacts(\n changes: t.IngestContactInput[],\n configOverwrites?: t.IngestFnArg\n ) {\n if (!changes.length) return undefined;\n return await post<t.ContactParam>(\n changes.map(({ source, ...transform }) => {\n return {\n ...source,\n type: source.type || 'contact',\n description: source.description || transform.name,\n uniqueRef: source.uniqueRef || transform.email!,\n status: source.status || 'active',\n transform: {\n data: transform,\n type: 'contact',\n },\n };\n }),\n configOverwrites\n );\n },\n };\n}\n"]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { PartialBy } from '@vrplatform/utils';
|
|
2
|
-
import type { RequestBody, ResponseData } from '../types';
|
|
3
|
-
export type ReservationParam = Omit<RequestBody<'post:/reservations/batch'>['data'][0], 'sourceId'>;
|
|
4
|
-
export type PaymentParam = Omit<RequestBody<'post:/payments/batch'>['data'][0], 'sourceId'>;
|
|
5
|
-
export type ListingParam = Omit<RequestBody<'post:/listings/batch'>['data'][0], 'sourceId'>;
|
|
6
|
-
export type BankRecordParam = Omit<RequestBody<'post:/bank-records/batch'>['data'][0], 'sourceId'>;
|
|
7
|
-
export type TransactionParam = Omit<RequestBody<'post:/transactions/batch'>['data'][0], 'sourceId'>;
|
|
8
|
-
export type ContactParam = Omit<RequestBody<'post:/contacts/batch'>['data'][0], 'sourceId'>;
|
|
9
|
-
type _SourceWithoutTransform = Omit<RequestBody<'post:/sources/batch'>['data'][number], 'transform'> & {
|
|
10
|
-
fileStorageId?: string;
|
|
11
|
-
};
|
|
12
|
-
type _SourceWithTransform<T> = _SourceWithoutTransform & {
|
|
13
|
-
transform: {
|
|
14
|
-
type: string;
|
|
15
|
-
data: T;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export type Source<T = undefined> = T extends undefined ? _SourceWithoutTransform : _SourceWithTransform<T>;
|
|
19
|
-
export type IngestArg = Omit<RequestBody<'post:/sources/batch'>, 'data'> & {
|
|
20
|
-
sessionId?: string;
|
|
21
|
-
tenantId: string;
|
|
22
|
-
};
|
|
23
|
-
export type IngestFnArg = Omit<Partial<IngestArg>, 'sessionId'> & {
|
|
24
|
-
correlationId?: string;
|
|
25
|
-
};
|
|
26
|
-
export type BatchResponseData = ResponseData<'post:/sources/batch'>['data'][0];
|
|
27
|
-
export type TypedResponseData<T = undefined> = Omit<BatchResponseData, 'transform'> & (T extends undefined ? {
|
|
28
|
-
transform?: never;
|
|
29
|
-
} : {
|
|
30
|
-
transform: Omit<BatchResponseData['transform'], 'data'> & {
|
|
31
|
-
data: T;
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
export type Impossible<K extends keyof any> = {
|
|
35
|
-
[P in K]: never;
|
|
36
|
-
};
|
|
37
|
-
export type NoExtraProperties<T, U extends T = T> = U & Impossible<Exclude<keyof U, keyof T>>;
|
|
38
|
-
export type ObjectWithSource<T = undefined> = T & {
|
|
39
|
-
source: PartialBy<_SourceWithoutTransform, 'type'>;
|
|
40
|
-
};
|
|
41
|
-
export type IngestReservationInput = NoExtraProperties<ObjectWithSource<ReservationParam>>;
|
|
42
|
-
export type IngestPaymentInput = NoExtraProperties<ObjectWithSource<PaymentParam>>;
|
|
43
|
-
export type IngestListingInput = NoExtraProperties<ObjectWithSource<ListingParam>>;
|
|
44
|
-
export type IngestBankRecordInput = NoExtraProperties<ObjectWithSource<BankRecordParam>>;
|
|
45
|
-
export type IngestTransactionInput = NoExtraProperties<ObjectWithSource<TransactionParam>>;
|
|
46
|
-
export type IngestContactInput = NoExtraProperties<ObjectWithSource<ContactParam>>;
|
|
47
|
-
export type IngestSourceInput = NoExtraProperties<Source>;
|
|
48
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"src/","sources":["ingest/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { PartialBy } from '@vrplatform/utils';\nimport type { RequestBody, ResponseData } from '../types';\n\nexport type ReservationParam = Omit<\n RequestBody<'post:/reservations/batch'>['data'][0],\n 'sourceId'\n>;\nexport type PaymentParam = Omit<\n RequestBody<'post:/payments/batch'>['data'][0],\n 'sourceId'\n>;\nexport type ListingParam = Omit<\n RequestBody<'post:/listings/batch'>['data'][0],\n 'sourceId'\n>;\nexport type BankRecordParam = Omit<\n RequestBody<'post:/bank-records/batch'>['data'][0],\n 'sourceId'\n>;\nexport type TransactionParam = Omit<\n RequestBody<'post:/transactions/batch'>['data'][0],\n 'sourceId'\n>;\nexport type ContactParam = Omit<\n RequestBody<'post:/contacts/batch'>['data'][0],\n 'sourceId'\n>;\ntype _SourceWithoutTransform = Omit<\n RequestBody<'post:/sources/batch'>['data'][number],\n 'transform'\n> & {\n // this is ONLY for ecosystem ingestion, can be removed once ecosystem does not rely on ingest, but calls batch endpoints\n fileStorageId?: string;\n};\ntype _SourceWithTransform<T> = _SourceWithoutTransform & {\n transform: { type: string; data: T };\n};\nexport type Source<T = undefined> = T extends undefined\n ? _SourceWithoutTransform\n : _SourceWithTransform<T>;\n\nexport type IngestArg = Omit<RequestBody<'post:/sources/batch'>, 'data'> & {\n sessionId?: string;\n tenantId: string;\n};\nexport type IngestFnArg = Omit<Partial<IngestArg>, 'sessionId'> & {\n correlationId?: string;\n};\n\nexport type BatchResponseData = ResponseData<'post:/sources/batch'>['data'][0];\nexport type TypedResponseData<T = undefined> = Omit<\n BatchResponseData,\n 'transform'\n> &\n (T extends undefined\n ? { transform?: never }\n : {\n transform: Omit<BatchResponseData['transform'], 'data'> & {\n data: T;\n };\n });\n\nexport type Impossible<K extends keyof any> = {\n [P in K]: never;\n};\nexport type NoExtraProperties<T, U extends T = T> = U &\n Impossible<Exclude<keyof U, keyof T>>;\n\nexport type ObjectWithSource<T = undefined> = T & {\n source: PartialBy<_SourceWithoutTransform, 'type'>;\n};\n\nexport type IngestReservationInput = NoExtraProperties<\n ObjectWithSource<ReservationParam>\n>;\nexport type IngestPaymentInput = NoExtraProperties<\n ObjectWithSource<PaymentParam>\n>;\nexport type IngestListingInput = NoExtraProperties<\n ObjectWithSource<ListingParam>\n>;\nexport type IngestBankRecordInput = NoExtraProperties<\n ObjectWithSource<BankRecordParam>\n>;\nexport type IngestTransactionInput = NoExtraProperties<\n ObjectWithSource<TransactionParam>\n>;\nexport type IngestContactInput = NoExtraProperties<\n ObjectWithSource<ContactParam>\n>;\nexport type IngestSourceInput = NoExtraProperties<Source>;\n"]}
|
|
@@ -1,13 +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 declare function useIngestCompat(api: ApiClient, config: IngestArg): {
|
|
7
|
-
api: ApiClient;
|
|
8
|
-
readonly sessionId: string;
|
|
9
|
-
sources(changes: Source[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<undefined>[] | undefined>;
|
|
10
|
-
reservations(changes: PartialBy<Source<ReservationInput>, "type">[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<ReservationInput>[]>;
|
|
11
|
-
payments(changes: PartialBy<Source<PaymentInput>, "type">[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<PaymentInput>[] | undefined>;
|
|
12
|
-
listings(changes: PartialBy<Source<ListingInput>, "type">[], configOverwrites?: IngestFnArg): Promise<import("../ingest").TypedResponseData<ListingInput>[] | undefined>;
|
|
13
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useIngestCompat = useIngestCompat;
|
|
18
|
-
const ingest_1 = require("../ingest");
|
|
19
|
-
const map_1 = require("./map");
|
|
20
|
-
__exportStar(require("./map"), exports);
|
|
21
|
-
__exportStar(require("./types"), exports);
|
|
22
|
-
function useIngestCompat(api, config) {
|
|
23
|
-
const post = (0, ingest_1.usePostSources)(api, config);
|
|
24
|
-
return {
|
|
25
|
-
api,
|
|
26
|
-
get sessionId() {
|
|
27
|
-
return api.sessionId;
|
|
28
|
-
},
|
|
29
|
-
async sources(changes, configOverwrites) {
|
|
30
|
-
if (!changes.length)
|
|
31
|
-
return undefined;
|
|
32
|
-
return await post(changes, configOverwrites);
|
|
33
|
-
},
|
|
34
|
-
async reservations(changes, configOverwrites) {
|
|
35
|
-
if (!changes.length)
|
|
36
|
-
return [];
|
|
37
|
-
return await post(changes.map(({ transform, ...source }) => {
|
|
38
|
-
const data = map_1.mapTransform.reservation(transform.data);
|
|
39
|
-
return {
|
|
40
|
-
...source,
|
|
41
|
-
type: source.type || 'reservation',
|
|
42
|
-
description: source.description || data.confirmationCode,
|
|
43
|
-
uniqueRef: source.uniqueRef || data.uniqueRef,
|
|
44
|
-
date: source.date || data.bookedAt,
|
|
45
|
-
status: source.status || 'active',
|
|
46
|
-
transform: {
|
|
47
|
-
data,
|
|
48
|
-
type: 'reservation',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}), configOverwrites);
|
|
52
|
-
},
|
|
53
|
-
async payments(changes, configOverwrites) {
|
|
54
|
-
if (!changes.length)
|
|
55
|
-
return undefined;
|
|
56
|
-
return await post(changes.map(({ transform, ...source }) => {
|
|
57
|
-
const data = map_1.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
|
-
}), configOverwrites);
|
|
71
|
-
},
|
|
72
|
-
async listings(changes, configOverwrites) {
|
|
73
|
-
if (!changes.length)
|
|
74
|
-
return undefined;
|
|
75
|
-
return await post(changes.map(({ transform, ...source }) => {
|
|
76
|
-
const data = map_1.mapTransform.listing(transform.data);
|
|
77
|
-
return {
|
|
78
|
-
...source,
|
|
79
|
-
type: source.type || 'listing',
|
|
80
|
-
description: source.description || data.name,
|
|
81
|
-
uniqueRef: source.uniqueRef || data.uniqueRef,
|
|
82
|
-
status: source.status || 'active',
|
|
83
|
-
transform: {
|
|
84
|
-
data,
|
|
85
|
-
type: 'listing',
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}), configOverwrites);
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["ingest-compat/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAcA,0CAmFC;AAjGD,sCAMmB;AAEnB,+BAAqC;AAGrC,wCAAsB;AACtB,0CAAwB;AAExB,SAAgB,eAAe,CAAC,GAAc,EAAE,MAAiB;IAC/D,MAAM,IAAI,GAAG,IAAA,uBAAc,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO;QACL,GAAG;QACH,I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esContent":["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 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,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapTransform = void 0;
|
|
4
|
-
exports.mapTransform = {
|
|
5
|
-
reservation: ({ id, uniqueRef, cancelledAt, status, listingConnectionId, listingConnectionRef, guestName, checkIn, checkOut, metadata, currency, bookedAt, bookingPlatform, pmsReferenceCode, bookerName, guests, confirmationCode, paymentLines, centTotal: _, nights: __, sourceId: ___, }) => ({
|
|
6
|
-
id,
|
|
7
|
-
uniqueRef,
|
|
8
|
-
cancelledAt,
|
|
9
|
-
status: status === 'inactive' ? null : status,
|
|
10
|
-
listingId: listingConnectionId?.toString() || listingConnectionRef?.toString(),
|
|
11
|
-
guestName,
|
|
12
|
-
checkIn,
|
|
13
|
-
checkOut,
|
|
14
|
-
metadata,
|
|
15
|
-
currency,
|
|
16
|
-
bookedAt,
|
|
17
|
-
bookingPlatform,
|
|
18
|
-
pmsReferenceCode,
|
|
19
|
-
bookerName,
|
|
20
|
-
guests,
|
|
21
|
-
confirmationCode,
|
|
22
|
-
lines: paymentLines?.map((line) => ({
|
|
23
|
-
type: line.type2,
|
|
24
|
-
amount: line.centTotal || 0,
|
|
25
|
-
uniqueRef: line.uniqueRef,
|
|
26
|
-
description: line.description,
|
|
27
|
-
metadata: line.metadata,
|
|
28
|
-
})) || [],
|
|
29
|
-
}),
|
|
30
|
-
payment: ({ currency, description, uniqueRef, payedAt, etaAt, metadata, lines, }) => ({
|
|
31
|
-
uniqueRef,
|
|
32
|
-
metadata,
|
|
33
|
-
currency,
|
|
34
|
-
paidAt: payedAt,
|
|
35
|
-
etaAt,
|
|
36
|
-
description: description ?? 'Payment',
|
|
37
|
-
lines: lines?.map((line) => ({
|
|
38
|
-
type: line.type2,
|
|
39
|
-
amount: line.centTotal || 0,
|
|
40
|
-
uniqueRef: line.uniqueRef,
|
|
41
|
-
description: line.description,
|
|
42
|
-
metadata: line.metadata,
|
|
43
|
-
})) || [],
|
|
44
|
-
}),
|
|
45
|
-
listing: (item) => {
|
|
46
|
-
let status = item.status === 'disabled'
|
|
47
|
-
? 'inactive'
|
|
48
|
-
: item.status === 'enabled'
|
|
49
|
-
? 'active'
|
|
50
|
-
: item.status;
|
|
51
|
-
if (!item.status && item.pmsStatus) {
|
|
52
|
-
status =
|
|
53
|
-
item.pmsStatus === 'disabled' || item.pmsStatus === 'inactive'
|
|
54
|
-
? 'inactive'
|
|
55
|
-
: item.pmsStatus === 'enabled' || item.pmsStatus === 'active'
|
|
56
|
-
? 'active'
|
|
57
|
-
: null;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
name: `${item.name}`,
|
|
61
|
-
status: status || 'active',
|
|
62
|
-
uniqueRef: item.uniqueRef,
|
|
63
|
-
defaultCurrency: item.defaultCurrency,
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=map.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sourceRoot":"src/","sources":["ingest-compat/map.ts"],"names":[],"mappings":";;;AAUa,QAAA,YAAY,GAAG;IAC1B,WAAW,EAAE,CAAC,EACZ,E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nB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACX,IAAI,EAAE,IAAI,CAAC,KAAM;YACjB,MAAM,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC,IAAI,EAAE;KACZ,CAAC;IACF,OAAO,EAAE,CAAC,IAAkB,EAAiB,EAAE;QAC7C,IAAI,MAAM,GACR,IAAI,CAAC,MAAM,KAAK,UAAU;YACxB,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS;gBACzB,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnC,MAAM;gBACJ,IAAI,CAAC,SAAS,KAAK,UAAU,IAAI,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,7 +0,0 @@
|
|
|
1
|
-
import type { RequestBody } from '../types';
|
|
2
|
-
export type ReservationInput = Record<string, any>;
|
|
3
|
-
export type ReservationOutput = RequestBody<'post:/reservations/batch'>['data'][0];
|
|
4
|
-
export type PaymentInput = Record<string, any>;
|
|
5
|
-
export type PaymentOutput = RequestBody<'post:/payments/batch'>['data'][0];
|
|
6
|
-
export type ListingInput = Record<string, any>;
|
|
7
|
-
export type ListingOutput = RequestBody<'post:/listings/batch'>['data'][0];
|
|
@@ -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 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,21 +0,0 @@
|
|
|
1
|
-
import type { ApiClient, RequestBody } from '../types';
|
|
2
|
-
import type * as t from './types';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export declare function usePostSources(api: ApiClient, config: t.IngestArg): <T = undefined>(data: RequestBody<"post:/sources/batch">["data"], configOverwrites?: t.IngestFnArg) => Promise<t.TypedResponseData<T>[]>;
|
|
5
|
-
export declare function useIngest(api: ApiClient, config: t.IngestArg): {
|
|
6
|
-
api: ApiClient;
|
|
7
|
-
readonly sessionId: string;
|
|
8
|
-
sources(changes: t.IngestSourceInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<undefined>[] | undefined>;
|
|
9
|
-
updateSources(data: RequestBody<"put:/sources/batch">["data"], configOverwrites?: t.IngestFnArg): Promise<{
|
|
10
|
-
id: string;
|
|
11
|
-
}[]>;
|
|
12
|
-
reservations(changes: t.IngestReservationInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.ReservationParam>[]>;
|
|
13
|
-
payments(changes: t.IngestPaymentInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.PaymentParam>[] | undefined>;
|
|
14
|
-
listings(changes: t.IngestListingInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.ListingParam>[] | undefined>;
|
|
15
|
-
cleanup(type: string | "listing", configOverwrites?: t.IngestFnArg & {
|
|
16
|
-
whereRange?: RequestBody<"put:/sources/cleanup">["whereRange"];
|
|
17
|
-
}): Promise<any>;
|
|
18
|
-
bankRecords(changes: t.IngestBankRecordInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.BankRecordParam>[] | undefined>;
|
|
19
|
-
transactions(changes: t.IngestTransactionInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.TransactionParam>[] | undefined>;
|
|
20
|
-
contacts(changes: t.IngestContactInput[], configOverwrites?: t.IngestFnArg): Promise<t.TypedResponseData<t.ContactParam>[] | undefined>;
|
|
21
|
-
};
|