@wxn0brp/vql 0.7.0 → 0.8.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 +14 -5
- package/dist/cpu/utils.d.ts +1 -1
- package/dist/{config.d.ts → helpers/config.d.ts} +2 -0
- package/dist/{config.js → helpers/config.js} +1 -0
- package/dist/{falconFrame.d.ts → helpers/falconFrame.d.ts} +1 -1
- package/dist/{falconFrame.js → helpers/falconFrame.js} +1 -1
- package/dist/{gw.d.ts → helpers/gw.d.ts} +1 -1
- package/dist/{merge.js → helpers/merge.js} +2 -2
- package/dist/{sheet.d.ts → helpers/sheet.d.ts} +1 -1
- package/dist/{valid.d.ts → helpers/valid.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/permissions/relation.d.ts +1 -1
- package/dist/permissions/relation.js +2 -0
- package/dist/permissions/request.d.ts +1 -1
- package/dist/permissions/request.js +2 -1
- package/dist/permissions/utils.d.ts +1 -1
- package/dist/processor.d.ts +1 -1
- package/dist/processor.js +3 -3
- package/dist/vql.d.ts +1 -1
- package/package.json +23 -10
- /package/dist/{apiAbstract.d.ts → helpers/apiAbstract.d.ts} +0 -0
- /package/dist/{apiAbstract.js → helpers/apiAbstract.js} +0 -0
- /package/dist/{gw.js → helpers/gw.js} +0 -0
- /package/dist/{merge.d.ts → helpers/merge.d.ts} +0 -0
- /package/dist/{sheet.js → helpers/sheet.js} +0 -0
- /package/dist/{valid.js → helpers/valid.js} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# VQL (Valthera Query Language)
|
|
2
2
|
|
|
3
|
-
VQL
|
|
3
|
+
VQL (Valthera Query Language) is a comprehensive framework for interacting with ValtheraDB. It combines a flexible query language, a powerful permission management system, and a suite of tools to build secure and efficient data-driven applications.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@wxn0brp/vql)
|
|
6
6
|
[](./LICENSE)
|
|
@@ -8,11 +8,16 @@ VQL is a query language and processing framework designed for managing and inter
|
|
|
8
8
|

|
|
9
9
|

|
|
10
10
|
|
|
11
|
-
## Features
|
|
11
|
+
## Key Features
|
|
12
12
|
|
|
13
|
-
- **Query
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
13
|
+
- **Dual Query Syntax**: Choose between VQLR (a JSON-based object query language for programmatic use) and VQLS (a human-readable string-based language for simpler queries and scripts).
|
|
14
|
+
- **Multi-Database Support**: Process queries across multiple ValtheraDB instances seamlessly.
|
|
15
|
+
- **Cross-Platform**: Run VQL in both Node.js and modern web browsers.
|
|
16
|
+
- **Extensible by Design**: Customize and extend functionality with sheets and custom configurations.
|
|
17
|
+
- **Advanced Relation Queries**: Natively handle complex relationships not just between collections, but also across entire databases.
|
|
18
|
+
- **Permission System**: Built-in, granular access control powered by Gate Warden. It's disabled by default and can be enabled when needed to enforce complex security rules.
|
|
19
|
+
- **Falcon Frame Integration**: Integrates with Falcon Frame for extended capabilities.
|
|
20
|
+
- **Variable Support**: Use predefined or custom variables in your queries, allowing for more dynamic and reusable logic.
|
|
16
21
|
|
|
17
22
|
## Example Usage
|
|
18
23
|
|
|
@@ -62,6 +67,10 @@ f.age = 1
|
|
|
62
67
|
})();
|
|
63
68
|
```
|
|
64
69
|
|
|
70
|
+
## Development Tools
|
|
71
|
+
|
|
72
|
+
For an enhanced development and debugging experience, you can use [VQL-dev](https://github.com/wxn0brP/VQL-dev), a dedicated tool for debugging VQL queries.
|
|
73
|
+
|
|
65
74
|
## Documentation
|
|
66
75
|
|
|
67
76
|
- [Base/Map](./docs/lang/base.md)
|
package/dist/cpu/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { VQLConfig } from "../config.js";
|
|
1
|
+
import { VQLConfig } from "../helpers/config.js";
|
|
2
2
|
export declare function parseSelect(config: VQLConfig, select: object | object[]): any[];
|
|
@@ -3,11 +3,13 @@ export interface VQLConfigInterface {
|
|
|
3
3
|
strictSelect: boolean;
|
|
4
4
|
strictACL: boolean;
|
|
5
5
|
noCheckPermissions: boolean;
|
|
6
|
+
permissionDeniedIfNoUser: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare class VQLConfig implements VQLConfigInterface {
|
|
8
9
|
hidePath: boolean;
|
|
9
10
|
strictSelect: boolean;
|
|
10
11
|
strictACL: boolean;
|
|
11
12
|
noCheckPermissions: boolean;
|
|
13
|
+
permissionDeniedIfNoUser: boolean;
|
|
12
14
|
constructor(config?: Partial<VQLConfigInterface>);
|
|
13
15
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export function deepMerge(target, source) {
|
|
2
|
-
if (typeof target !==
|
|
2
|
+
if (typeof target !== "object" || target === null) {
|
|
3
3
|
target = {};
|
|
4
4
|
}
|
|
5
5
|
for (const key in source) {
|
|
6
6
|
if (source.hasOwnProperty(key)) {
|
|
7
|
-
if (typeof source[key] ===
|
|
7
|
+
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
8
8
|
if (!target[key]) {
|
|
9
9
|
target[key] = {};
|
|
10
10
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { VQL_Query } from "
|
|
1
|
+
import { VQL_Query } from "../types/vql.js";
|
|
2
2
|
export declare function replaceVars(query: VQL_Query, user: any): VQL_Query;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { VQLProcessor } from "./processor.js";
|
|
2
|
-
import { VQLConfig } from "./config.js";
|
|
3
|
-
import { createValtheraAdapter } from "./apiAbstract.js";
|
|
2
|
+
import { VQLConfig } from "./helpers/config.js";
|
|
3
|
+
import { createValtheraAdapter } from "./helpers/apiAbstract.js";
|
|
4
4
|
import logger from "./logger.js";
|
|
5
5
|
import { LogLevel } from "@wxn0brp/lucerna-log";
|
|
6
|
-
import { FF_VQL } from "./falconFrame.js";
|
|
7
|
-
import { createGwValidFn } from "./gw.js";
|
|
6
|
+
import { FF_VQL } from "./helpers/falconFrame.js";
|
|
7
|
+
import { createGwValidFn } from "./helpers/gw.js";
|
|
8
8
|
export default VQLProcessor;
|
|
9
9
|
export { VQLProcessor, createValtheraAdapter, VQLConfig, logger as VQLLogger, LogLevel as VQLLogLevel, FF_VQL, createGwValidFn };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { VQLProcessor } from "./processor.js";
|
|
2
|
-
import { VQLConfig } from "./config.js";
|
|
3
|
-
import { createValtheraAdapter } from "./apiAbstract.js";
|
|
2
|
+
import { VQLConfig } from "./helpers/config.js";
|
|
3
|
+
import { createValtheraAdapter } from "./helpers/apiAbstract.js";
|
|
4
4
|
import logger from "./logger.js";
|
|
5
5
|
import { LogLevel } from "@wxn0brp/lucerna-log";
|
|
6
|
-
import { FF_VQL } from "./falconFrame.js";
|
|
7
|
-
import { createGwValidFn } from "./gw.js";
|
|
6
|
+
import { FF_VQL } from "./helpers/falconFrame.js";
|
|
7
|
+
import { createGwValidFn } from "./helpers/gw.js";
|
|
8
8
|
export default VQLProcessor;
|
|
9
9
|
export { VQLProcessor, createValtheraAdapter, VQLConfig, logger as VQLLogger, LogLevel as VQLLogLevel, FF_VQL, createGwValidFn };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PermValidFn } from "../types/perm.js";
|
|
2
2
|
import { VQL_Query_Relation } from "../types/vql.js";
|
|
3
|
-
import { VQLConfig } from "../config.js";
|
|
3
|
+
import { VQLConfig } from "../helpers/config.js";
|
|
4
4
|
export declare function checkRelationPermission(config: VQLConfig, permValidFn: PermValidFn, user: any, query: VQL_Query_Relation): Promise<boolean>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PermCRUD } from "../types/perm.js";
|
|
2
2
|
import { extractPathsFromData, hashKey } from "./utils.js";
|
|
3
3
|
export async function checkRelationPermission(config, permValidFn, user, query) {
|
|
4
|
+
if (!user && config.permissionDeniedIfNoUser)
|
|
5
|
+
return false;
|
|
4
6
|
const { path, search, relations, select } = query.r;
|
|
5
7
|
// Helper function to recursively check permissions with fallback mechanism
|
|
6
8
|
const checkPermissionRecursively = async (entityId, originalPath, fallbackLevels = []) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VQLConfig } from "../config.js";
|
|
1
|
+
import { VQLConfig } from "../helpers/config.js";
|
|
2
2
|
import { PermCRUD, PermValidFn } from "../types/perm.js";
|
|
3
3
|
import { VQL_Query_CRUD } from "../types/vql.js";
|
|
4
4
|
export declare function extractPaths(config: VQLConfig, query: VQL_Query_CRUD): Promise<{
|
|
@@ -83,11 +83,12 @@ export function processFieldPath(pathObj) {
|
|
|
83
83
|
export async function checkRequestPermission(config, permValidFn, user, query) {
|
|
84
84
|
if (!query)
|
|
85
85
|
return false;
|
|
86
|
+
if (!user && config.permissionDeniedIfNoUser)
|
|
87
|
+
return false;
|
|
86
88
|
const permPaths = await extractPaths(config, query);
|
|
87
89
|
// Helper function to recursively check permissions
|
|
88
90
|
const checkPermissionRecursively = async (entityId, originalPath, requiredPerm, fallbackLevels = []) => {
|
|
89
91
|
// Check if the user has access to the current entity
|
|
90
|
-
// const result = await gw.hasAccess(user.id, entityId, requiredPerm);
|
|
91
92
|
const result = await permValidFn({
|
|
92
93
|
field: entityId,
|
|
93
94
|
path: originalPath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VQLConfig } from "../config.js";
|
|
1
|
+
import { VQLConfig } from "../helpers/config.js";
|
|
2
2
|
export declare function getHash(json: string): Promise<string>;
|
|
3
3
|
export declare function hashKey(config: VQLConfig, path: any): Promise<string>;
|
|
4
4
|
export declare function extractPathsFromData(data: any, stack?: string[]): {
|
package/dist/processor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Relation, ValtheraCompatible } from "@wxn0brp/db-core";
|
|
2
|
-
import { VQLConfig, VQLConfigInterface } from "./config.js";
|
|
2
|
+
import { VQLConfig, VQLConfigInterface } from "./helpers/config.js";
|
|
3
3
|
import { VQL_Query, VQLError, VQLUQ } from "./types/vql.js";
|
|
4
4
|
import { PermValidFn } from "./types/perm.js";
|
|
5
5
|
export declare class VQLProcessor {
|
package/dist/processor.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Relation } from "@wxn0brp/db-core";
|
|
2
|
-
import { VQLConfig } from "./config.js";
|
|
2
|
+
import { VQLConfig } from "./helpers/config.js";
|
|
3
3
|
import { executeRelation } from "./cpu/relation.js";
|
|
4
4
|
import { executeQuery } from "./cpu/request.js";
|
|
5
5
|
import logger from "./logger.js";
|
|
6
|
-
import { replaceVars } from "./sheet.js";
|
|
7
|
-
import { validateRaw, validateVql } from "./valid.js";
|
|
6
|
+
import { replaceVars } from "./helpers/sheet.js";
|
|
7
|
+
import { validateRaw, validateVql } from "./helpers/valid.js";
|
|
8
8
|
import { parseVQLS } from "./cpu/string/index.js";
|
|
9
9
|
export class VQLProcessor {
|
|
10
10
|
dbInstances;
|
package/dist/vql.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export type ArrayOperators<T = any> = {
|
|
|
55
55
|
};
|
|
56
56
|
/** String Operators */
|
|
57
57
|
export type StringOperators<T = any> = {
|
|
58
|
-
$regex?: PartialOfType<T, RegExp, string>;
|
|
58
|
+
$regex?: PartialOfType<T, RegExp | string, string>;
|
|
59
59
|
$startsWith?: PartialOfType<T, string>;
|
|
60
60
|
$endsWith?: PartialOfType<T, string>;
|
|
61
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/vql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"author": "wxn0brP",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,10 +14,22 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"vql",
|
|
19
|
+
"valthera",
|
|
20
|
+
"database",
|
|
21
|
+
"orm",
|
|
22
|
+
"api",
|
|
23
|
+
"crud",
|
|
24
|
+
"nosql",
|
|
25
|
+
"query",
|
|
26
|
+
"db",
|
|
27
|
+
"query-language"
|
|
28
|
+
],
|
|
17
29
|
"peerDependencies": {
|
|
18
|
-
"@wxn0brp/db-core": ">=0.2.
|
|
19
|
-
"@wxn0brp/falcon-frame": ">=0.1
|
|
20
|
-
"@wxn0brp/gate-warden": ">=0.4.
|
|
30
|
+
"@wxn0brp/db-core": ">=0.2.5",
|
|
31
|
+
"@wxn0brp/falcon-frame": ">=0.5.1",
|
|
32
|
+
"@wxn0brp/gate-warden": ">=0.4.1"
|
|
21
33
|
},
|
|
22
34
|
"peerDependenciesMeta": {
|
|
23
35
|
"@wxn0brp/falcon-frame": {
|
|
@@ -32,15 +44,16 @@
|
|
|
32
44
|
},
|
|
33
45
|
"devDependencies": {
|
|
34
46
|
"@types/node": "*",
|
|
35
|
-
"@wxn0brp/db": "^0.40.
|
|
36
|
-
"@wxn0brp/
|
|
37
|
-
"@wxn0brp/
|
|
38
|
-
"
|
|
47
|
+
"@wxn0brp/db": "^0.40.1",
|
|
48
|
+
"@wxn0brp/db-core": "^0.2.5",
|
|
49
|
+
"@wxn0brp/falcon-frame": "^0.5.1",
|
|
50
|
+
"@wxn0brp/gate-warden": "^0.4.1",
|
|
51
|
+
"esbuild": "^0.25.11",
|
|
39
52
|
"tsc-alias": "*",
|
|
40
53
|
"typescript": "*"
|
|
41
54
|
},
|
|
42
55
|
"dependencies": {
|
|
43
|
-
"@wxn0brp/lucerna-log": "^0.2.
|
|
56
|
+
"@wxn0brp/lucerna-log": "^0.2.1"
|
|
44
57
|
},
|
|
45
58
|
"exports": {
|
|
46
59
|
".": {
|
|
@@ -54,4 +67,4 @@
|
|
|
54
67
|
"default": "./dist/*.js"
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
|
-
}
|
|
70
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|