@myapihq/sdk 2.31.2 → 2.31.4
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/client.d.ts +10 -1
- package/dist/client.js +14 -3
- package/dist/config.js +8 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -11,6 +11,15 @@ export declare class MyApiError extends Error {
|
|
|
11
11
|
* nothing support could trace. It is the only useful thing about a 500.
|
|
12
12
|
*/
|
|
13
13
|
requestId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The HTTP method of the failed request, when the SDK knows it.
|
|
16
|
+
*
|
|
17
|
+
* Present so callers can tell a failed READ from a failed WRITE. The CLI's
|
|
18
|
+
* 5xx message used to tell everyone "whether the change went through is not
|
|
19
|
+
* knowable from here" — true and important after a POST, and simply false
|
|
20
|
+
* after `pixel audience`, which changes nothing.
|
|
21
|
+
*/
|
|
22
|
+
method?: string;
|
|
14
23
|
constructor(code: string, status: number, detail?: string | undefined, body?: Record<string, unknown> | undefined);
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
@@ -42,7 +51,7 @@ export interface RequestOptions {
|
|
|
42
51
|
*/
|
|
43
52
|
onReplay?: () => void;
|
|
44
53
|
}
|
|
45
|
-
export declare function toError(err: any, status: number, requestId?: string): MyApiError;
|
|
54
|
+
export declare function toError(err: any, status: number, requestId?: string, method?: string): MyApiError;
|
|
46
55
|
export declare function request<T>(method: string, url: string, apiKey?: string, body?: unknown, extraHeaders?: Record<string, string>, opts?: RequestOptions): Promise<T>;
|
|
47
56
|
export interface Page<T> {
|
|
48
57
|
data: T[];
|
package/dist/client.js
CHANGED
|
@@ -23,6 +23,15 @@ class MyApiError extends Error {
|
|
|
23
23
|
* nothing support could trace. It is the only useful thing about a 500.
|
|
24
24
|
*/
|
|
25
25
|
requestId;
|
|
26
|
+
/**
|
|
27
|
+
* The HTTP method of the failed request, when the SDK knows it.
|
|
28
|
+
*
|
|
29
|
+
* Present so callers can tell a failed READ from a failed WRITE. The CLI's
|
|
30
|
+
* 5xx message used to tell everyone "whether the change went through is not
|
|
31
|
+
* knowable from here" — true and important after a POST, and simply false
|
|
32
|
+
* after `pixel audience`, which changes nothing.
|
|
33
|
+
*/
|
|
34
|
+
method;
|
|
26
35
|
constructor(code, status, detail, body) {
|
|
27
36
|
// Surface the detail in the message so console.error / err.message
|
|
28
37
|
// shows useful info without callers having to look at err.detail.
|
|
@@ -256,7 +265,7 @@ async function parseResponse(method, url, response) {
|
|
|
256
265
|
throw new MyApiError('invalid_json_response', response.status, `${method} ${url} returned non-JSON (status ${response.status}): ${snippet}\n${diagnoseNonJson(response.status, raw)}`);
|
|
257
266
|
}
|
|
258
267
|
if (!response.ok) {
|
|
259
|
-
throw toError(result?.error, response.status, pickRequestId(result));
|
|
268
|
+
throw toError(result?.error, response.status, pickRequestId(result), method);
|
|
260
269
|
}
|
|
261
270
|
// A few routes answer 2xx with a BARE object — no {success, data, error,
|
|
262
271
|
// meta} envelope. `pixel identity` and `pixel events` are the two we have
|
|
@@ -273,7 +282,7 @@ async function parseResponse(method, url, response) {
|
|
|
273
282
|
}
|
|
274
283
|
const apiResponse = result;
|
|
275
284
|
if (!apiResponse.success) {
|
|
276
|
-
throw toError(apiResponse.error, response.status);
|
|
285
|
+
throw toError(apiResponse.error, response.status, undefined, method);
|
|
277
286
|
}
|
|
278
287
|
return apiResponse;
|
|
279
288
|
}
|
|
@@ -301,7 +310,7 @@ function pickRequestId(result) {
|
|
|
301
310
|
const meta = result?.meta;
|
|
302
311
|
return typeof meta?.request_id === 'string' && meta.request_id ? meta.request_id : undefined;
|
|
303
312
|
}
|
|
304
|
-
function toError(err, status, requestId) {
|
|
313
|
+
function toError(err, status, requestId, method) {
|
|
305
314
|
const obj = typeof err === 'object' && err !== null ? err : undefined;
|
|
306
315
|
const code = obj ? (obj.code || 'unknown_error') : (err || 'unknown_error');
|
|
307
316
|
const pick = (v) => (typeof v === 'string' && v.trim() !== '' ? v : undefined);
|
|
@@ -309,6 +318,8 @@ function toError(err, status, requestId) {
|
|
|
309
318
|
const e = new MyApiError(code, status, detail, obj);
|
|
310
319
|
if (requestId)
|
|
311
320
|
e.requestId = requestId;
|
|
321
|
+
if (method)
|
|
322
|
+
e.method = method;
|
|
312
323
|
return e;
|
|
313
324
|
}
|
|
314
325
|
// Returns the unwrapped `data` payload — the common case.
|
package/dist/config.js
CHANGED
|
@@ -28,7 +28,14 @@ exports.WORKFLOW_BASE = process.env.MYAPI_WORKFLOW_URL ?? 'https://api.myworkflo
|
|
|
28
28
|
exports.EMAIL_BASE = process.env.MYAPI_EMAIL_URL ?? 'https://api.myemailapi.com';
|
|
29
29
|
exports.STORAGE_BASE = process.env.MYAPI_STORAGE_URL ?? 'https://api.mystorageapi.com';
|
|
30
30
|
exports.URL_BASE = process.env.MYAPI_URL_URL ?? 'https://api.myurlto.com';
|
|
31
|
-
|
|
31
|
+
// api.mypixelapi.com resolves and answers, which is why this looked wired. It
|
|
32
|
+
// answers `401 {"error":"Unauthorized"}` to a valid platform key on EVERY pixel
|
|
33
|
+
// route — note the bare body, not our envelope: it is a different service that
|
|
34
|
+
// does not share our key space. So every `myapi pixel …` command has failed
|
|
35
|
+
// with "Invalid API key. Run: myapi account setup" since the initial release,
|
|
36
|
+
// and setup cannot fix it. The gateway serves the whole pixel surface with the
|
|
37
|
+
// same key (visits, events, interactions, identity, identify all verified).
|
|
38
|
+
exports.PIXEL_BASE = process.env.MYAPI_PIXEL_URL ?? GATEWAY;
|
|
32
39
|
// Per-service hosts below either don't resolve in DNS or 404 the routes;
|
|
33
40
|
// served via the gateway until backend wires the brand routing. Flip back
|
|
34
41
|
// to per-service hosts when DNS is sound and routes verified there.
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.31.
|
|
1
|
+
export declare const SDK_VERSION = "2.31.4";
|
package/dist/version.js
CHANGED
|
@@ -8,4 +8,4 @@ exports.SDK_VERSION = void 0;
|
|
|
8
8
|
// Why a constant and not a package.json read: the SDK runs inside edge
|
|
9
9
|
// functions (Cloudflare Workers), so it must not import node:fs. A literal
|
|
10
10
|
// is the only version source that works in every runtime we ship to.
|
|
11
|
-
exports.SDK_VERSION = '2.31.
|
|
11
|
+
exports.SDK_VERSION = '2.31.4';
|