@myapihq/sdk 1.0.39 → 1.0.41

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.js CHANGED
@@ -40,12 +40,15 @@ async function request(method, url, apiKey, body) {
40
40
  throw new MyApiError('invalid_json_response', response.status);
41
41
  }
42
42
  if (!response.ok) {
43
- const code = result?.error || 'unknown_error';
43
+ const err = result?.error;
44
+ const code = typeof err === 'object' ? (err?.code || 'unknown_error') : (err || 'unknown_error');
44
45
  throw new MyApiError(code, response.status);
45
46
  }
46
47
  const apiResponse = result;
47
48
  if (!apiResponse.success) {
48
- throw new MyApiError(apiResponse.error || 'unknown_error', response.status);
49
+ const err = apiResponse.error;
50
+ const code = typeof err === 'object' ? (err?.code || 'unknown_error') : (err || 'unknown_error');
51
+ throw new MyApiError(code, response.status);
49
52
  }
50
53
  return apiResponse.data;
51
54
  }
package/dist/domain.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare function importDomain(apiKey: string, orgId: string, payload: {
23
23
  }): Promise<DomainRecord>;
24
24
  export declare function listDomains(apiKey: string, orgId: string, filter?: string): Promise<DomainRecord[]>;
25
25
  export declare function getDomainStatus(apiKey: string, orgId: string, domain: string): Promise<DomainRecord>;
26
- export declare function assignDomain(apiKey: string, orgId: string, domain: string, targetOrgId: string): Promise<DomainRecord>;
26
+ export declare function assignDomain(apiKey: string, orgId: string, domain: string): Promise<DomainRecord>;
27
27
  export declare function unassignDomain(apiKey: string, orgId: string, domain: string): Promise<DomainRecord>;
28
28
  export declare function getDomainSettings(apiKey: string, orgId: string, domain: string): Promise<DomainSettings>;
29
29
  export declare function updateDomainSettings(apiKey: string, orgId: string, domain: string, payload: {
package/dist/domain.js CHANGED
@@ -27,9 +27,8 @@ async function listDomains(apiKey, orgId, filter) {
27
27
  async function getDomainStatus(apiKey, orgId, domain) {
28
28
  return (0, client_1.request)('GET', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/status`, apiKey);
29
29
  }
30
- async function assignDomain(apiKey, orgId, domain, targetOrgId) {
31
- const org_id_payload = targetOrgId === 'null' ? null : targetOrgId;
32
- return (0, client_1.request)('POST', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/assign`, apiKey, { org_id: org_id_payload });
30
+ async function assignDomain(apiKey, orgId, domain) {
31
+ return (0, client_1.request)('POST', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/assign`, apiKey, { org_id: orgId });
33
32
  }
34
33
  async function unassignDomain(apiKey, orgId, domain) {
35
34
  return (0, client_1.request)('POST', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/assign`, apiKey, { org_id: null });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myapihq/sdk",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "TypeScript SDK for the MyAPI ecosystem",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/client.ts CHANGED
@@ -46,13 +46,16 @@ export async function request<T>(
46
46
  }
47
47
 
48
48
  if (!response.ok) {
49
- const code = result?.error || 'unknown_error';
49
+ const err = result?.error;
50
+ const code = typeof err === 'object' ? (err?.code || 'unknown_error') : (err || 'unknown_error');
50
51
  throw new MyApiError(code, response.status);
51
52
  }
52
53
 
53
54
  const apiResponse = result as ApiResponse<T>;
54
55
  if (!apiResponse.success) {
55
- throw new MyApiError(apiResponse.error || 'unknown_error', response.status);
56
+ const err = apiResponse.error as any;
57
+ const code = typeof err === 'object' ? (err?.code || 'unknown_error') : (err || 'unknown_error');
58
+ throw new MyApiError(code, response.status);
56
59
  }
57
60
 
58
61
  return apiResponse.data as T;
package/src/domain.ts CHANGED
@@ -38,9 +38,8 @@ export async function getDomainStatus(apiKey: string, orgId: string, domain: str
38
38
  return request('GET', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/status`, apiKey);
39
39
  }
40
40
 
41
- export async function assignDomain(apiKey: string, orgId: string, domain: string, targetOrgId: string): Promise<DomainRecord> {
42
- const org_id_payload = targetOrgId === 'null' ? null : targetOrgId;
43
- return request('POST', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/assign`, apiKey, { org_id: org_id_payload });
41
+ export async function assignDomain(apiKey: string, orgId: string, domain: string): Promise<DomainRecord> {
42
+ return request('POST', `${BASE_URL}/domain/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(domain)}/assign`, apiKey, { org_id: orgId });
44
43
  }
45
44
 
46
45
  export async function unassignDomain(apiKey: string, orgId: string, domain: string): Promise<DomainRecord> {