perspectapi-ts-sdk 5.4.2 → 5.4.5
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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/index.mjs +7 -0
- package/package.json +1 -1
- package/src/v2/client/base-v2-client.ts +14 -0
- package/src/v2/types.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -3112,6 +3112,8 @@ interface V2Media extends V2Object {
|
|
|
3112
3112
|
width: number | null;
|
|
3113
3113
|
height: number | null;
|
|
3114
3114
|
filesize: number | null;
|
|
3115
|
+
caption: string | null;
|
|
3116
|
+
alt_text: string | null;
|
|
3115
3117
|
}
|
|
3116
3118
|
interface V2Content extends V2Object {
|
|
3117
3119
|
object: "content";
|
package/dist/index.d.ts
CHANGED
|
@@ -3112,6 +3112,8 @@ interface V2Media extends V2Object {
|
|
|
3112
3112
|
width: number | null;
|
|
3113
3113
|
height: number | null;
|
|
3114
3114
|
filesize: number | null;
|
|
3115
|
+
caption: string | null;
|
|
3116
|
+
alt_text: string | null;
|
|
3115
3117
|
}
|
|
3116
3118
|
interface V2Content extends V2Object {
|
|
3117
3119
|
object: "content";
|
package/dist/index.js
CHANGED
|
@@ -3380,6 +3380,13 @@ var BaseV2Client = class {
|
|
|
3380
3380
|
* We unwrap accordingly.
|
|
3381
3381
|
*/
|
|
3382
3382
|
extractData(response) {
|
|
3383
|
+
if ("object" in response && typeof response.object === "string") {
|
|
3384
|
+
const payload2 = response;
|
|
3385
|
+
if (payload2.error && typeof payload2.error === "object" && "type" in payload2.error) {
|
|
3386
|
+
throw this.toError(response);
|
|
3387
|
+
}
|
|
3388
|
+
return response;
|
|
3389
|
+
}
|
|
3383
3390
|
const payload = response.data;
|
|
3384
3391
|
if (payload && typeof payload === "object" && "error" in payload) {
|
|
3385
3392
|
const errObj = payload.error;
|
package/dist/index.mjs
CHANGED
|
@@ -3312,6 +3312,13 @@ var BaseV2Client = class {
|
|
|
3312
3312
|
* We unwrap accordingly.
|
|
3313
3313
|
*/
|
|
3314
3314
|
extractData(response) {
|
|
3315
|
+
if ("object" in response && typeof response.object === "string") {
|
|
3316
|
+
const payload2 = response;
|
|
3317
|
+
if (payload2.error && typeof payload2.error === "object" && "type" in payload2.error) {
|
|
3318
|
+
throw this.toError(response);
|
|
3319
|
+
}
|
|
3320
|
+
return response;
|
|
3321
|
+
}
|
|
3315
3322
|
const payload = response.data;
|
|
3316
3323
|
if (payload && typeof payload === "object" && "error" in payload) {
|
|
3317
3324
|
const errObj = payload.error;
|
package/package.json
CHANGED
|
@@ -68,6 +68,20 @@ export abstract class BaseV2Client {
|
|
|
68
68
|
* We unwrap accordingly.
|
|
69
69
|
*/
|
|
70
70
|
private extractData<T>(response: { data?: unknown; success?: boolean; error?: unknown; message?: string }): T {
|
|
71
|
+
// When the v2 API returns an object with an `object` key (e.g. list responses
|
|
72
|
+
// like { object: "list", data: [...], has_more: ... }), the shared HttpClient
|
|
73
|
+
// passes it through as-is because it detects a `data` key. In that case the
|
|
74
|
+
// *entire* response is the v2 payload — return it directly instead of
|
|
75
|
+
// double-unwrapping via `.data`.
|
|
76
|
+
if ('object' in response && typeof (response as any).object === 'string') {
|
|
77
|
+
// Still check for v2 error bodies nested inside
|
|
78
|
+
const payload = response as any;
|
|
79
|
+
if (payload.error && typeof payload.error === 'object' && 'type' in payload.error) {
|
|
80
|
+
throw this.toError(response);
|
|
81
|
+
}
|
|
82
|
+
return response as unknown as T;
|
|
83
|
+
}
|
|
84
|
+
|
|
71
85
|
const payload = response.data as any;
|
|
72
86
|
|
|
73
87
|
// Check if the API returned a v2 error body
|