@vrplatform/api 1.3.1-stage.38615128806 → 1.3.1-stage.38628694180
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/error.d.ts +10 -1
- package/build/main/error.js +7 -2
- package/build/main/error.js.map +1 -1
- package/build/main/generated/v1.d.ts +2 -2
- package/build/main/generated/v1.js.map +2 -2
- package/build/module/error.d.ts +10 -1
- package/build/module/error.js +8 -2
- package/build/module/error.js.map +1 -1
- package/build/module/generated/v1.d.ts +2 -2
- package/build/module/generated/v1.js.map +2 -2
- package/package.json +1 -1
- package/src/error.ts +12 -2
- package/src/generated/v1.ts +2 -2
package/build/main/error.d.ts
CHANGED
|
@@ -21,7 +21,16 @@ export declare class ApiClientError extends Error {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class ApiClientResponseError extends Error {
|
|
23
23
|
status: number;
|
|
24
|
-
|
|
24
|
+
readonly details: {
|
|
25
|
+
contentType: string | null;
|
|
26
|
+
requestId: string | null;
|
|
27
|
+
cfRay: string | null;
|
|
28
|
+
};
|
|
29
|
+
constructor(message: string, status: number, details?: {
|
|
30
|
+
contentType: string | null;
|
|
31
|
+
requestId: string | null;
|
|
32
|
+
cfRay: string | null;
|
|
33
|
+
});
|
|
25
34
|
}
|
|
26
35
|
export declare function throwIfError<T extends ApiResponse<unknown> | Promise<ApiResponse<unknown>>>(response: T): T extends Promise<ApiResponse<unknown>> ? Promise<NonNullable<Awaited<T>['data']>> : NonNullable<Awaited<T>['data']>;
|
|
27
36
|
export {};
|
package/build/main/error.js
CHANGED
|
@@ -17,9 +17,10 @@ class ApiClientError extends Error {
|
|
|
17
17
|
}
|
|
18
18
|
exports.ApiClientError = ApiClientError;
|
|
19
19
|
class ApiClientResponseError extends Error {
|
|
20
|
-
constructor(message, status) {
|
|
20
|
+
constructor(message, status, details = { contentType: null, requestId: null, cfRay: null }) {
|
|
21
21
|
super(message);
|
|
22
22
|
this.status = status;
|
|
23
|
+
this.details = details;
|
|
23
24
|
this.name = 'ApiClientResponseError';
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -61,7 +62,11 @@ function throwIfError(response) {
|
|
|
61
62
|
typeof error.links.docs !== 'string' ||
|
|
62
63
|
!('schema' in error.links) ||
|
|
63
64
|
typeof error.links.schema !== 'string')))
|
|
64
|
-
throw new ApiClientResponseError('API response did not contain a valid error envelope', response.response.status
|
|
65
|
+
throw new ApiClientResponseError('API response did not contain a valid error envelope', response.response.status, {
|
|
66
|
+
contentType: response.response.headers.get('content-type'),
|
|
67
|
+
requestId: response.response.headers.get('x-request-id'),
|
|
68
|
+
cfRay: response.response.headers.get('cf-ray'),
|
|
69
|
+
});
|
|
65
70
|
throw new ApiClientError(error);
|
|
66
71
|
}
|
|
67
72
|
//# sourceMappingURL=error.js.map
|
package/build/main/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;AA0DA,oCA2DC;AAnGD,MAAa,cAAe,SAAQ,KAAK;IAOvC,YAAmB,KAAoB;QACrC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QADJ,UAAK,GAAL,KAAK,CAAe;QAErC,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,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5C,CAAC;CACF;AAhBD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AAO,CAAC,GAAG,CAAC,QAAQ,CAAC;SAC/C,CACF,CAAC;IAEJ,MAAM,IAAI,cAAc,CAAC,KAAsB,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import type { paths } from './generated/v1';\n\n// The shared default envelope is emitted on every route. Preserve unfamiliar\n// server codes so an older client can still expose a newer API failure.\ntype PublicError =\n paths['/account-connections']['get']['responses'][400]['content']['application/json'];\ntype ErrorEnvelope = Omit<PublicError, 'code' | 'issues'> & {\n code: string;\n issues?: PublicError['issues'];\n stack?: string;\n};\n\ntype ApiResponse<T> = {\n response: Response;\n data?: T;\n error?: unknown;\n};\n\nexport class ApiClientError extends Error {\n code: ErrorEnvelope['code'];\n issues: PublicError['issues'];\n context: PublicError['context'];\n links: PublicError['links'];\n retryable: PublicError['retryable'];\n\n constructor(public error: ErrorEnvelope) {\n super(error.message);\n this.code = error.code;\n this.issues = error.issues ?? [];\n this.context = error.context;\n this.links = error.links;\n this.retryable = error.retryable;\n if (error.stack) this.stack = error.stack;\n }\n}\n\nexport class ApiClientResponseError extends Error {\n constructor(\n message: string,\n public status: number,\n public readonly details: {\n contentType: string | null;\n requestId: string | null;\n cfRay: string | null;\n } = { contentType: null, requestId: null, cfRay: null }\n ) {\n super(message);\n this.name = 'ApiClientResponseError';\n }\n}\n\nexport function throwIfError<\n T extends ApiResponse<unknown> | Promise<ApiResponse<unknown>>,\n>(\n response: T\n): T extends Promise<ApiResponse<unknown>>\n ? Promise<NonNullable<Awaited<T>['data']>>\n : NonNullable<Awaited<T>['data']>;\nexport function throwIfError(\n response: Promise<ApiResponse<unknown>> | ApiResponse<unknown>\n): unknown {\n if (response instanceof Promise)\n return response.then((value) => throwIfError(value));\n if (response.response.ok && response.error === undefined) {\n return response.data;\n }\n\n const error = response.error;\n if (\n typeof error !== 'object' ||\n error === null ||\n !('code' in error) ||\n typeof error.code !== 'string' ||\n !('message' in error) ||\n typeof error.message !== 'string' ||\n !('issues' in error) ||\n !Array.isArray(error.issues) ||\n !error.issues.every(\n (issue: unknown) =>\n typeof issue === 'object' &&\n issue !== null &&\n 'message' in issue &&\n typeof issue.message === 'string' &&\n (!('path' in issue) ||\n issue.path === undefined ||\n (Array.isArray(issue.path) &&\n issue.path.every(\n (part: unknown) =>\n typeof part === 'string' || typeof part === 'number'\n ))) &&\n (!('schema' in issue) ||\n issue.schema === undefined ||\n typeof issue.schema === 'string')\n ) ||\n ('retryable' in error &&\n error.retryable !== undefined &&\n typeof error.retryable !== 'boolean') ||\n ('links' in error &&\n error.links !== undefined &&\n (typeof error.links !== 'object' ||\n error.links === null ||\n !('docs' in error.links) ||\n typeof error.links.docs !== 'string' ||\n !('schema' in error.links) ||\n typeof error.links.schema !== 'string'))\n )\n throw new ApiClientResponseError(\n 'API response did not contain a valid error envelope',\n response.response.status,\n {\n contentType: response.response.headers.get('content-type'),\n requestId: response.response.headers.get('x-request-id'),\n cfRay: response.response.headers.get('cf-ray'),\n }\n );\n\n throw new ApiClientError(error as ErrorEnvelope);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/build/main/generated/v1.d.ts
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 37398833 bytes
|
|
4
|
+
sha256: 0fbf834e82028e0055eb31530acf1de1d9d97f2d43f38a63f115027c22588ae8
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/build/main/generated/v1.js.map
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 39572411 bytes
|
|
4
|
+
sha256: ecb9522f87866912d307a33421599610fe2c90dabfbf0cbf73097cc88f0694f8
|
package/build/module/error.d.ts
CHANGED
|
@@ -21,7 +21,16 @@ export declare class ApiClientError extends Error {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class ApiClientResponseError extends Error {
|
|
23
23
|
status: number;
|
|
24
|
-
|
|
24
|
+
readonly details: {
|
|
25
|
+
contentType: string | null;
|
|
26
|
+
requestId: string | null;
|
|
27
|
+
cfRay: string | null;
|
|
28
|
+
};
|
|
29
|
+
constructor(message: string, status: number, details?: {
|
|
30
|
+
contentType: string | null;
|
|
31
|
+
requestId: string | null;
|
|
32
|
+
cfRay: string | null;
|
|
33
|
+
});
|
|
25
34
|
}
|
|
26
35
|
export declare function throwIfError<T extends ApiResponse<unknown> | Promise<ApiResponse<unknown>>>(response: T): T extends Promise<ApiResponse<unknown>> ? Promise<NonNullable<Awaited<T>['data']>> : NonNullable<Awaited<T>['data']>;
|
|
27
36
|
export {};
|
package/build/module/error.js
CHANGED
|
@@ -19,9 +19,11 @@ export class ApiClientError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
export class ApiClientResponseError extends Error {
|
|
21
21
|
status;
|
|
22
|
-
|
|
22
|
+
details;
|
|
23
|
+
constructor(message, status, details = { contentType: null, requestId: null, cfRay: null }) {
|
|
23
24
|
super(message);
|
|
24
25
|
this.status = status;
|
|
26
|
+
this.details = details;
|
|
25
27
|
this.name = 'ApiClientResponseError';
|
|
26
28
|
}
|
|
27
29
|
}
|
|
@@ -62,7 +64,11 @@ export function throwIfError(response) {
|
|
|
62
64
|
typeof error.links.docs !== 'string' ||
|
|
63
65
|
!('schema' in error.links) ||
|
|
64
66
|
typeof error.links.schema !== 'string')))
|
|
65
|
-
throw new ApiClientResponseError('API response did not contain a valid error envelope', response.response.status
|
|
67
|
+
throw new ApiClientResponseError('API response did not contain a valid error envelope', response.response.status, {
|
|
68
|
+
contentType: response.response.headers.get('content-type'),
|
|
69
|
+
requestId: response.response.headers.get('x-request-id'),
|
|
70
|
+
cfRay: response.response.headers.get('cf-ray'),
|
|
71
|
+
});
|
|
66
72
|
throw new ApiClientError(error);
|
|
67
73
|
}
|
|
68
74
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings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G,CAAC,cAAc,CAAC;YAC1D,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;YACxD,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;SAC/C,CACF,CAAC;IAEJ,MAAM,IAAI,cAAc,CAAC,KAAsB,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import type { paths } from './generated/v1';\n\n// The shared default envelope is emitted on every route. Preserve unfamiliar\n// server codes so an older client can still expose a newer API failure.\ntype PublicError =\n paths['/account-connections']['get']['responses'][400]['content']['application/json'];\ntype ErrorEnvelope = Omit<PublicError, 'code' | 'issues'> & {\n code: string;\n issues?: PublicError['issues'];\n stack?: string;\n};\n\ntype ApiResponse<T> = {\n response: Response;\n data?: T;\n error?: unknown;\n};\n\nexport class ApiClientError extends Error {\n code: ErrorEnvelope['code'];\n issues: PublicError['issues'];\n context: PublicError['context'];\n links: PublicError['links'];\n retryable: PublicError['retryable'];\n\n constructor(public error: ErrorEnvelope) {\n super(error.message);\n this.code = error.code;\n this.issues = error.issues ?? [];\n this.context = error.context;\n this.links = error.links;\n this.retryable = error.retryable;\n if (error.stack) this.stack = error.stack;\n }\n}\n\nexport class ApiClientResponseError extends Error {\n constructor(\n message: string,\n public status: number,\n public readonly details: {\n contentType: string | null;\n requestId: string | null;\n cfRay: string | null;\n } = { contentType: null, requestId: null, cfRay: null }\n ) {\n super(message);\n this.name = 'ApiClientResponseError';\n }\n}\n\nexport function throwIfError<\n T extends ApiResponse<unknown> | Promise<ApiResponse<unknown>>,\n>(\n response: T\n): T extends Promise<ApiResponse<unknown>>\n ? Promise<NonNullable<Awaited<T>['data']>>\n : NonNullable<Awaited<T>['data']>;\nexport function throwIfError(\n response: Promise<ApiResponse<unknown>> | ApiResponse<unknown>\n): unknown {\n if (response instanceof Promise)\n return response.then((value) => throwIfError(value));\n if (response.response.ok && response.error === undefined) {\n return response.data;\n }\n\n const error = response.error;\n if (\n typeof error !== 'object' ||\n error === null ||\n !('code' in error) ||\n typeof error.code !== 'string' ||\n !('message' in error) ||\n typeof error.message !== 'string' ||\n !('issues' in error) ||\n !Array.isArray(error.issues) ||\n !error.issues.every(\n (issue: unknown) =>\n typeof issue === 'object' &&\n issue !== null &&\n 'message' in issue &&\n typeof issue.message === 'string' &&\n (!('path' in issue) ||\n issue.path === undefined ||\n (Array.isArray(issue.path) &&\n issue.path.every(\n (part: unknown) =>\n typeof part === 'string' || typeof part === 'number'\n ))) &&\n (!('schema' in issue) ||\n issue.schema === undefined ||\n typeof issue.schema === 'string')\n ) ||\n ('retryable' in error &&\n error.retryable !== undefined &&\n typeof error.retryable !== 'boolean') ||\n ('links' in error &&\n error.links !== undefined &&\n (typeof error.links !== 'object' ||\n error.links === null ||\n !('docs' in error.links) ||\n typeof error.links.docs !== 'string' ||\n !('schema' in error.links) ||\n typeof error.links.schema !== 'string'))\n )\n throw new ApiClientResponseError(\n 'API response did not contain a valid error envelope',\n response.response.status,\n {\n contentType: response.response.headers.get('content-type'),\n requestId: response.response.headers.get('x-request-id'),\n cfRay: response.response.headers.get('cf-ray'),\n }\n );\n\n throw new ApiClientError(error as ErrorEnvelope);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/build/module/generated/v1.d.ts
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 37398833 bytes
|
|
4
|
+
sha256: 0fbf834e82028e0055eb31530acf1de1d9d97f2d43f38a63f115027c22588ae8
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/build/module/generated/v1.js.map
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 39572410 bytes
|
|
4
|
+
sha256: caea7bae4c49c3e707f25855bbd29b6da74d004fb5905eb892caae014ce986b7
|
package/package.json
CHANGED
package/src/error.ts
CHANGED
|
@@ -37,7 +37,12 @@ export class ApiClientError extends Error {
|
|
|
37
37
|
export class ApiClientResponseError extends Error {
|
|
38
38
|
constructor(
|
|
39
39
|
message: string,
|
|
40
|
-
public status: number
|
|
40
|
+
public status: number,
|
|
41
|
+
public readonly details: {
|
|
42
|
+
contentType: string | null;
|
|
43
|
+
requestId: string | null;
|
|
44
|
+
cfRay: string | null;
|
|
45
|
+
} = { contentType: null, requestId: null, cfRay: null }
|
|
41
46
|
) {
|
|
42
47
|
super(message);
|
|
43
48
|
this.name = 'ApiClientResponseError';
|
|
@@ -101,7 +106,12 @@ export function throwIfError(
|
|
|
101
106
|
)
|
|
102
107
|
throw new ApiClientResponseError(
|
|
103
108
|
'API response did not contain a valid error envelope',
|
|
104
|
-
response.response.status
|
|
109
|
+
response.response.status,
|
|
110
|
+
{
|
|
111
|
+
contentType: response.response.headers.get('content-type'),
|
|
112
|
+
requestId: response.response.headers.get('x-request-id'),
|
|
113
|
+
cfRay: response.response.headers.get('cf-ray'),
|
|
114
|
+
}
|
|
105
115
|
);
|
|
106
116
|
|
|
107
117
|
throw new ApiClientError(error as ErrorEnvelope);
|
package/src/generated/v1.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/src/generated/v1.ts
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 37398834 bytes
|
|
4
|
+
sha256: a218a1d570d833b075fddf258bc7a1a3fa1aca7971440f01f7d85485c1945089
|