@vrplatform/api 1.2.33 → 1.2.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main/client.d.ts +1 -1
- package/build/main/client.js +1 -1
- package/build/main/client.js.map +1 -1
- package/build/main/error.js +1 -1
- package/build/main/error.js.map +1 -1
- package/build/main/generated/openapi-fetch.d.ts +1 -1
- package/build/main/generated/openapi-fetch.js.map +1 -1
- package/build/main/generated/v1.d.ts +10139 -9185
- package/build/main/generated/v1.js.map +1 -1
- package/build/main/index.d.ts +4 -3
- package/build/main/index.js +0 -3
- package/build/main/index.js.map +1 -1
- package/build/main/ingest/index.d.ts +0 -2
- package/build/main/ingest/index.js.map +1 -1
- package/build/main/ingest/types.d.ts +1 -1
- package/build/main/ingest/types.js.map +1 -1
- package/build/main/ingest-compat/index.d.ts +0 -1
- package/build/main/ingest-compat/index.js.map +1 -1
- package/build/main/ingest-compat/types.d.ts +0 -1
- package/build/main/ingest-compat/types.js.map +1 -1
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/types.d.ts +0 -1
- package/build/main/types.js.map +1 -1
- package/build/module/client.d.ts +1 -1
- package/build/module/client.js +1 -1
- package/build/module/client.js.map +1 -1
- package/build/module/error.js +1 -1
- package/build/module/error.js.map +1 -1
- package/build/module/generated/openapi-fetch.d.ts +1 -1
- package/build/module/generated/openapi-fetch.js.map +1 -1
- package/build/module/generated/v1.d.ts +10139 -9185
- package/build/module/generated/v1.js.map +1 -1
- package/build/module/index.d.ts +4 -3
- package/build/module/index.js +0 -3
- package/build/module/index.js.map +1 -1
- package/build/module/ingest/index.d.ts +0 -2
- package/build/module/ingest/index.js.map +1 -1
- package/build/module/ingest/types.d.ts +1 -1
- package/build/module/ingest/types.js.map +1 -1
- package/build/module/ingest-compat/index.d.ts +0 -1
- package/build/module/ingest-compat/index.js.map +1 -1
- package/build/module/ingest-compat/types.d.ts +0 -1
- package/build/module/ingest-compat/types.js.map +1 -1
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/types.d.ts +0 -1
- package/build/module/types.js.map +1 -1
- package/package.json +14 -8
- package/src/client.ts +4 -1
- package/src/error.ts +1 -1
- package/src/generated/openapi-fetch.ts +1 -1
- package/src/generated/v1.ts +10139 -9185
- package/src/index.ts +6 -4
- package/src/ingest/index.ts +0 -4
- package/src/ingest/types.ts +1 -1
- package/src/types.ts +0 -1
- package/build/main/fetcher.d.ts +0 -18
- package/build/main/fetcher.js +0 -68
- package/build/main/fetcher.js.map +0 -1
- package/build/main/headers.d.ts +0 -18
- package/build/main/headers.js +0 -25
- package/build/main/headers.js.map +0 -1
- package/build/main/middlewares/curl.d.ts +0 -6
- package/build/main/middlewares/curl.js +0 -20
- package/build/main/middlewares/curl.js.map +0 -1
- package/build/main/middlewares/index.d.ts +0 -1
- package/build/main/middlewares/index.js +0 -18
- package/build/main/middlewares/index.js.map +0 -1
- package/build/main/retryable-errors.d.ts +0 -9
- package/build/main/retryable-errors.js +0 -38
- package/build/main/retryable-errors.js.map +0 -1
- package/build/module/fetcher.d.ts +0 -18
- package/build/module/fetcher.js +0 -63
- package/build/module/fetcher.js.map +0 -1
- package/build/module/headers.d.ts +0 -18
- package/build/module/headers.js +0 -23
- package/build/module/headers.js.map +0 -1
- package/build/module/middlewares/curl.d.ts +0 -6
- package/build/module/middlewares/curl.js +0 -16
- package/build/module/middlewares/curl.js.map +0 -1
- package/build/module/middlewares/index.d.ts +0 -1
- package/build/module/middlewares/index.js +0 -2
- package/build/module/middlewares/index.js.map +0 -1
- package/build/module/retryable-errors.d.ts +0 -9
- package/build/module/retryable-errors.js +0 -34
- package/build/module/retryable-errors.js.map +0 -1
- package/src/ingest-compat/index.ts +0 -99
- package/src/ingest-compat/map.ts +0 -111
- package/src/ingest-compat/types.ts +0 -11
- package/src/middlewares/curl.ts +0 -23
- package/src/middlewares/index.ts +0 -1
package/build/module/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { useIngest } from './ingest';
|
|
2
|
+
import type { ApiClient } from './types';
|
|
1
3
|
export * from './client';
|
|
2
4
|
export * from './error';
|
|
3
5
|
export * from './generated/v1';
|
|
4
6
|
export * from './ingest';
|
|
5
|
-
export * from './ingest';
|
|
6
|
-
export * from './ingest-compat';
|
|
7
|
-
export * from './middlewares';
|
|
8
7
|
export * from './types';
|
|
8
|
+
export type ApiIngest = ReturnType<typeof useIngest>;
|
|
9
|
+
export type VRPlatformApi = ApiClient;
|
package/build/module/index.js
CHANGED
|
@@ -2,8 +2,5 @@ export * from './client';
|
|
|
2
2
|
export * from './error';
|
|
3
3
|
export * from './generated/v1';
|
|
4
4
|
export * from './ingest';
|
|
5
|
-
export * from './ingest';
|
|
6
|
-
export * from './ingest-compat';
|
|
7
|
-
export * from './middlewares';
|
|
8
5
|
export * from './types';
|
|
9
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAGA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC","sourcesContent":["import type { useIngest } from './ingest';\nimport type { ApiClient } from './types';\n\nexport * from './client';\nexport * from './error';\nexport * from './generated/v1';\nexport * from './ingest';\nexport * from './types';\n\nexport type ApiIngest = ReturnType<typeof useIngest>;\nexport type VRPlatformApi = ApiClient;\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { ApiClient, RequestBody } from '../types';
|
|
2
2
|
import type * as t from './types';
|
|
3
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
4
3
|
export * from './types';
|
|
5
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>[]>;
|
|
6
|
-
export type ApiIngest = ReturnType<typeof useIngest>;
|
|
7
5
|
export declare function useIngest(api: ApiClient, config: t.IngestArg): {
|
|
8
6
|
api: ApiClient;
|
|
9
7
|
readonly sessionId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["ingest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMxC,cAAc,SAAS,CAAC;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,MAAM,UAAU,cAAc,CAAC,GAAc,EAAE,MAAmB;IAChE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAC/C,KAAK,UAAU,IAAI,CACjB,IAAgD,EAChD,gBAAgC;QAEhC,MAAM,IAAI,GAAuC;YAC/C,GAAG,UAAU;YACb,IAAI;SACL,CAAC;QACF,MAAM,OAAO,GAAG,WAAW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D,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 type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\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 type ApiIngest = ReturnType<typeof useIngest>;\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
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["ingest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,cAAc,SAAS,CAAC;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,MAAM,UAAU,cAAc,CAAC,GAAc,EAAE,MAAmB;IAChE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAC/C,KAAK,UAAU,IAAI,CACjB,IAAgD,EAChD,gBAAgC;QAEhC,MAAM,IAAI,GAAuC;YAC/C,GAAG,UAAU;YACb,IAAI;SACL,CAAC;QACF,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,YAAY,CAC3B,MAAM,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI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,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,4 +1,4 @@
|
|
|
1
|
-
import type { PartialBy } from '@
|
|
1
|
+
import type { PartialBy } from '@vrplatform/utils';
|
|
2
2
|
import type { RequestBody, ResponseData } from '../types';
|
|
3
3
|
export type ReservationParam = Omit<RequestBody<'post:/reservations/batch'>['data'][0], 'sourceId'>;
|
|
4
4
|
export type PaymentParam = Omit<RequestBody<'post:/payments/batch'>['data'][0], 'sourceId'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"src/","sources":["ingest/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { PartialBy } from '@
|
|
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"]}
|
|
@@ -3,7 +3,6 @@ import type { ApiClient } from '../types';
|
|
|
3
3
|
import type { ListingInput, PaymentInput, ReservationInput } from './types';
|
|
4
4
|
export * from './map';
|
|
5
5
|
export * from './types';
|
|
6
|
-
export type ApiIngestCompat = ReturnType<typeof useIngestCompat>;
|
|
7
6
|
export declare function useIngestCompat(api: ApiClient, config: IngestArg): {
|
|
8
7
|
api: ApiClient;
|
|
9
8
|
readonly sessionId: string;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","s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EAAE,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI;oBAC5C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,SAAU;oBAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;oBACjC,SAAS,EAAE;wBACT,IAAI;wBACJ,IAAI,EAAE,SAAS;qBAChB;iBACF,CAAC;YACJ,CAAC,CAAC,EACF,gBAAgB,CACjB,CAAC;QACJ,CAAC;KACF,CAAC;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 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,5 +1,4 @@
|
|
|
1
1
|
import type { RequestBody } from '../types';
|
|
2
|
-
export type PaymentLine = Record<string, any>;
|
|
3
2
|
export type ReservationInput = Record<string, any>;
|
|
4
3
|
export type ReservationOutput = RequestBody<'post:/reservations/batch'>['data'][0];
|
|
5
4
|
export type PaymentInput = Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"src/","sources":["ingest-compat/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RequestBody } from '../types';\n\nexport type
|
|
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 +1 @@
|
|
|
1
|
-
{"root":["../../src/cache.ts","../../src/client.ts","../../src/error.ts","../../src/index.ts","../../src/sec.ts","../../src/types.ts","../../src/generated/openapi-fetch.ts","../../src/generated/v1.ts","../../src/ingest/index.ts","../../src/ingest/types.ts"
|
|
1
|
+
{"root":["../../src/cache.ts","../../src/client.ts","../../src/error.ts","../../src/index.ts","../../src/sec.ts","../../src/types.ts","../../src/generated/openapi-fetch.ts","../../src/generated/v1.ts","../../src/ingest/index.ts","../../src/ingest/types.ts"],"version":"5.9.3"}
|
package/build/module/types.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export type ApiClientAuth = {
|
|
|
9
9
|
export type ApiClient = ReturnType<typeof createClient<paths>> & {
|
|
10
10
|
sessionId: string;
|
|
11
11
|
};
|
|
12
|
-
export type VRPlatformApi = ApiClient;
|
|
13
12
|
type ResponseCombinations = {
|
|
14
13
|
[Path in keyof paths]: {
|
|
15
14
|
[Method in keyof paths[Path]]: paths[Path][Method] extends never ? never : paths[Path][Method] extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type createClient from 'openapi-fetch';\nimport type { paths } from './generated/v1';\n\nexport type ApiClientAuth = {\n apiKey?: string;\n sec?: string;\n tenantId?: string;\n accessToken?: string;\n};\nexport type ApiClient = ReturnType<typeof createClient<paths>> & {\n sessionId: string;\n};\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type createClient from 'openapi-fetch';\nimport type { paths } from './generated/v1';\n\nexport type ApiClientAuth = {\n apiKey?: string;\n sec?: string;\n tenantId?: string;\n accessToken?: string;\n};\nexport type ApiClient = ReturnType<typeof createClient<paths>> & {\n sessionId: string;\n};\ntype ResponseCombinations = {\n [Path in keyof paths]: {\n [Method in keyof paths[Path]]: paths[Path][Method] extends never\n ? never\n : paths[Path][Method] extends {\n responses: {\n 200: { content: { 'application/json': unknown } };\n };\n }\n ? `${Method & string}:${Path}`\n : never;\n }[keyof paths[Path]];\n}[keyof paths];\n\nexport type ResponseData<T extends ResponseCombinations> =\n T extends `${infer Method}:${infer Path}`\n ? Path extends keyof paths\n ? Method extends keyof paths[Path]\n ? paths[Path][Method] extends {\n responses: {\n 200: { content: { 'application/json': infer Data } };\n };\n }\n ? Data\n : never\n : never\n : never\n : never;\n\ntype RequestBodyCombinations = {\n [Path in keyof paths]: {\n [Method in keyof paths[Path]]: paths[Path][Method] extends never\n ? never\n : paths[Path][Method] extends {\n requestBody: {\n content: { 'application/json': unknown };\n };\n }\n ? `${Method & string}:${Path}`\n : never;\n }[keyof paths[Path]];\n}[keyof paths];\n\nexport type RequestBody<T extends RequestBodyCombinations> =\n T extends `${infer Method}:${infer Path}`\n ? Path extends keyof paths\n ? Method extends keyof paths[Path]\n ? paths[Path][Method] extends {\n requestBody: {\n content: { 'application/json': infer Data };\n };\n }\n ? Data\n : never\n : never\n : never\n : never;\n\ntype RequestParamCombinations = {\n [Path in keyof paths]: {\n [Method in keyof paths[Path]]: paths[Path][Method] extends never\n ? never\n : paths[Path][Method] extends {\n parameters: {\n query?: Record<string, unknown>;\n };\n }\n ? `${Method & string}:${Path}`\n : never;\n }[keyof paths[Path]];\n}[keyof paths];\n\nexport type RequestQuery<T extends RequestParamCombinations> =\n T extends `${infer Method}:${infer Path}`\n ? Path extends keyof paths\n ? Method extends keyof paths[Path]\n ? paths[Path][Method] extends {\n parameters: {\n query?: infer Data;\n };\n }\n ? Data\n : never\n : never\n : never\n : never;\n"]}
|
package/package.json
CHANGED
|
@@ -3,20 +3,26 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.34",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "build/main/index.js",
|
|
9
9
|
"module": "build/module/index.js",
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"openapi-fetch": "0.
|
|
14
|
-
"openapi-typescript": "^7.
|
|
13
|
+
"openapi-fetch": "0.15.0",
|
|
14
|
+
"openapi-typescript": "^7.10.1",
|
|
15
|
+
"openapi-typescript-helpers": "^0.0.15"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
17
|
-
"@
|
|
18
|
+
"@vrplatform/utils": "^4.9.45",
|
|
18
19
|
"@sentry/core": "*"
|
|
19
20
|
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@vrplatform/kysely": "*",
|
|
23
|
+
"@vrplatform/repository": "*",
|
|
24
|
+
"@vrplatform/common": "*"
|
|
25
|
+
},
|
|
20
26
|
"files": [
|
|
21
27
|
"build/main",
|
|
22
28
|
"build/module",
|
|
@@ -25,16 +31,16 @@
|
|
|
25
31
|
"LICENSE"
|
|
26
32
|
],
|
|
27
33
|
"scripts": {
|
|
28
|
-
"pub": "
|
|
34
|
+
"pub": "bunx bumpp --no-commit --no-git-check --no-verify --ignore-scripts --no-tag -p=false",
|
|
29
35
|
"npmpub": "bun run build && bunx vrp-deploy --prefix npmpub",
|
|
30
|
-
"npmpub:
|
|
31
|
-
"npmpub:
|
|
36
|
+
"npmpub:staging": "pnpm publish --no-git-checks --tag staging",
|
|
37
|
+
"npmpub:main": "pnpm publish --no-git-checks",
|
|
32
38
|
"build": "bun run generate && bun build:main && bun build:module",
|
|
33
39
|
"build:main": "tsc -b tsconfig.main.json",
|
|
34
40
|
"build:module": "tsc -b tsconfig.esm.json",
|
|
35
41
|
"dev": "NODE_ENV=generator bun --watch ./generate.ts",
|
|
36
42
|
"generate": "bun generate:schema && bun generate:client",
|
|
37
|
-
"generate:schema": "bun run --cwd ../../api
|
|
43
|
+
"generate:schema": "bun run --cwd ../../api generate",
|
|
38
44
|
"generate:client": "bunx --bun openapi-typescript ../../api/openapi.json -o ./src/generated/v1.ts",
|
|
39
45
|
"typecheck": "tsc --noEmit",
|
|
40
46
|
"tsgo": "tsgo --noEmit"
|
package/src/client.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { type RetryableFetchParams, useRetryableFetch } from '@finalytic/utils';
|
|
2
1
|
import * as Sentry from '@sentry/core';
|
|
2
|
+
import {
|
|
3
|
+
type RetryableFetchParams,
|
|
4
|
+
useRetryableFetch,
|
|
5
|
+
} from '@vrplatform/utils';
|
|
3
6
|
import createClient from 'openapi-fetch';
|
|
4
7
|
import { useCache } from './cache';
|
|
5
8
|
import type { paths } from './generated/v1';
|
package/src/error.ts
CHANGED
|
@@ -360,7 +360,7 @@ declare function createQuerySerializer<T = unknown>(
|
|
|
360
360
|
|
|
361
361
|
/**
|
|
362
362
|
* Handle different OpenAPI 3.x serialization styles
|
|
363
|
-
* @type {import("
|
|
363
|
+
* @type {import("openapi-fetch").defaultPathSerializer}
|
|
364
364
|
* @see https://swagger.io/docs/specification/serialization/#path
|
|
365
365
|
*/
|
|
366
366
|
declare function defaultPathSerializer(
|