@gsl-lang/gql 0.0.0-stage → 0.6.0

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
@@ -1,3 +1,43 @@
1
- # Temporary Holding Version
1
+ <!--
2
+ SPDX-License-Identifier: CC-BY-4.0
3
+ Copyright (c) 2026 Pascal Dennerly.
4
+ -->
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ # @gsl-lang/gql
7
+
8
+ TypeScript implementation of the GSL Query Language, as specified in
9
+ [`spec/gql/QUERY_SPEC.md`](../../../spec/gql/QUERY_SPEC.md). Depends on
10
+ [`@gsl-lang/core`](../core/README.md).
11
+
12
+ - **Status:** functional. Parser and query engine are implemented and validated
13
+ against every shared conformance fixture. Not published.
14
+ - **Licence:** Apache-2.0.
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import { parse } from "@gsl-lang/core";
20
+ import { runQuery } from "@gsl-lang/gql";
21
+
22
+ const { graph } = parse('node api [team="payments"]\\nnode db\\napi -> db');
23
+ const result = runQuery(graph, 'subgraph node.team == "payments"');
24
+ ```
25
+
26
+ ## What is here
27
+
28
+ ```
29
+ packages/gql/
30
+ src/lexer.ts # tokenizer
31
+ src/parser.ts # hand-written recursive-descent parser
32
+ src/predicates.ts # predicate evaluation (attribute, set, parent, depth)
33
+ src/expressions.ts # subgraph, traversal, make, remove, collapse, algebra
34
+ src/graph.ts # mutable working graph used during query execution
35
+ test/conformance.test.ts # runs the shared fixtures
36
+ ```
37
+
38
+ ## Conformance
39
+
40
+ The package executes each fixture directory under
41
+ [`tests/conformance/gql`](../../../tests/conformance/README.md) — `graph.gsl`
42
+ plus `query.gql` — and compares the canonical serialization of the result with
43
+ `result.gsl`, matching the Go reference implementation exactly.
@@ -0,0 +1,88 @@
1
+ import type { AttributeValue, GslGraph } from "@gsl-lang/core";
2
+ import { Predicate } from "./predicates.js";
3
+ export interface Value {
4
+ graph: GslGraph;
5
+ }
6
+ export interface QueryContext {
7
+ inputGraph: GslGraph;
8
+ namedGraphs: Map<string, GslGraph>;
9
+ }
10
+ export interface Expression {
11
+ apply(ctx: QueryContext, input: Value): Value;
12
+ }
13
+ export declare function validateTargetType(pred: Predicate): string;
14
+ export declare class Query {
15
+ readonly expressions: Expression[];
16
+ constructor(expressions: Expression[]);
17
+ execute(ctx: QueryContext): Value;
18
+ }
19
+ export declare class IdentityExpr implements Expression {
20
+ apply(_ctx: QueryContext, input: Value): Value;
21
+ }
22
+ export declare class FromExpr implements Expression {
23
+ private readonly isWildcard;
24
+ private readonly name;
25
+ constructor(isWildcard: boolean, name: string);
26
+ apply(ctx: QueryContext): Value;
27
+ }
28
+ export declare class BindExpr implements Expression {
29
+ private readonly pipeline;
30
+ private readonly name;
31
+ constructor(pipeline: Query, name: string);
32
+ apply(ctx: QueryContext, input: Value): Value;
33
+ }
34
+ export interface TraversalConfig {
35
+ directions: string[];
36
+ depth: number;
37
+ }
38
+ export declare class SubgraphExpr implements Expression {
39
+ private readonly pred;
40
+ private readonly traversal;
41
+ constructor(pred: Predicate, traversal: TraversalConfig | null);
42
+ apply(_ctx: QueryContext, input: Value): Value;
43
+ private buildSubgraph;
44
+ private injectEdges;
45
+ private traverse;
46
+ }
47
+ export declare class RemoveEdgeExpr implements Expression {
48
+ private readonly pred;
49
+ constructor(pred: Predicate);
50
+ apply(_ctx: QueryContext, input: Value): Value;
51
+ }
52
+ export declare class RemoveAttributeExpr implements Expression {
53
+ private readonly target;
54
+ private readonly attr;
55
+ private readonly pred;
56
+ constructor(target: string, attr: string, pred: Predicate);
57
+ apply(_ctx: QueryContext, input: Value): Value;
58
+ }
59
+ export declare class RemoveOrphansExpr implements Expression {
60
+ apply(_ctx: QueryContext, input: Value): Value;
61
+ }
62
+ export declare class CollapseExpr implements Expression {
63
+ private readonly nodeId;
64
+ private readonly pred;
65
+ constructor(nodeId: string, pred: Predicate);
66
+ apply(_ctx: QueryContext, input: Value): Value;
67
+ }
68
+ export declare class MakeExpr implements Expression {
69
+ private readonly target;
70
+ private readonly attr;
71
+ private readonly value;
72
+ private readonly pred;
73
+ constructor(target: string, attr: string, value: AttributeValue, pred: Predicate);
74
+ apply(_ctx: QueryContext, input: Value): Value;
75
+ }
76
+ export declare class GraphAlgebraExpr implements Expression {
77
+ private readonly leftRef;
78
+ private readonly operator;
79
+ private readonly rightRef;
80
+ constructor(leftRef: string, operator: string, rightRef: string);
81
+ apply(ctx: QueryContext): Value;
82
+ private resolveGraph;
83
+ private union;
84
+ private intersection;
85
+ private difference;
86
+ private symmetricDifference;
87
+ }
88
+ //# sourceMappingURL=expressions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../../src/expressions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAML,SAAS,EAEV,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,QAAQ,CAAC;IACrB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;CAC/C;AAuBD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAI1D;AAED,qBAAa,KAAK;IACJ,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE;gBAAzB,WAAW,EAAE,UAAU,EAAE;IAE9C,OAAO,CAAC,GAAG,EAAE,YAAY,GAAG,KAAK;CAOlC;AAED,qBAAa,YAAa,YAAW,UAAU;IAC7C,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,GAAG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