@wxn0brp/vql-client 0.2.1 → 0.2.3

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
@@ -4,12 +4,16 @@ Minimalistic, pluggable client for **VQL** query execution.
4
4
 
5
5
  Supports:
6
6
 
7
- - ESM (`import`)
8
- - CDN / `<script>` (`VQLClient`)
9
- - Fully typed with TypeScript
10
- - Custom transport layers and lifecycle hooks
7
+ - ESM (`import`)
8
+ - CDN / `<script>` (`VQLClient`)
9
+ - Fully typed with TypeScript
10
+ - Custom transport layers and lifecycle hooks
11
11
 
12
- ## 🚀 Usage
12
+ ## DOCS
13
+
14
+ [API Reference](https://wxn0brp.github.io/VQL-client/)
15
+
16
+ ## Usage
13
17
 
14
18
  ### ESM
15
19
 
@@ -28,9 +32,9 @@ const result = await fetchVQL("db1 user! s._id = xyz");
28
32
  </script>
29
33
  ```
30
34
 
31
- ## 🧠 Usage
35
+ ## Usage
32
36
 
33
- ### `fetchVQL<T = any>(query: string | object): Promise<T>`
37
+ ### `fetchVQL<T = any>(query: string | object, vars?: Object, hookContext?: Object): Promise<T>`
34
38
 
35
39
  Executes a VQL query and returns the result (unwrapped from `{ result }`, unless an error is present).
36
40
 
@@ -49,13 +53,13 @@ VConfig.transport = async (query) => {
49
53
  }).then(res => res.json());
50
54
  }
51
55
  VConfig.hooks = {
52
- onStart: (q) => console.log("VQL start", q),
53
- onEnd: (q, ms, r) => console.log("VQL end", ms + "ms", r),
54
- onError: (q, e) => console.error("VQL error", e)
56
+ onStart: (query, ctx) => console.log("VQL start", query),
57
+ onEnd: (q, time, res, ctx) => console.log("VQL end", time + "ms", res),
58
+ onError: (q, e, ctx) => console.error("VQL error", e)
55
59
  }
56
60
  ```
57
61
 
58
- ## ✈️ Default Transport
62
+ ## Default Transport
59
63
 
60
64
  ```ts
61
65
  defTransport(query): Promise<any>
@@ -78,15 +82,10 @@ Returns:
78
82
  }
79
83
  ```
80
84
 
81
- ## 📁 Output Files
85
+ ## License
82
86
 
83
- ```
84
- dist/
85
- ├── index.js # ESM build (import)
86
- ├── index.d.ts # TypeScript types
87
- ├── vql-client.min.js # Global (CDN, window.VQLClient)
88
- ```
87
+ MIT wxn0brP
89
88
 
90
- ## 📜 License
89
+ ## Contributing
91
90
 
92
- MIT wxn0brP
91
+ Contributions are welcome!
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface Config {
10
10
  transport?: VQLTransport;
11
11
  hooks?: VQLHooks;
12
12
  url?: string;
13
+ body?: Record<string, any>;
13
14
  }
14
15
  export declare const VConfig: Config;
15
16
  export declare function fetchVQL<T = any>(query: VQLUQ<T>, vars?: any, hookContext?: any): Promise<T>;
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ export async function defTransport(query) {
39
39
  headers: {
40
40
  "Content-Type": "application/json"
41
41
  },
42
- body: JSON.stringify({ query })
42
+ body: JSON.stringify({ query, ...(VConfig.body || {}) })
43
43
  });
44
44
  if (!res.ok)
45
45
  throw new Error(`VQL request failed: ${res.status}`);
package/dist/min.js CHANGED
@@ -1 +1 @@
1
- var VQLClient=(()=>{var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var g=(r,t)=>{for(var e in t)s(r,e,{get:t[e],enumerable:!0})},m=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of w(t))!T.call(r,n)&&n!==e&&s(r,n,{get:()=>t[n],enumerable:!(a=l(t,n))||a.enumerable});return r};var E=r=>m(s({},"__esModule",{value:!0}),r);var U={};g(U,{VConfig:()=>i,defTransport:()=>Q,fetchVQL:()=>d});var i={transport:Q,hooks:{},url:"/VQL"};async function d(r,t={},e={}){var f,c,p,u;let{transport:a,hooks:n}=i,V=Date.now();try{e=Object.assign({},t,e),(f=n.onStart)==null||f.call(n,r,e),typeof r=="string"&&Object.keys(t).length&&(r={query:r,var:t});let o=await a(r),L=Date.now()-V;if((c=n.onEnd)==null||c.call(n,r,L,o,e),o!=null&&o.err){let y=new Error(o.err);throw(p=n.onError)==null||p.call(n,r,y,o,e),y}return o.result!==void 0?o.result:o}catch(o){throw(u=n.onError)==null||u.call(n,r,o,null,e),o}}async function Q(r){let t=await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:r})});if(!t.ok)throw new Error(`VQL request failed: ${t.status}`);return await t.json()}typeof window!="undefined"&&(window.VQLClient={fetchVQL:d,defTransport:Q,cfg:i});return E(U);})();
1
+ var VQLClient=(()=>{var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var V=(n,r,t)=>r in n?s(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,l=(n,r)=>{for(var t in r||(r={}))L.call(r,t)&&V(n,t,r[t]);if(u)for(var t of u(r))U.call(r,t)&&V(n,t,r[t]);return n};var b=(n,r)=>{for(var t in r)s(n,t,{get:r[t],enumerable:!0})},x=(n,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of E(r))!L.call(n,o)&&o!==t&&s(n,o,{get:()=>r[o],enumerable:!(i=m(r,o))||i.enumerable});return n};var j=n=>x(s({},"__esModule",{value:!0}),n);var O={};b(O,{VConfig:()=>a,defTransport:()=>Q,fetchVQL:()=>w});var a={transport:Q,hooks:{},url:"/VQL"};async function w(n,r={},t={}){var f,y,c,d;let{transport:i,hooks:o}=a,g=Date.now();try{t=Object.assign({},r,t),(f=o.onStart)==null||f.call(o,n,t),typeof n=="string"&&Object.keys(r).length&&(n={query:n,var:r});let e=await i(n),T=Date.now()-g;if((y=o.onEnd)==null||y.call(o,n,T,e,t),e!=null&&e.err){let p=new Error(e.err);throw(c=o.onError)==null||c.call(o,n,p,e,t),p}return e.result!==void 0?e.result:e}catch(e){throw(d=o.onError)==null||d.call(o,n,e,null,t),e}}async function Q(n){let r=await fetch(a.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l({query:n},a.body||{}))});if(!r.ok)throw new Error(`VQL request failed: ${r.status}`);return await r.json()}typeof window!="undefined"&&(window.VQLClient={fetchVQL:w,defTransport:Q,cfg:a});return j(O);})();
package/dist/vql.d.ts CHANGED
@@ -36,7 +36,7 @@ export type ArrayOperators<T = any> = {
36
36
  $size?: PartialOfType<T, number>;
37
37
  };
38
38
  export type StringOperators<T = any> = {
39
- $regex?: PartialOfType<T, RegExp, string>;
39
+ $regex?: PartialOfType<T, RegExp | string, string>;
40
40
  $startsWith?: PartialOfType<T, string>;
41
41
  $endsWith?: PartialOfType<T, string>;
42
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/vql-client",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "VQL Client",
@@ -13,8 +13,8 @@
13
13
  "license": "MIT",
14
14
  "type": "module",
15
15
  "devDependencies": {
16
- "esbuild": "^0.25.8",
17
- "typescript": "^5.8.3"
16
+ "esbuild": "*",
17
+ "typescript": "*"
18
18
  },
19
19
  "files": [
20
20
  "dist"
@@ -31,4 +31,4 @@
31
31
  "default": "./dist/*.js"
32
32
  }
33
33
  }
34
- }
34
+ }