@wxn0brp/vql-client 0.0.1 → 0.0.2
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/package.json +23 -24
- package/.github/workflows/build.yml +0 -25
- package/build.js +0 -33
- package/src/index.ts +0 -70
- package/suglite.json +0 -10
- package/tsconfig.json +0 -25
package/package.json
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
2
|
+
"name": "@wxn0brp/vql-client",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"author": "wxn0brP",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"esbuild": "^0.25.4",
|
|
11
|
+
"tsc-alias": "^1.8.10",
|
|
12
|
+
"typescript": "^5.7.3"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs",
|
|
22
|
+
"default": "./dist/index.js"
|
|
25
23
|
}
|
|
26
|
-
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Build
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
tags:
|
|
8
|
-
- "*"
|
|
9
|
-
|
|
10
|
-
workflow_dispatch:
|
|
11
|
-
|
|
12
|
-
concurrency:
|
|
13
|
-
group: build-main
|
|
14
|
-
cancel-in-progress: true
|
|
15
|
-
|
|
16
|
-
jobs:
|
|
17
|
-
build:
|
|
18
|
-
uses: wxn0brP/workflow-dist/.github/workflows/build-ts.yml@main
|
|
19
|
-
with:
|
|
20
|
-
scriptsHandling: "remove-all"
|
|
21
|
-
customCommands: "npm run minify"
|
|
22
|
-
publishToNpm: true
|
|
23
|
-
|
|
24
|
-
secrets:
|
|
25
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/build.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import esbuild from "esbuild";
|
|
2
|
-
|
|
3
|
-
const sharedConfig = {
|
|
4
|
-
entryPoints: ["src/index.ts"],
|
|
5
|
-
bundle: true,
|
|
6
|
-
sourcemap: false,
|
|
7
|
-
target: "es2017",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
Promise.all([
|
|
11
|
-
// IIFE + minified
|
|
12
|
-
esbuild.build({
|
|
13
|
-
...sharedConfig,
|
|
14
|
-
format: "iife",
|
|
15
|
-
globalName: "VQLClient",
|
|
16
|
-
minify: true,
|
|
17
|
-
outfile: "dist/vql-client.min.js",
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
|
-
// CommonJS - require
|
|
21
|
-
esbuild.build({
|
|
22
|
-
...sharedConfig,
|
|
23
|
-
format: "cjs",
|
|
24
|
-
outfile: "dist/vql-client.cjs",
|
|
25
|
-
}),
|
|
26
|
-
])
|
|
27
|
-
.then(() => {
|
|
28
|
-
console.log("✅ Build complete");
|
|
29
|
-
})
|
|
30
|
-
.catch((e) => {
|
|
31
|
-
console.error("❌ Build failed:", e);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export type VQLQuery = string | object;
|
|
2
|
-
export type VQLResult<T = any> = Promise<T>;
|
|
3
|
-
export type VQLTransport = (query: VQLQuery) => VQLResult;
|
|
4
|
-
export type VQLHooks = {
|
|
5
|
-
onStart?: (query: VQLQuery) => void;
|
|
6
|
-
onEnd?: (query: VQLQuery, durationMs: number, result: any) => void;
|
|
7
|
-
onError?: (query: VQLQuery, error: unknown) => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let transport: VQLTransport = defaultFetchTransport;
|
|
11
|
-
let hooks: VQLHooks = {};
|
|
12
|
-
|
|
13
|
-
export function initVQLClient(config: {
|
|
14
|
-
transport?: VQLTransport,
|
|
15
|
-
hooks?: VQLHooks
|
|
16
|
-
}) {
|
|
17
|
-
if (config.transport) transport = config.transport;
|
|
18
|
-
if (config.hooks) hooks = config.hooks;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function fetchVQL<T = any>(query: VQLQuery): Promise<T> {
|
|
22
|
-
const start = Date.now();
|
|
23
|
-
try {
|
|
24
|
-
hooks.onStart?.(query);
|
|
25
|
-
|
|
26
|
-
const res = await transport(query);
|
|
27
|
-
|
|
28
|
-
const duration = Date.now() - start;
|
|
29
|
-
hooks.onEnd?.(query, duration, res);
|
|
30
|
-
|
|
31
|
-
if (res?.err) {
|
|
32
|
-
const error = new Error(res.err);
|
|
33
|
-
hooks.onError?.(query, error);
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return res?.result ?? res;
|
|
38
|
-
} catch (e) {
|
|
39
|
-
hooks.onError?.(query, e);
|
|
40
|
-
throw e;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function resetVQLClient() {
|
|
45
|
-
transport = defaultFetchTransport;
|
|
46
|
-
hooks = {};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export async function defaultFetchTransport(query: VQLQuery): Promise<any> {
|
|
50
|
-
const res = await fetch("/VQL", {
|
|
51
|
-
method: "POST",
|
|
52
|
-
headers: {
|
|
53
|
-
"Content-Type": "application/json"
|
|
54
|
-
},
|
|
55
|
-
body: JSON.stringify({ query })
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (!res.ok) throw new Error(`VQL request failed: ${res.status}`);
|
|
59
|
-
return await res.json();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Export global for CDN use
|
|
63
|
-
if (typeof window !== "undefined") {
|
|
64
|
-
(window as any).VQLClient = {
|
|
65
|
-
fetchVQL,
|
|
66
|
-
initVQLClient,
|
|
67
|
-
resetVQLClient,
|
|
68
|
-
defaultFetchTransport
|
|
69
|
-
};
|
|
70
|
-
}
|
package/suglite.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "ES2022",
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"paths": {},
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"inlineSourceMap": false,
|
|
11
|
-
"sourceMap": false,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"removeComments": true
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"./src"
|
|
17
|
-
],
|
|
18
|
-
"exclude": [
|
|
19
|
-
"node_modules"
|
|
20
|
-
],
|
|
21
|
-
"tsc-alias": {
|
|
22
|
-
"resolveFullPaths": true,
|
|
23
|
-
"verbose": false
|
|
24
|
-
}
|
|
25
|
-
}
|