qwksearch-api-client 0.0.10 → 0.0.12

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/README.md CHANGED
@@ -22,44 +22,6 @@ QwkSearch API provides three core services for AI-powered research and content a
22
22
  2. **Language Generation** - Generate AI responses using multiple language model providers
23
23
  3. **Web Search** - Search the web using metasearch engine across 100+ sources
24
24
 
25
- ## Base URL
26
-
27
- ```
28
- https://qwksearch.com/api
29
- ```
30
-
31
- ## API Endpoints
32
-
33
- ### 1. Extract Content (`/extract`)
34
-
35
- Extract structured content, citations, and metadata from any URL including articles, PDFs, and YouTube videos.
36
-
37
- #### Features
38
-
39
- - **Main Content Detection**: Combines Mozilla Readability and Postlight Mercury algorithms with 100+ custom adapters
40
- - **HTML Standardization**: Transforms complex HTML into simplified reading-mode format
41
- - **YouTube Transcripts**: Retrieves complete video transcripts with timestamps
42
- - **PDF Processing**: Extracts formatted text and infers heading hierarchy
43
- - **Citation Extraction**: Identifies author names, publication dates, sources, and titles
44
- - **Author Formatting**: Validates against 90,000+ name database for proper citation formatting
45
-
46
- #### Request
47
-
48
- ```http
49
- GET /extract?url={url}&images={boolean}&links={boolean}
50
- ```
51
-
52
- **Parameters:**
53
-
54
- | Parameter | Type | Required | Default | Description |
55
- |-----------|------|----------|---------|-------------|
56
- | `url` | string (uri) | Yes | - | URL to extract content from |
57
- | `images` | boolean | No | true | Include images in output |
58
- | `links` | boolean | No | true | Include hyperlinks in output |
59
- | `formatting` | boolean | No | true | Preserve text formatting |
60
- | `absoluteURLs` | boolean | No | true | Convert relative URLs to absolute |
61
- | `timeout` | integer | No | 5 | HTTP request timeout (1-30 seconds) |
62
-
63
25
 
64
26
 
65
27
  ## Complete Example: Research Pipeline
@@ -124,6 +86,40 @@ researchTopic('quantum computing applications')
124
86
 
125
87
  ---
126
88
 
89
+
90
+ ## API Endpoints
91
+
92
+ ### 1. Extract Content (`/extract`)
93
+
94
+ Extract structured content, citations, and metadata from any URL including articles, PDFs, and YouTube videos.
95
+
96
+ #### Features
97
+
98
+ - **Main Content Detection**: Combines Mozilla Readability and Postlight Mercury algorithms with 100+ custom adapters
99
+ - **HTML Standardization**: Transforms complex HTML into simplified reading-mode format
100
+ - **YouTube Transcripts**: Retrieves complete video transcripts with timestamps
101
+ - **PDF Processing**: Extracts formatted text and infers heading hierarchy
102
+ - **Citation Extraction**: Identifies author names, publication dates, sources, and titles
103
+ - **Author Formatting**: Validates against 90,000+ name database for proper citation formatting
104
+
105
+ #### Request
106
+
107
+ ```http
108
+ GET /extract?url={url}&images={boolean}&links={boolean}
109
+ ```
110
+
111
+ **Parameters:**
112
+
113
+ | Parameter | Type | Required | Default | Description |
114
+ |-----------|------|----------|---------|-------------|
115
+ | `url` | string (uri) | Yes | - | URL to extract content from |
116
+ | `images` | boolean | No | true | Include images in output |
117
+ | `links` | boolean | No | true | Include hyperlinks in output |
118
+ | `formatting` | boolean | No | true | Preserve text formatting |
119
+ | `absoluteURLs` | boolean | No | true | Convert relative URLs to absolute |
120
+ | `timeout` | integer | No | 5 | HTTP request timeout (1-30 seconds) |
121
+
122
+
127
123
  ### 2. Generate Language (`/agents`)
128
124
 
129
125
  Generate AI responses using various language model providers with pre-built agent templates.
@@ -796,7 +796,7 @@ const createClient = (config = {}) => {
796
796
  trace: makeMethodFn("TRACE")
797
797
  };
798
798
  };
799
- const baseUrl = "https://qwksearch.com/api";
799
+ const baseUrl = "https://app.qwksearch.com/api";
800
800
  const createClientConfig = (config) => ({
801
801
  ...config,
802
802
  baseUrl
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["api-client"]={})}(this,function(e){"use strict";const t={bodySerializer:e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t)},r=({allowReserved:e,explode:t,name:r,style:a,value:n})=>{if(!t){const t=(e?n:n.map(e=>encodeURIComponent(e))).join((e=>{switch(e){case"form":default:return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20"}})(a));switch(a){case"label":return`.${t}`;case"matrix":return`;${r}=${t}`;case"simple":return t;default:return`${r}=${t}`}}const o=(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}})(a),i=n.map(t=>"label"===a||"simple"===a?e?t:encodeURIComponent(t):s({allowReserved:e,name:r,value:t})).join(o);return"label"===a||"matrix"===a?o+i:i},s=({allowReserved:e,name:t,value:r})=>{if(null==r)return"";if("object"==typeof r)throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},a=({allowReserved:e,explode:t,name:r,style:a,value:n,valueOnly:o})=>{if(n instanceof Date)return o?n.toISOString():`${r}=${n.toISOString()}`;if("deepObject"!==a&&!t){let t=[];Object.entries(n).forEach(([r,s])=>{t=[...t,r,e?s:encodeURIComponent(s)]});const s=t.join(",");switch(a){case"form":return`${r}=${s}`;case"label":return`.${s}`;case"matrix":return`;${r}=${s}`;default:return s}}const i=(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}})(a),l=Object.entries(n).map(([t,n])=>s({allowReserved:e,name:"deepObject"===a?`${r}[${t}]`:t,value:n})).join(i);return"label"===a||"matrix"===a?i+l:l},n=/\{[^{}]+\}/g,o=({baseUrl:e,path:t,query:o,querySerializer:i,url:l})=>{let c=(e??"")+(l.startsWith("/")?l:`/${l}`);t&&(c=(({path:e,url:t})=>{let o=t;const i=t.match(n);if(i)for(const n of i){let t=!1,i=n.substring(1,n.length-1),l="simple";i.endsWith("*")&&(t=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),l="label"):i.startsWith(";")&&(i=i.substring(1),l="matrix");const c=e[i];if(null==c)continue;if(Array.isArray(c)){o=o.replace(n,r({explode:t,name:i,style:l,value:c}));continue}if("object"==typeof c){o=o.replace(n,a({explode:t,name:i,style:l,value:c,valueOnly:!0}));continue}if("matrix"===l){o=o.replace(n,`;${s({name:i,value:c})}`);continue}const d=encodeURIComponent("label"===l?`.${c}`:c);o=o.replace(n,d)}return o})({path:t,url:c}));let d=o?i(o):"";return d.startsWith("?")&&(d=d.substring(1)),d&&(c+=`?${d}`),c};function i(e){const t=void 0!==e.body;if(t&&e.bodySerializer){if("serializedBody"in e){return void 0!==e.serializedBody&&""!==e.serializedBody?e.serializedBody:null}return""!==e.body?e.body:null}if(t)return e.body}const l=async(e,t)=>{const r="function"==typeof t?await t(e):t;if(r)return"bearer"===e.scheme?`Bearer ${r}`:"basic"===e.scheme?`Basic ${btoa(r)}`:r},c=({parameters:e={},...t}={})=>n=>{const o=[];if(n&&"object"==typeof n)for(const i in n){const l=n[i];if(null==l)continue;const c=e[i]||t;if(Array.isArray(l)){const e=r({allowReserved:c.allowReserved,explode:!0,name:i,style:"form",value:l,...c.array});e&&o.push(e)}else if("object"==typeof l){const e=a({allowReserved:c.allowReserved,explode:!0,name:i,style:"deepObject",value:l,...c.object});e&&o.push(e)}else{const e=s({allowReserved:c.allowReserved,name:i,value:l});e&&o.push(e)}}return o.join("&")},d=(e,t)=>!!t&&!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)),u=e=>o({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:"function"==typeof e.querySerializer?e.querySerializer:c(e.querySerializer),url:e.url}),f=(e,t)=>{const r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=h(e.headers,t.headers),r},p=e=>{const t=[];return e.forEach((e,r)=>{t.push([r,e])}),t},h=(...e)=>{const t=new Headers;for(const r of e){if(!r)continue;const e=r instanceof Headers?p(r):Object.entries(r);for(const[r,s]of e)if(null===s)t.delete(r);else if(Array.isArray(s))for(const e of s)t.append(r,e);else void 0!==s&&t.set(r,"object"==typeof s?JSON.stringify(s):s)}return t};class y{fns=[];clear(){this.fns=[]}eject(e){const t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){const t=this.getInterceptorIndex(e);return Boolean(this.fns[t])}getInterceptorIndex(e){return"number"==typeof e?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){const r=this.getInterceptorIndex(e);return!!this.fns[r]&&(this.fns[r]=t,e)}use(e){return this.fns.push(e),this.fns.length-1}}const b=c({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),m={"Content-Type":"application/json"},w=(e={})=>({...t,headers:m,parseAs:"auto",querySerializer:b,...e}),v=((e={})=>{let t=f(w(),e);const r=()=>({...t}),s={error:new y,request:new y,response:new y},a=async e=>{const r={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:h(t.headers,e.headers),serializedBody:void 0};r.security&&await(async({security:e,...t})=>{for(const r of e){if(d(t,r.name))continue;const e=await l(r,t.auth);if(!e)continue;const s=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[s]=e;break;case"cookie":t.headers.append("Cookie",`${s}=${e}`);break;default:t.headers.set(s,e)}}})({...r,security:r.security}),r.requestValidator&&await r.requestValidator(r),void 0!==r.body&&r.bodySerializer&&(r.serializedBody=r.bodySerializer(r.body)),void 0!==r.body&&""!==r.serializedBody||r.headers.delete("Content-Type");return{opts:r,url:u(r)}},n=async e=>{const{opts:t,url:r}=await a(e),n={redirect:"follow",...t,body:i(t)};let o=new Request(r,n);for(const a of s.request.fns)a&&(o=await a(o,t));const l=t.fetch;let c;try{c=await l(o)}catch(y){let e=y;for(const r of s.error.fns)r&&(e=await r(y,void 0,o,t));if(e=e||{},t.throwOnError)throw e;return"data"===t.responseStyle?void 0:{error:e,request:o,response:void 0}}for(const a of s.response.fns)a&&(c=await a(c,o,t));const d={request:o,response:c};if(c.ok){const e=("auto"===t.parseAs?(e=>{if(!e)return"stream";const t=e.split(";")[0]?.trim();return t?t.startsWith("application/json")||t.endsWith("+json")?"json":"multipart/form-data"===t?"formData":["application/","audio/","image/","video/"].some(e=>t.startsWith(e))?"blob":t.startsWith("text/")?"text":void 0:void 0})(c.headers.get("Content-Type")):t.parseAs)??"json";if(204===c.status||"0"===c.headers.get("Content-Length")){let r;switch(e){case"arrayBuffer":case"blob":case"text":r=await c[e]();break;case"formData":r=new FormData;break;case"stream":r=c.body;break;default:r={}}return"data"===t.responseStyle?r:{data:r,...d}}let r;switch(e){case"arrayBuffer":case"blob":case"formData":case"json":case"text":r=await c[e]();break;case"stream":return"data"===t.responseStyle?c.body:{data:c.body,...d}}return"json"===e&&(t.responseValidator&&await t.responseValidator(r),t.responseTransformer&&(r=await t.responseTransformer(r))),"data"===t.responseStyle?r:{data:r,...d}}const u=await c.text();let f;try{f=JSON.parse(u)}catch{}const p=f??u;let h=p;for(const a of s.error.fns)a&&(h=await a(p,c,o,t));if(h=h||{},t.throwOnError)throw h;return"data"===t.responseStyle?void 0:{error:h,...d}},o=e=>t=>n({...t,method:e}),c=e=>async t=>{const{opts:r,url:n}=await a(t);return(({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:s,responseValidator:a,sseDefaultRetryDelay:n,sseMaxRetryAttempts:o,sseMaxRetryDelay:i,sseSleepFn:l,url:c,...d})=>{let u;const f=l??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let l=n??3e3,p=0;const h=d.signal??(new AbortController).signal;for(;!h.aborted;){p++;const n=d.headers instanceof Headers?d.headers:new Headers(d.headers);void 0!==u&&n.set("Last-Event-ID",u);try{const t={redirect:"follow",...d,body:d.serializedBody,headers:n,signal:h};let o=new Request(c,t);e&&(o=await e(c,t));const i=d.fetch??globalThis.fetch,f=await i(o);if(!f.ok)throw new Error(`SSE failed: ${f.status} ${f.statusText}`);if(!f.body)throw new Error("No body in SSE response");const p=f.body.pipeThrough(new TextDecoderStream).getReader();let y="";const b=()=>{try{p.cancel()}catch{}};h.addEventListener("abort",b);try{for(;;){const{done:e,value:t}=await p.read();if(e)break;y+=t;const n=y.split("\n\n");y=n.pop()??"";for(const o of n){const e=o.split("\n"),t=[];let n,i;for(const r of e)if(r.startsWith("data:"))t.push(r.replace(/^data:\s*/,""));else if(r.startsWith("event:"))n=r.replace(/^event:\s*/,"");else if(r.startsWith("id:"))u=r.replace(/^id:\s*/,"");else if(r.startsWith("retry:")){const e=Number.parseInt(r.replace(/^retry:\s*/,""),10);Number.isNaN(e)||(l=e)}let c=!1;if(t.length){const e=t.join("\n");try{i=JSON.parse(e),c=!0}catch{i=e}}c&&(a&&await a(i),s&&(i=await s(i))),r?.({data:i,event:n,id:u,retry:l}),t.length&&(yield i)}}}finally{h.removeEventListener("abort",b),p.releaseLock()}break}catch(y){if(t?.(y),void 0!==o&&p>=o)break;const e=Math.min(l*2**(p-1),i??3e4);await f(e)}}}()}})({...r,body:r.body,headers:r.headers,method:e,onRequest:async(e,t)=>{let a=new Request(e,t);for(const n of s.request.fns)n&&(a=await n(a,r));return a},url:n})};return{buildUrl:u,connect:o("CONNECT"),delete:o("DELETE"),get:o("GET"),getConfig:r,head:o("HEAD"),interceptors:s,options:o("OPTIONS"),patch:o("PATCH"),post:o("POST"),put:o("PUT"),request:n,setConfig:e=>(t=f(t,e),r()),sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:o("TRACE")}})((g=w(),{...g,baseUrl:"https://qwksearch.com/api"}));var g;e.extractContent=e=>(e.client??v).get({url:"/extract",...e}),e.searchWeb=e=>(e.client??v).get({url:"/search",...e}),e.writeLanguage=e=>(e.client??v).post({url:"/agents",...e,headers:{"Content-Type":"application/json",...e.headers}}),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["api-client"]={})}(this,function(e){"use strict";const t={bodySerializer:e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t)},r=({allowReserved:e,explode:t,name:r,style:a,value:n})=>{if(!t){const t=(e?n:n.map(e=>encodeURIComponent(e))).join((e=>{switch(e){case"form":default:return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20"}})(a));switch(a){case"label":return`.${t}`;case"matrix":return`;${r}=${t}`;case"simple":return t;default:return`${r}=${t}`}}const o=(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}})(a),i=n.map(t=>"label"===a||"simple"===a?e?t:encodeURIComponent(t):s({allowReserved:e,name:r,value:t})).join(o);return"label"===a||"matrix"===a?o+i:i},s=({allowReserved:e,name:t,value:r})=>{if(null==r)return"";if("object"==typeof r)throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},a=({allowReserved:e,explode:t,name:r,style:a,value:n,valueOnly:o})=>{if(n instanceof Date)return o?n.toISOString():`${r}=${n.toISOString()}`;if("deepObject"!==a&&!t){let t=[];Object.entries(n).forEach(([r,s])=>{t=[...t,r,e?s:encodeURIComponent(s)]});const s=t.join(",");switch(a){case"form":return`${r}=${s}`;case"label":return`.${s}`;case"matrix":return`;${r}=${s}`;default:return s}}const i=(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}})(a),l=Object.entries(n).map(([t,n])=>s({allowReserved:e,name:"deepObject"===a?`${r}[${t}]`:t,value:n})).join(i);return"label"===a||"matrix"===a?i+l:l},n=/\{[^{}]+\}/g,o=({baseUrl:e,path:t,query:o,querySerializer:i,url:l})=>{let c=(e??"")+(l.startsWith("/")?l:`/${l}`);t&&(c=(({path:e,url:t})=>{let o=t;const i=t.match(n);if(i)for(const n of i){let t=!1,i=n.substring(1,n.length-1),l="simple";i.endsWith("*")&&(t=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),l="label"):i.startsWith(";")&&(i=i.substring(1),l="matrix");const c=e[i];if(null==c)continue;if(Array.isArray(c)){o=o.replace(n,r({explode:t,name:i,style:l,value:c}));continue}if("object"==typeof c){o=o.replace(n,a({explode:t,name:i,style:l,value:c,valueOnly:!0}));continue}if("matrix"===l){o=o.replace(n,`;${s({name:i,value:c})}`);continue}const d=encodeURIComponent("label"===l?`.${c}`:c);o=o.replace(n,d)}return o})({path:t,url:c}));let d=o?i(o):"";return d.startsWith("?")&&(d=d.substring(1)),d&&(c+=`?${d}`),c};function i(e){const t=void 0!==e.body;if(t&&e.bodySerializer){if("serializedBody"in e){return void 0!==e.serializedBody&&""!==e.serializedBody?e.serializedBody:null}return""!==e.body?e.body:null}if(t)return e.body}const l=async(e,t)=>{const r="function"==typeof t?await t(e):t;if(r)return"bearer"===e.scheme?`Bearer ${r}`:"basic"===e.scheme?`Basic ${btoa(r)}`:r},c=({parameters:e={},...t}={})=>n=>{const o=[];if(n&&"object"==typeof n)for(const i in n){const l=n[i];if(null==l)continue;const c=e[i]||t;if(Array.isArray(l)){const e=r({allowReserved:c.allowReserved,explode:!0,name:i,style:"form",value:l,...c.array});e&&o.push(e)}else if("object"==typeof l){const e=a({allowReserved:c.allowReserved,explode:!0,name:i,style:"deepObject",value:l,...c.object});e&&o.push(e)}else{const e=s({allowReserved:c.allowReserved,name:i,value:l});e&&o.push(e)}}return o.join("&")},d=(e,t)=>!!t&&!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)),u=e=>o({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:"function"==typeof e.querySerializer?e.querySerializer:c(e.querySerializer),url:e.url}),f=(e,t)=>{const r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=h(e.headers,t.headers),r},p=e=>{const t=[];return e.forEach((e,r)=>{t.push([r,e])}),t},h=(...e)=>{const t=new Headers;for(const r of e){if(!r)continue;const e=r instanceof Headers?p(r):Object.entries(r);for(const[r,s]of e)if(null===s)t.delete(r);else if(Array.isArray(s))for(const e of s)t.append(r,e);else void 0!==s&&t.set(r,"object"==typeof s?JSON.stringify(s):s)}return t};class y{fns=[];clear(){this.fns=[]}eject(e){const t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){const t=this.getInterceptorIndex(e);return Boolean(this.fns[t])}getInterceptorIndex(e){return"number"==typeof e?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){const r=this.getInterceptorIndex(e);return!!this.fns[r]&&(this.fns[r]=t,e)}use(e){return this.fns.push(e),this.fns.length-1}}const b=c({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),m={"Content-Type":"application/json"},w=(e={})=>({...t,headers:m,parseAs:"auto",querySerializer:b,...e}),v=((e={})=>{let t=f(w(),e);const r=()=>({...t}),s={error:new y,request:new y,response:new y},a=async e=>{const r={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:h(t.headers,e.headers),serializedBody:void 0};r.security&&await(async({security:e,...t})=>{for(const r of e){if(d(t,r.name))continue;const e=await l(r,t.auth);if(!e)continue;const s=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[s]=e;break;case"cookie":t.headers.append("Cookie",`${s}=${e}`);break;default:t.headers.set(s,e)}}})({...r,security:r.security}),r.requestValidator&&await r.requestValidator(r),void 0!==r.body&&r.bodySerializer&&(r.serializedBody=r.bodySerializer(r.body)),void 0!==r.body&&""!==r.serializedBody||r.headers.delete("Content-Type");return{opts:r,url:u(r)}},n=async e=>{const{opts:t,url:r}=await a(e),n={redirect:"follow",...t,body:i(t)};let o=new Request(r,n);for(const a of s.request.fns)a&&(o=await a(o,t));const l=t.fetch;let c;try{c=await l(o)}catch(y){let e=y;for(const r of s.error.fns)r&&(e=await r(y,void 0,o,t));if(e=e||{},t.throwOnError)throw e;return"data"===t.responseStyle?void 0:{error:e,request:o,response:void 0}}for(const a of s.response.fns)a&&(c=await a(c,o,t));const d={request:o,response:c};if(c.ok){const e=("auto"===t.parseAs?(e=>{if(!e)return"stream";const t=e.split(";")[0]?.trim();return t?t.startsWith("application/json")||t.endsWith("+json")?"json":"multipart/form-data"===t?"formData":["application/","audio/","image/","video/"].some(e=>t.startsWith(e))?"blob":t.startsWith("text/")?"text":void 0:void 0})(c.headers.get("Content-Type")):t.parseAs)??"json";if(204===c.status||"0"===c.headers.get("Content-Length")){let r;switch(e){case"arrayBuffer":case"blob":case"text":r=await c[e]();break;case"formData":r=new FormData;break;case"stream":r=c.body;break;default:r={}}return"data"===t.responseStyle?r:{data:r,...d}}let r;switch(e){case"arrayBuffer":case"blob":case"formData":case"json":case"text":r=await c[e]();break;case"stream":return"data"===t.responseStyle?c.body:{data:c.body,...d}}return"json"===e&&(t.responseValidator&&await t.responseValidator(r),t.responseTransformer&&(r=await t.responseTransformer(r))),"data"===t.responseStyle?r:{data:r,...d}}const u=await c.text();let f;try{f=JSON.parse(u)}catch{}const p=f??u;let h=p;for(const a of s.error.fns)a&&(h=await a(p,c,o,t));if(h=h||{},t.throwOnError)throw h;return"data"===t.responseStyle?void 0:{error:h,...d}},o=e=>t=>n({...t,method:e}),c=e=>async t=>{const{opts:r,url:n}=await a(t);return(({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:s,responseValidator:a,sseDefaultRetryDelay:n,sseMaxRetryAttempts:o,sseMaxRetryDelay:i,sseSleepFn:l,url:c,...d})=>{let u;const f=l??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let l=n??3e3,p=0;const h=d.signal??(new AbortController).signal;for(;!h.aborted;){p++;const n=d.headers instanceof Headers?d.headers:new Headers(d.headers);void 0!==u&&n.set("Last-Event-ID",u);try{const t={redirect:"follow",...d,body:d.serializedBody,headers:n,signal:h};let o=new Request(c,t);e&&(o=await e(c,t));const i=d.fetch??globalThis.fetch,f=await i(o);if(!f.ok)throw new Error(`SSE failed: ${f.status} ${f.statusText}`);if(!f.body)throw new Error("No body in SSE response");const p=f.body.pipeThrough(new TextDecoderStream).getReader();let y="";const b=()=>{try{p.cancel()}catch{}};h.addEventListener("abort",b);try{for(;;){const{done:e,value:t}=await p.read();if(e)break;y+=t;const n=y.split("\n\n");y=n.pop()??"";for(const o of n){const e=o.split("\n"),t=[];let n,i;for(const r of e)if(r.startsWith("data:"))t.push(r.replace(/^data:\s*/,""));else if(r.startsWith("event:"))n=r.replace(/^event:\s*/,"");else if(r.startsWith("id:"))u=r.replace(/^id:\s*/,"");else if(r.startsWith("retry:")){const e=Number.parseInt(r.replace(/^retry:\s*/,""),10);Number.isNaN(e)||(l=e)}let c=!1;if(t.length){const e=t.join("\n");try{i=JSON.parse(e),c=!0}catch{i=e}}c&&(a&&await a(i),s&&(i=await s(i))),r?.({data:i,event:n,id:u,retry:l}),t.length&&(yield i)}}}finally{h.removeEventListener("abort",b),p.releaseLock()}break}catch(y){if(t?.(y),void 0!==o&&p>=o)break;const e=Math.min(l*2**(p-1),i??3e4);await f(e)}}}()}})({...r,body:r.body,headers:r.headers,method:e,onRequest:async(e,t)=>{let a=new Request(e,t);for(const n of s.request.fns)n&&(a=await n(a,r));return a},url:n})};return{buildUrl:u,connect:o("CONNECT"),delete:o("DELETE"),get:o("GET"),getConfig:r,head:o("HEAD"),interceptors:s,options:o("OPTIONS"),patch:o("PATCH"),post:o("POST"),put:o("PUT"),request:n,setConfig:e=>(t=f(t,e),r()),sse:{connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),head:c("HEAD"),options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),trace:c("TRACE")},trace:o("TRACE")}})((g=w(),{...g,baseUrl:"https://app.qwksearch.com/api"}));var g;e.extractContent=e=>(e.client??v).get({url:"/extract",...e}),e.searchWeb=e=>(e.client??v).get({url:"/search",...e}),e.writeLanguage=e=>(e.client??v).post({url:"/agents",...e,headers:{"Content-Type":"application/json",...e.headers}}),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwksearch-api-client",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "QwkSearch API Client - Generated from openapi-docs.yml",
5
5
  "type": "module",
6
6
  "main": "./dist/api-client.js",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "scripts": {
16
16
  "ship": "npx standard-version --release-as patch; npm publish",
17
- "build:api": "API_URL=https://qwksearch.com/api openapi-ts && vite build",
17
+ "build:api": "API_URL=https://app.qwksearch.com/api openapi-ts && vite build",
18
18
  "test:api": "vitest"
19
19
  },
20
20
  "files": [