@myapihq/sdk 2.2.0 → 2.4.0

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.
@@ -64,7 +64,7 @@ export declare function listAudiences(apiKey: string, orgId: string): Promise<Au
64
64
  export declare function getAudience(apiKey: string, orgId: string, audienceId: string): Promise<Audience>;
65
65
  export declare function updateAudience(apiKey: string, orgId: string, audienceId: string, patch: UpdateAudienceInput): Promise<Audience>;
66
66
  export declare function deleteAudience(apiKey: string, orgId: string, audienceId: string): Promise<void>;
67
- export declare function getAudienceMembers(apiKey: string, orgId: string, audienceId: string, opts: {
67
+ export declare function getAudienceMembers(apiKey: string, orgId: string, audienceId: string, opts?: {
68
68
  limit?: number;
69
69
  offset?: number;
70
70
  }): Promise<AudienceMembers>;
package/dist/audience.js CHANGED
@@ -39,7 +39,7 @@ async function updateAudience(apiKey, orgId, audienceId, patch) {
39
39
  async function deleteAudience(apiKey, orgId, audienceId) {
40
40
  return (0, client_1.request)('DELETE', `${config_1.AUDIENCE_BASE}/audience/orgs/${encodeURIComponent(orgId)}/audiences/${encodeURIComponent(audienceId)}`, apiKey);
41
41
  }
42
- async function getAudienceMembers(apiKey, orgId, audienceId, opts) {
42
+ async function getAudienceMembers(apiKey, orgId, audienceId, opts = {}) {
43
43
  const _q = new URLSearchParams();
44
44
  for (const [k, v] of Object.entries(opts)) {
45
45
  if (v != null)
package/dist/domain.d.ts CHANGED
@@ -40,7 +40,7 @@ export interface Registrant {
40
40
  }
41
41
  export interface RegisterDomainInput {
42
42
  years?: number;
43
- registrant: Registrant;
43
+ registrant?: Registrant;
44
44
  }
45
45
  export declare function checkDomain(apiKey: string, orgId: string, domain: string): Promise<{
46
46
  available: boolean;
package/dist/email.js CHANGED
@@ -36,9 +36,11 @@ exports.EXPOSES = [
36
36
  // Mailbox / sending activation
37
37
  'POST /email/mailboxes/create',
38
38
  'GET /email/mailboxes',
39
+ 'DELETE /email/mailboxes/{address}',
39
40
  'PUT /email/mailboxes/{address}/forwarding',
40
41
  'DELETE /email/mailboxes/{address}/forwarding',
41
42
  'POST /email/sending/activate',
43
+ 'POST /email/orgs/{org_id}/domains/{domain}/mail-server-resync',
42
44
  // Send + read
43
45
  'POST /email/send',
44
46
  'GET /email/status/{message_id}',
package/dist/hq.js CHANGED
@@ -63,6 +63,9 @@ exports.EXPOSES = [
63
63
  'GET /hq/billing/usage',
64
64
  'POST /hq/billing/setup-payment',
65
65
  'POST /hq/billing/topup',
66
+ 'GET /hq/billing/auto-recharge',
67
+ 'PUT /hq/billing/auto-recharge',
68
+ 'DELETE /hq/billing/auto-recharge',
66
69
  'GET /hq/orgs/{org_id}/doctor',
67
70
  ];
68
71
  // The closed grantable-slot vocabulary. Mirrors `iam.GrantableSlots` in the
package/dist/services.js CHANGED
@@ -112,7 +112,10 @@ exports.SERVICES = [
112
112
  domain: 'mypixelapi.com',
113
113
  description: 'Tracking pixel + identity resolution. Capture visits, events, and stitch known users to anonymous sessions.',
114
114
  category: 'capture',
115
- status: 'planned',
115
+ // Ingestion pipeline live in prod; CLI (visits/events/interactions/
116
+ // identity/audience) + skill shipped. Not ga: preview-subdomain ownership
117
+ // gap (TODO.md Gap 4) blocks the primary funnel flow.
118
+ status: 'preview',
116
119
  keywords: k('pixel', 'analytics', 'tracking', 'visit', 'identity'),
117
120
  },
118
121
  // ── data ────────────────────────────────────────────────────────────
package/dist/storage.js CHANGED
@@ -37,15 +37,18 @@ async function uploadAsset(apiKey, orgId, file, contentType, name) {
37
37
  catch {
38
38
  throw new client_1.MyApiError('invalid_json_response', response.status);
39
39
  }
40
- if (!response.ok) {
41
- const code = result?.error || 'unknown_error';
42
- throw new client_1.MyApiError(code, response.status);
40
+ // Mirror client.ts error handling: the backend's modern error shape is an
41
+ // object {code, message, ...}. The old string-only handling here made
42
+ // err.code an object, so e.g. funds.isInsufficientFunds could never match
43
+ // a 402 on a billable upload.
44
+ if (!response.ok || !result.success) {
45
+ const err = result?.error;
46
+ const code = typeof err === 'object' && err !== null ? (err?.code || 'unknown_error') : (err || 'unknown_error');
47
+ const detail = typeof err === 'object' && err !== null ? (err?.message || undefined) : undefined;
48
+ const errBody = typeof err === 'object' && err !== null ? err : undefined;
49
+ throw new client_1.MyApiError(code, response.status, detail, errBody);
43
50
  }
44
- const apiResponse = result;
45
- if (!apiResponse.success) {
46
- throw new client_1.MyApiError(apiResponse.error || 'unknown_error', response.status);
47
- }
48
- return apiResponse.data;
51
+ return result.data;
49
52
  }
50
53
  async function listAssets(apiKey, orgId) {
51
54
  return (0, client_1.request)('GET', `${config_1.STORAGE_BASE}/storage/orgs/${encodeURIComponent(orgId)}/assets`, apiKey);
@@ -17,6 +17,7 @@ export type WorkflowStep = {
17
17
  to: string;
18
18
  subject: string;
19
19
  template_id?: string;
20
+ text?: string;
20
21
  html?: string;
21
22
  } | {
22
23
  type: 'slack_message';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@myapihq/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "2.2.0",
4
+ "version": "2.4.0",
5
5
  "description": "TypeScript SDK for the MyAPI ecosystem",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/src/audience.ts CHANGED
@@ -147,7 +147,7 @@ export async function deleteAudience(apiKey: string, orgId: string, audienceId:
147
147
  return request('DELETE', `${BASE_URL}/audience/orgs/${encodeURIComponent(orgId)}/audiences/${encodeURIComponent(audienceId)}`, apiKey);
148
148
  }
149
149
 
150
- export async function getAudienceMembers(apiKey: string, orgId: string, audienceId: string, opts: { limit?: number; offset?: number }): Promise<AudienceMembers> {
150
+ export async function getAudienceMembers(apiKey: string, orgId: string, audienceId: string, opts: { limit?: number; offset?: number } = {}): Promise<AudienceMembers> {
151
151
  const _q = new URLSearchParams();
152
152
  for (const [k, v] of Object.entries(opts)) {
153
153
  if (v != null) _q.append(k, String(v));
package/src/domain.ts CHANGED
@@ -72,7 +72,11 @@ export interface Registrant {
72
72
 
73
73
  export interface RegisterDomainInput {
74
74
  years?: number;
75
- registrant: Registrant;
75
+ // Required only when the server runs REGISTRAR_PROVIDER=cloudflare (the CF
76
+ // account holds the zone; this is the WHOIS registrant). Under the legacy
77
+ // OpenProvider path it is ignored-but-accepted, so it's optional here and the
78
+ // backend enforces its presence when it actually needs it.
79
+ registrant?: Registrant;
76
80
  }
77
81
 
78
82
  export async function checkDomain(apiKey: string, orgId: string, domain: string): Promise<{ available: boolean; price_cents: number }> {
package/src/email.ts CHANGED
@@ -6,9 +6,11 @@ export const EXPOSES: Exposes = [
6
6
  // Mailbox / sending activation
7
7
  'POST /email/mailboxes/create',
8
8
  'GET /email/mailboxes',
9
+ 'DELETE /email/mailboxes/{address}',
9
10
  'PUT /email/mailboxes/{address}/forwarding',
10
11
  'DELETE /email/mailboxes/{address}/forwarding',
11
12
  'POST /email/sending/activate',
13
+ 'POST /email/orgs/{org_id}/domains/{domain}/mail-server-resync',
12
14
  // Send + read
13
15
  'POST /email/send',
14
16
  'GET /email/status/{message_id}',
package/src/hq.ts CHANGED
@@ -32,6 +32,9 @@ export const EXPOSES: Exposes = [
32
32
  'GET /hq/billing/usage',
33
33
  'POST /hq/billing/setup-payment',
34
34
  'POST /hq/billing/topup',
35
+ 'GET /hq/billing/auto-recharge',
36
+ 'PUT /hq/billing/auto-recharge',
37
+ 'DELETE /hq/billing/auto-recharge',
35
38
  'GET /hq/orgs/{org_id}/doctor',
36
39
  ];
37
40
 
package/src/llm.ts CHANGED
@@ -16,7 +16,7 @@ export const EXPOSES: Exposes = [
16
16
  ];
17
17
 
18
18
  // ── Raw surface ──────────────────────────────────────────────────────────
19
- // Backed *exclusively* by self-hosted open-source models (Qwen on our TPU).
19
+ // Backed *exclusively* by self-hosted open-source models on our own TPU.
20
20
  // The customer picks the model id from the catalog. Proprietary models are
21
21
  // not callable here — that rule is what keeps the LLM slot off the
22
22
  // reseller framing.
package/src/services.ts CHANGED
@@ -140,7 +140,10 @@ export const SERVICES: readonly ServiceMeta[] = [
140
140
  domain: 'mypixelapi.com',
141
141
  description: 'Tracking pixel + identity resolution. Capture visits, events, and stitch known users to anonymous sessions.',
142
142
  category: 'capture',
143
- status: 'planned',
143
+ // Ingestion pipeline live in prod; CLI (visits/events/interactions/
144
+ // identity/audience) + skill shipped. Not ga: preview-subdomain ownership
145
+ // gap (TODO.md Gap 4) blocks the primary funnel flow.
146
+ status: 'preview',
144
147
  keywords: k('pixel', 'analytics', 'tracking', 'visit', 'identity'),
145
148
  },
146
149
 
package/src/storage.ts CHANGED
@@ -56,17 +56,19 @@ export async function uploadAsset(apiKey: string, orgId: string, file: Blob | Bu
56
56
  throw new MyApiError('invalid_json_response', response.status);
57
57
  }
58
58
 
59
- if (!response.ok) {
60
- const code = result?.error || 'unknown_error';
61
- throw new MyApiError(code, response.status);
59
+ // Mirror client.ts error handling: the backend's modern error shape is an
60
+ // object {code, message, ...}. The old string-only handling here made
61
+ // err.code an object, so e.g. funds.isInsufficientFunds could never match
62
+ // a 402 on a billable upload.
63
+ if (!response.ok || !(result as ApiResponse<Asset>).success) {
64
+ const err = result?.error;
65
+ const code = typeof err === 'object' && err !== null ? (err?.code || 'unknown_error') : (err || 'unknown_error');
66
+ const detail = typeof err === 'object' && err !== null ? (err?.message || undefined) : undefined;
67
+ const errBody = typeof err === 'object' && err !== null ? err : undefined;
68
+ throw new MyApiError(code, response.status, detail, errBody);
62
69
  }
63
70
 
64
- const apiResponse = result as ApiResponse<Asset>;
65
- if (!apiResponse.success) {
66
- throw new MyApiError(apiResponse.error || 'unknown_error', response.status);
67
- }
68
-
69
- return apiResponse.data as Asset;
71
+ return (result as ApiResponse<Asset>).data as Asset;
70
72
  }
71
73
 
72
74
  export async function listAssets(apiKey: string, orgId: string): Promise<Asset[]> {
package/src/workflow.ts CHANGED
@@ -28,7 +28,7 @@ export const EXPOSES: Exposes = [
28
28
  * automatically injected into the HTML body.
29
29
  */
30
30
  export type WorkflowStep =
31
- | { type: 'send_email'; from: string; to: string; subject: string; template_id?: string; html?: string }
31
+ | { type: 'send_email'; from: string; to: string; subject: string; template_id?: string; text?: string; html?: string }
32
32
  | { type: 'slack_message'; webhook_url: string; text: string }
33
33
  // Backend (2026-05-15): `http_request` step is now accepted (alias: `http`).
34
34
  // POSTs (or other method) to `url` with the inbound payload; supports