@orth/sdk 0.1.0 → 0.3.1
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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
interface OrthogonalConfig {
|
|
5
5
|
/** Your Orthogonal API key (starts with orth_live_ or orth_test_) */
|
|
6
6
|
apiKey: string;
|
|
7
|
+
/** Custom headers to include in all requests */
|
|
8
|
+
headers?: Record<string, string>;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Options for the run() method
|
|
@@ -52,6 +54,7 @@ interface RunResponse {
|
|
|
52
54
|
*/
|
|
53
55
|
declare class Orthogonal {
|
|
54
56
|
private apiKey;
|
|
57
|
+
private customHeaders;
|
|
55
58
|
constructor(config: OrthogonalConfig);
|
|
56
59
|
/**
|
|
57
60
|
* Call any API on the Orthogonal platform
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
interface OrthogonalConfig {
|
|
5
5
|
/** Your Orthogonal API key (starts with orth_live_ or orth_test_) */
|
|
6
6
|
apiKey: string;
|
|
7
|
+
/** Custom headers to include in all requests */
|
|
8
|
+
headers?: Record<string, string>;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Options for the run() method
|
|
@@ -52,6 +54,7 @@ interface RunResponse {
|
|
|
52
54
|
*/
|
|
53
55
|
declare class Orthogonal {
|
|
54
56
|
private apiKey;
|
|
57
|
+
private customHeaders;
|
|
55
58
|
constructor(config: OrthogonalConfig);
|
|
56
59
|
/**
|
|
57
60
|
* Call any API on the Orthogonal platform
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var Orthogonal = class {
|
|
|
32
32
|
throw new Error("Orthogonal API key is required");
|
|
33
33
|
}
|
|
34
34
|
this.apiKey = config.apiKey;
|
|
35
|
+
this.customHeaders = config.headers || {};
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Call any API on the Orthogonal platform
|
|
@@ -43,7 +44,9 @@ var Orthogonal = class {
|
|
|
43
44
|
headers: {
|
|
44
45
|
Authorization: `Bearer ${this.apiKey}`,
|
|
45
46
|
"Content-Type": "application/json",
|
|
46
|
-
"User-Agent": `@orth/sdk/${VERSION}
|
|
47
|
+
"User-Agent": `@orth/sdk/${VERSION}`,
|
|
48
|
+
"X-Orthogonal-Source": "sdk",
|
|
49
|
+
...this.customHeaders
|
|
47
50
|
},
|
|
48
51
|
body: JSON.stringify({ api, path, query, body })
|
|
49
52
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrthogonalConfig, RunOptions, RunResponse } from \"./types\";\n\nconst VERSION = \"0.1.0\";\nconst BASE_URL = \"https://api.orth.sh\";\n\n/**\n * Orthogonal SDK client\n *\n * @example\n * ```typescript\n * import Orthogonal from \"@orth/sdk\";\n *\n * const orthogonal = new Orthogonal({\n * apiKey: process.env.ORTHOGONAL_API_KEY\n * });\n *\n * const response = await orthogonal.run({\n * api: \"andi\",\n * path: \"/api/v1/search\",\n * query: { q: \"hello world\" }\n * });\n *\n * console.log(response.data);\n * ```\n */\nexport class Orthogonal {\n private apiKey: string;\n\n constructor(config: OrthogonalConfig) {\n if (!config.apiKey) {\n throw new Error(\"Orthogonal API key is required\");\n }\n this.apiKey = config.apiKey;\n }\n\n /**\n * Call any API on the Orthogonal platform\n */\n async run(options: RunOptions): Promise<RunResponse> {\n const { api, path, query, body } = options;\n\n const response = await fetch(`${BASE_URL}/v1/run`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": `@orth/sdk/${VERSION}`,\n },\n body: JSON.stringify({ api, path, query, body }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n // Provide helpful error messages for common cases\n if (response.status === 401) {\n throw new Error(\"Invalid API key. Visit https://orthogonal.sh to get one!\");\n }\n if (response.status === 402) {\n throw new Error(\"Insufficient funds. Add USDC at https://orthogonal.sh\");\n }\n // Check for nested error in data.error (e.g., from target API)\n const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;\n throw new Error(errorMessage);\n }\n\n return data as RunResponse;\n }\n}\n\n// Export types\nexport * from \"./types\";\n\n// Default export\nexport default Orthogonal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,UAAU;AAChB,IAAM,WAAW;AAsBV,IAAM,aAAN,MAAiB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrthogonalConfig, RunOptions, RunResponse } from \"./types\";\n\nconst VERSION = \"0.1.0\";\nconst BASE_URL = \"https://api.orth.sh\";\n\n/**\n * Orthogonal SDK client\n *\n * @example\n * ```typescript\n * import Orthogonal from \"@orth/sdk\";\n *\n * const orthogonal = new Orthogonal({\n * apiKey: process.env.ORTHOGONAL_API_KEY\n * });\n *\n * const response = await orthogonal.run({\n * api: \"andi\",\n * path: \"/api/v1/search\",\n * query: { q: \"hello world\" }\n * });\n *\n * console.log(response.data);\n * ```\n */\nexport class Orthogonal {\n private apiKey: string;\n private customHeaders: Record<string, string>;\n\n constructor(config: OrthogonalConfig) {\n if (!config.apiKey) {\n throw new Error(\"Orthogonal API key is required\");\n }\n this.apiKey = config.apiKey;\n this.customHeaders = config.headers || {};\n }\n\n /**\n * Call any API on the Orthogonal platform\n */\n async run(options: RunOptions): Promise<RunResponse> {\n const { api, path, query, body } = options;\n\n const response = await fetch(`${BASE_URL}/v1/run`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": `@orth/sdk/${VERSION}`,\n \"X-Orthogonal-Source\": \"sdk\",\n ...this.customHeaders,\n },\n body: JSON.stringify({ api, path, query, body }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n // Provide helpful error messages for common cases\n if (response.status === 401) {\n throw new Error(\"Invalid API key. Visit https://orthogonal.sh to get one!\");\n }\n if (response.status === 402) {\n throw new Error(\"Insufficient funds. Add USDC at https://orthogonal.sh\");\n }\n // Check for nested error in data.error (e.g., from target API)\n const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;\n throw new Error(errorMessage);\n }\n\n return data as RunResponse;\n }\n}\n\n// Export types\nexport * from \"./types\";\n\n// Default export\nexport default Orthogonal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,UAAU;AAChB,IAAM,WAAW;AAsBV,IAAM,aAAN,MAAiB;AAAA,EAItB,YAAY,QAA0B;AACpC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,SAAK,SAAS,OAAO;AACrB,SAAK,gBAAgB,OAAO,WAAW,CAAC;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,SAA2C;AACnD,UAAM,EAAE,KAAK,MAAM,OAAO,KAAK,IAAI;AAEnC,UAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,WAAW;AAAA,MACjD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,gBAAgB;AAAA,QAChB,cAAc,aAAa,OAAO;AAAA,QAClC,uBAAuB;AAAA,QACvB,GAAG,KAAK;AAAA,MACV;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,KAAK,MAAM,OAAO,KAAK,CAAC;AAAA,IACjD,CAAC;AAED,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,CAAC,SAAS,IAAI;AAEhB,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,0DAA0D;AAAA,MAC5E;AACA,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AAEA,YAAM,eAAe,KAAK,MAAM,SAAS,KAAK,SAAS,8BAA8B,SAAS,MAAM;AACpG,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAEA,WAAO;AAAA,EACT;AACF;AAMA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ var Orthogonal = class {
|
|
|
7
7
|
throw new Error("Orthogonal API key is required");
|
|
8
8
|
}
|
|
9
9
|
this.apiKey = config.apiKey;
|
|
10
|
+
this.customHeaders = config.headers || {};
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Call any API on the Orthogonal platform
|
|
@@ -18,7 +19,9 @@ var Orthogonal = class {
|
|
|
18
19
|
headers: {
|
|
19
20
|
Authorization: `Bearer ${this.apiKey}`,
|
|
20
21
|
"Content-Type": "application/json",
|
|
21
|
-
"User-Agent": `@orth/sdk/${VERSION}
|
|
22
|
+
"User-Agent": `@orth/sdk/${VERSION}`,
|
|
23
|
+
"X-Orthogonal-Source": "sdk",
|
|
24
|
+
...this.customHeaders
|
|
22
25
|
},
|
|
23
26
|
body: JSON.stringify({ api, path, query, body })
|
|
24
27
|
});
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrthogonalConfig, RunOptions, RunResponse } from \"./types\";\n\nconst VERSION = \"0.1.0\";\nconst BASE_URL = \"https://api.orth.sh\";\n\n/**\n * Orthogonal SDK client\n *\n * @example\n * ```typescript\n * import Orthogonal from \"@orth/sdk\";\n *\n * const orthogonal = new Orthogonal({\n * apiKey: process.env.ORTHOGONAL_API_KEY\n * });\n *\n * const response = await orthogonal.run({\n * api: \"andi\",\n * path: \"/api/v1/search\",\n * query: { q: \"hello world\" }\n * });\n *\n * console.log(response.data);\n * ```\n */\nexport class Orthogonal {\n private apiKey: string;\n\n constructor(config: OrthogonalConfig) {\n if (!config.apiKey) {\n throw new Error(\"Orthogonal API key is required\");\n }\n this.apiKey = config.apiKey;\n }\n\n /**\n * Call any API on the Orthogonal platform\n */\n async run(options: RunOptions): Promise<RunResponse> {\n const { api, path, query, body } = options;\n\n const response = await fetch(`${BASE_URL}/v1/run`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": `@orth/sdk/${VERSION}`,\n },\n body: JSON.stringify({ api, path, query, body }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n // Provide helpful error messages for common cases\n if (response.status === 401) {\n throw new Error(\"Invalid API key. Visit https://orthogonal.sh to get one!\");\n }\n if (response.status === 402) {\n throw new Error(\"Insufficient funds. Add USDC at https://orthogonal.sh\");\n }\n // Check for nested error in data.error (e.g., from target API)\n const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;\n throw new Error(errorMessage);\n }\n\n return data as RunResponse;\n }\n}\n\n// Export types\nexport * from \"./types\";\n\n// Default export\nexport default Orthogonal;\n"],"mappings":";AAEA,IAAM,UAAU;AAChB,IAAM,WAAW;AAsBV,IAAM,aAAN,MAAiB;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrthogonalConfig, RunOptions, RunResponse } from \"./types\";\n\nconst VERSION = \"0.1.0\";\nconst BASE_URL = \"https://api.orth.sh\";\n\n/**\n * Orthogonal SDK client\n *\n * @example\n * ```typescript\n * import Orthogonal from \"@orth/sdk\";\n *\n * const orthogonal = new Orthogonal({\n * apiKey: process.env.ORTHOGONAL_API_KEY\n * });\n *\n * const response = await orthogonal.run({\n * api: \"andi\",\n * path: \"/api/v1/search\",\n * query: { q: \"hello world\" }\n * });\n *\n * console.log(response.data);\n * ```\n */\nexport class Orthogonal {\n private apiKey: string;\n private customHeaders: Record<string, string>;\n\n constructor(config: OrthogonalConfig) {\n if (!config.apiKey) {\n throw new Error(\"Orthogonal API key is required\");\n }\n this.apiKey = config.apiKey;\n this.customHeaders = config.headers || {};\n }\n\n /**\n * Call any API on the Orthogonal platform\n */\n async run(options: RunOptions): Promise<RunResponse> {\n const { api, path, query, body } = options;\n\n const response = await fetch(`${BASE_URL}/v1/run`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": `@orth/sdk/${VERSION}`,\n \"X-Orthogonal-Source\": \"sdk\",\n ...this.customHeaders,\n },\n body: JSON.stringify({ api, path, query, body }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n // Provide helpful error messages for common cases\n if (response.status === 401) {\n throw new Error(\"Invalid API key. Visit https://orthogonal.sh to get one!\");\n }\n if (response.status === 402) {\n throw new Error(\"Insufficient funds. Add USDC at https://orthogonal.sh\");\n }\n // Check for nested error in data.error (e.g., from target API)\n const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;\n throw new Error(errorMessage);\n }\n\n return data as RunResponse;\n }\n}\n\n// Export types\nexport * from \"./types\";\n\n// Default export\nexport default Orthogonal;\n"],"mappings":";AAEA,IAAM,UAAU;AAChB,IAAM,WAAW;AAsBV,IAAM,aAAN,MAAiB;AAAA,EAItB,YAAY,QAA0B;AACpC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,SAAK,SAAS,OAAO;AACrB,SAAK,gBAAgB,OAAO,WAAW,CAAC;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,SAA2C;AACnD,UAAM,EAAE,KAAK,MAAM,OAAO,KAAK,IAAI;AAEnC,UAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,WAAW;AAAA,MACjD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,gBAAgB;AAAA,QAChB,cAAc,aAAa,OAAO;AAAA,QAClC,uBAAuB;AAAA,QACvB,GAAG,KAAK;AAAA,MACV;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,KAAK,MAAM,OAAO,KAAK,CAAC;AAAA,IACjD,CAAC;AAED,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,CAAC,SAAS,IAAI;AAEhB,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,0DAA0D;AAAA,MAC5E;AACA,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AAEA,YAAM,eAAe,KAAK,MAAM,SAAS,KAAK,SAAS,8BAA8B,SAAS,MAAM;AACpG,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAEA,WAAO;AAAA,EACT;AACF;AAMA,IAAO,gBAAQ;","names":[]}
|