@vrplatform/api 1.2.33-987 → 1.2.33-989

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.
@@ -1,4 +1,4 @@
1
- import { type RetryableFetchParams } from '@finalytic/utils';
1
+ import { type RetryableFetchParams } from '@vrplatform/utils';
2
2
  import type { ApiClient, ApiClientAuth } from './types';
3
3
  export declare function useApiClient({ baseUrl: base, local, auth, sessionId: sid, testing, headers: h, ...retryableFetchParams }: {
4
4
  attempts?: number;
@@ -37,8 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.useApiClient = useApiClient;
40
- const utils_1 = require("@finalytic/utils");
41
40
  const Sentry = __importStar(require("@sentry/core"));
41
+ const utils_1 = require("@vrplatform/utils");
42
42
  const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
43
43
  const cache_1 = require("./cache");
44
44
  const sec_1 = require("./sec");
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"src/","sources":["client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,oCAiFC;AAzFD,4CAAgF;AAChF,qDAAuC;AACvC,kEAAyC;AACzC,mCAAmC;AAEnC,+BAA0C;AAG1C,SAAgB,YAAY,CAAC,EAC3B,OAAO,EAAE,IAAI,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EAAE,GAAG;AACd,cAAc;AACd,OAAO,EACP,OAAO,EAAE,CAAC,EACV,GAAG,oBAAoB,EAYD;IACtB,MAAM,OAAO,GACX,CAAC,KAAK;QACJ,CAAC,CAAC,oBAAoB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,CAAC,CAAC,IAAI,CAAC,IAAI,4BAA4B,CAAC;IAE5C,MAAM,SAAS,GAAG,GAAG,IAAI,MAAM,CAA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/utils';\nimport * as Sentry from '@sentry/core';\nimport createClient from 'openapi-fetch';\nimport { useCache } from './cache';\nimport type { paths } from './generated/v1';\nimport { generateApiKeySec } from './sec';\nimport type { ApiClient, ApiClientAuth } from './types';\n\nexport function useApiClient({\n baseUrl: base,\n local,\n auth,\n sessionId: sid,\n // headers: h,\n testing,\n headers: h,\n ...retryableFetchParams\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n baseUrl?: string;\n sessionId?: string;\n local?: boolean | number;\n headers?: Record<string, string> | (() => Record<string, string>);\n testing?: {\n overwriteUri?: string;\n getOverwriteTimestamp?: () => number | undefined;\n };\n} & RetryableFetchParams) {\n const baseUrl =\n (local\n ? `http://localhost:${typeof local === 'number' ? local : 8877}`\n : base) || 'https://api.vrplatform.app';\n\n const sessionId = sid || crypto.randomUUID();\n // cache the sec key for 1 minute (its valid for 5 minutes on the API)\n const cache = useCache(\n async (v: string) =>\n generateApiKeySec(v, testing?.getOverwriteTimestamp?.()),\n 60_000\n );\n\n const retryableFetch = useRetryableFetch({\n ...retryableFetchParams,\n onRetry(arg) {\n cache.invalidate();\n if (retryableFetchParams.onRetry) retryableFetchParams.onRetry(arg);\n },\n });\n\n const trace = Sentry.getTraceData();\n const client = createClient<paths>({\n baseUrl,\n fetch(req) {\n return retryableFetch(async () => {\n let clone: Request = req.clone() as any;\n if (testing?.overwriteUri)\n clone = new Request(testing.overwriteUri, clone);\n\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) clone.headers.set('X-Session-Id', sessionId);\n if (a.sec)\n clone.headers.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) clone.headers.set('X-Api-Key', a.apiKey);\n if (a.tenantId) clone.headers.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n clone.headers.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n const additionalHeaders = h ? (typeof h === 'function' ? h() : h) : {};\n for (const key in additionalHeaders) {\n clone.headers.set(key, additionalHeaders[key]);\n }\n\n if (trace['sentry-trace'])\n clone.headers.set('sentry-trace', trace['sentry-trace']);\n if (trace.baggage) clone.headers.set('baggage', trace.baggage);\n\n return clone;\n });\n },\n });\n\n const sessionClient: ApiClient = client as any;\n sessionClient.sessionId = sessionId;\n return sessionClient;\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"src/","sources":["client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,oCAiFC;AA5FD,qDAAuC;AACvC,6CAG2B;AAC3B,kEAAyC;AACzC,mCAAmC;AAEnC,+BAA0C;AAG1C,SAAgB,YAAY,CAAC,EAC3B,OAAO,EAAE,IAAI,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EAAE,GAAG;AACd,cAAc;AACd,OAAO,EACP,OAAO,EAAE,CAAC,EACV,GAAG,oBAAoB,EAYD;IACtB,MAAM,OAAO,GACX,CAAC,KAAK;QACJ,CAAC,CAAC,oBAAoB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,CAAC,CAAC,IAAI,CAAC,IAAI,4BAA4B,CAAC;IAE5C,MAAM,SAAS,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7C,sEAAsE;IACtE,MAAM,KAAK,GAAG,IAAA,gBAAQ,EACpB,KAAK,EAAE,CAAS,EAAE,EAAE,CAClB,IAAA,uBAAiB,EAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,EAAE,CAAC,EAC1D,KAAM,CACP,CAAC;IAEF,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC;QACvC,GAAG,oBAAoB;QACvB,OAAO,CAAC,GAAG;YACT,KAAK,CAAC,UAAU,EAAE,CAAC;YACnB,IAAI,oBAAoB,CAAC,OAAO;gBAAE,oBAAoB,CAAC,OAAO,C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W,EAAE,CAC9B,CAAC;gBACJ,MAAM,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvE,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;oBACpC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;gBACjD,CAAC;gBAED,IAAI,KAAK,CAAC,cAAc,CAAC;oBACvB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;gBAC3D,IAAI,KAAK,CAAC,OAAO;oBAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAE/D,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,aAAa,GAAc,MAAa,CAAC;IAC/C,aAAa,CAAC,SAAS,GAAG,SAAS,CAAC;IACpC,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import * as Sentry from '@sentry/core';\nimport {\n type RetryableFetchParams,\n useRetryableFetch,\n} from '@vrplatform/utils';\nimport createClient from 'openapi-fetch';\nimport { useCache } from './cache';\nimport type { paths } from './generated/v1';\nimport { generateApiKeySec } from './sec';\nimport type { ApiClient, ApiClientAuth } from './types';\n\nexport function useApiClient({\n baseUrl: base,\n local,\n auth,\n sessionId: sid,\n // headers: h,\n testing,\n headers: h,\n ...retryableFetchParams\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n baseUrl?: string;\n sessionId?: string;\n local?: boolean | number;\n headers?: Record<string, string> | (() => Record<string, string>);\n testing?: {\n overwriteUri?: string;\n getOverwriteTimestamp?: () => number | undefined;\n };\n} & RetryableFetchParams) {\n const baseUrl =\n (local\n ? `http://localhost:${typeof local === 'number' ? local : 8877}`\n : base) || 'https://api.vrplatform.app';\n\n const sessionId = sid || crypto.randomUUID();\n // cache the sec key for 1 minute (its valid for 5 minutes on the API)\n const cache = useCache(\n async (v: string) =>\n generateApiKeySec(v, testing?.getOverwriteTimestamp?.()),\n 60_000\n );\n\n const retryableFetch = useRetryableFetch({\n ...retryableFetchParams,\n onRetry(arg) {\n cache.invalidate();\n if (retryableFetchParams.onRetry) retryableFetchParams.onRetry(arg);\n },\n });\n\n const trace = Sentry.getTraceData();\n const client = createClient<paths>({\n baseUrl,\n fetch(req) {\n return retryableFetch(async () => {\n let clone: Request = req.clone() as any;\n if (testing?.overwriteUri)\n clone = new Request(testing.overwriteUri, clone);\n\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) clone.headers.set('X-Session-Id', sessionId);\n if (a.sec)\n clone.headers.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) clone.headers.set('X-Api-Key', a.apiKey);\n if (a.tenantId) clone.headers.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n clone.headers.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n const additionalHeaders = h ? (typeof h === 'function' ? h() : h) : {};\n for (const key in additionalHeaders) {\n clone.headers.set(key, additionalHeaders[key]);\n }\n\n if (trace['sentry-trace'])\n clone.headers.set('sentry-trace', trace['sentry-trace']);\n if (trace.baggage) clone.headers.set('baggage', trace.baggage);\n\n return clone;\n });\n },\n });\n\n const sessionClient: ApiClient = client as any;\n sessionClient.sessionId = sessionId;\n return sessionClient;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiClientError = void 0;
4
4
  exports.throwIfError = throwIfError;
5
- const utils_1 = require("@finalytic/utils");
5
+ const utils_1 = require("@vrplatform/utils");
6
6
  class ApiClientError extends Error {
7
7
  constructor(error) {
8
8
  if (!error.message)
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;AA8CA,oCAoBC;AAlED,4CAA4C;AAY5C,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAmB,KAAQ;QACzB,IAAI,CAAC,KAAK,CAAC,OAAO;YAChB,KAAK,CAAC,OAAO,GAAG;gBACd,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACV,CAAC,CAAC,CAAC,OAAO,EAAG,CAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;qBACrC,MAAM,CAAC,gBAAQ,CAAC;qBAChB,IAAI,CAAC,MAAM,CAAC,CAChB;qBACA,IAAI,CAAC,IAAI,CAAC;aACd;iBACE,MAAM,CAAC,gBAAQ,CAAC;iBAChB,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAdJ,UAAK,GAAL,KAAK,CAAG;QAgBzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5C,CAAC;CACF;AA3BD,wCA2BC;AAOD,SAAgB,YAAY,CAC1B,QAAwB;IAExB,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAChD,CAAC;YAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;YAEhC,IAAI,KAAK;gBAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;IAEhC,IAAI,KAAK;QAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { hasValue } from '@finalytic/utils';\nimport type { FetchResponse } from './generated/openapi-fetch';\n\ntype E = {\n code: string;\n message: string;\n issues?: {\n message: string;\n }[];\n context?: any;\n stack?: any;\n};\nexport class ApiClientError extends Error {\n code: string;\n issues: {\n message: string;\n }[];\n context: any;\n constructor(public error: E) {\n if (!error.message)\n error.message = [\n error.code,\n error.issues\n ?.map((x) =>\n [x.message, (x as any).path?.join('->')]\n .filter(hasValue)\n .join(' on ')\n )\n .join(', '),\n ]\n .filter(hasValue)\n .join(': ');\n super(error.message);\n\n this.code = error.code;\n this.issues = error.issues || [];\n this.context = error.context || {};\n if (error.stack) this.stack = error.stack;\n }\n}\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: T\n): NonNullable<T['data']>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T>\n): Promise<NonNullable<T['data']>>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T> | T\n): Promise<NonNullable<T['data']>> | NonNullable<T['data']> {\n if (response instanceof Promise) {\n return response.then((response) => {\n if (response.response.status === 503) {\n throw new Error('Worker resources exceeded.');\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError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AAC,CAAC;YAChD,CAAC;YAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;YAEhC,IAAI,KAAK;gBAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;IAEhC,IAAI,KAAK;QAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { hasValue } from '@vrplatform/utils';\nimport type { FetchResponse } from './generated/openapi-fetch';\n\ntype E = {\n code: string;\n message: string;\n issues?: {\n message: string;\n }[];\n context?: any;\n stack?: any;\n};\nexport class ApiClientError extends Error {\n code: string;\n issues: {\n message: string;\n }[];\n context: any;\n constructor(public error: E) {\n if (!error.message)\n error.message = [\n error.code,\n error.issues\n ?.map((x) =>\n [x.message, (x as any).path?.join('->')]\n .filter(hasValue)\n .join(' on ')\n )\n .join(', '),\n ]\n .filter(hasValue)\n .join(': ');\n super(error.message);\n\n this.code = error.code;\n this.issues = error.issues || [];\n this.context = error.context || {};\n if (error.stack) this.stack = error.stack;\n }\n}\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: T\n): NonNullable<T['data']>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T>\n): Promise<NonNullable<T['data']>>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T> | T\n): Promise<NonNullable<T['data']>> | NonNullable<T['data']> {\n if (response instanceof Promise) {\n return response.then((response) => {\n if (response.response.status === 503) {\n throw new Error('Worker resources exceeded.');\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n}\n"]}
@@ -17656,8 +17656,8 @@ export interface operations {
17656
17656
  content: {
17657
17657
  "application/json": {
17658
17658
  name: string;
17659
- /** @enum {string|null} */
17660
- status?: "active" | "inactive" | null;
17659
+ /** @enum {string} */
17660
+ status?: "active" | "inactive";
17661
17661
  /** @enum {string} */
17662
17662
  type: "ledger" | "bank" | "recurringFee" | "nonPosting";
17663
17663
  id: string;
@@ -17783,13 +17783,13 @@ export interface operations {
17783
17783
  content: {
17784
17784
  "application/json": {
17785
17785
  name?: string;
17786
- /** @enum {string|null} */
17787
- status?: "active" | "inactive" | null;
17786
+ /** @enum {string} */
17787
+ status?: "active" | "inactive";
17788
17788
  /** @enum {string} */
17789
17789
  type?: "ledger" | "bank" | "recurringFee" | "nonPosting";
17790
17790
  assignments?: ("accountsPayable" | "accountsReceivable" | "cancellationRevenue" | "deferredRevenue" | "deposit_channelFee" | "deposit_coHostPayout" | "deposit_merchantFee" | "openingBalance" | "deposit_reserve" | "deposit_vat" | "expense_markup" | "expense_reimbursement" | "expense_salesTax" | "transfer_ownerPayout" | "transfer")[] | null;
17791
17791
  offsetAccountId?: string | null;
17792
- categoryId?: string | null;
17792
+ categoryId?: string;
17793
17793
  banking?: {
17794
17794
  /** @enum {string|null} */
17795
17795
  category?: "trust" | "operating" | "external" | null;
@@ -17810,8 +17810,8 @@ export interface operations {
17810
17810
  content: {
17811
17811
  "application/json": {
17812
17812
  name: string;
17813
- /** @enum {string|null} */
17814
- status?: "active" | "inactive" | null;
17813
+ /** @enum {string} */
17814
+ status?: "active" | "inactive";
17815
17815
  /** @enum {string} */
17816
17816
  type: "ledger" | "bank" | "recurringFee" | "nonPosting";
17817
17817
  id: string;
@@ -18025,8 +18025,8 @@ export interface operations {
18025
18025
  "application/json": {
18026
18026
  data: {
18027
18027
  name: string;
18028
- /** @enum {string|null} */
18029
- status?: "active" | "inactive" | null;
18028
+ /** @enum {string} */
18029
+ status?: "active" | "inactive";
18030
18030
  /** @enum {string} */
18031
18031
  type: "ledger" | "bank" | "recurringFee" | "nonPosting";
18032
18032
  id: string;
@@ -18160,13 +18160,13 @@ export interface operations {
18160
18160
  content: {
18161
18161
  "application/json": {
18162
18162
  name: string;
18163
- /** @enum {string|null} */
18164
- status?: "active" | "inactive" | null;
18163
+ /** @enum {string} */
18164
+ status?: "active" | "inactive";
18165
18165
  /** @enum {string} */
18166
18166
  type: "ledger" | "bank" | "recurringFee" | "nonPosting";
18167
18167
  assignments?: ("accountsPayable" | "accountsReceivable" | "cancellationRevenue" | "deferredRevenue" | "deposit_channelFee" | "deposit_coHostPayout" | "deposit_merchantFee" | "openingBalance" | "deposit_reserve" | "deposit_vat" | "expense_markup" | "expense_reimbursement" | "expense_salesTax" | "transfer_ownerPayout" | "transfer")[] | null;
18168
18168
  offsetAccountId?: string | null;
18169
- categoryId?: string | null;
18169
+ categoryId?: string;
18170
18170
  banking?: {
18171
18171
  /** @enum {string|null} */
18172
18172
  category?: "trust" | "operating" | "external" | null;
@@ -18187,8 +18187,8 @@ export interface operations {
18187
18187
  content: {
18188
18188
  "application/json": {
18189
18189
  name: string;
18190
- /** @enum {string|null} */
18191
- status?: "active" | "inactive" | null;
18190
+ /** @enum {string} */
18191
+ status?: "active" | "inactive";
18192
18192
  /** @enum {string} */
18193
18193
  type: "ledger" | "bank" | "recurringFee" | "nonPosting";
18194
18194
  id: string;