Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit eb03f58

Browse files
authored
Merge pull request #1 from hudlow/spec-v0.18
update spec to v0.18
2 parents f6cb866 + 3dc64e7 commit eb03f58

11 files changed

Lines changed: 2418 additions & 1054 deletions

File tree

builder.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
Expr,
44
Expr_CreateStruct_Entry,
55
SourceInfo,
6-
} from "./external/proto/dev/cel/expr/syntax_pb.ts";
6+
} from "./external/cel/expr/syntax_pb.ts";
77

88
const encoder = new TextEncoder();
99

@@ -128,19 +128,20 @@ class Builder {
128128
#prevId = 0n;
129129

130130
sourceInfo: SourceInfo = {
131-
$typeName: "dev.cel.expr.SourceInfo",
131+
$typeName: "cel.expr.SourceInfo",
132132
syntaxVersion: "",
133133
location: "",
134134
lineOffsets: [],
135135
positions: {},
136136
macroCalls: {},
137+
extensions: [],
137138
};
138139

139140
nextExpr(offset: number, exprKind: Expr["exprKind"]): Expr {
140141
this.sourceInfo.positions[(++this.#prevId).toString()] = offset;
141142

142143
return {
143-
$typeName: "dev.cel.expr.Expr",
144+
$typeName: "cel.expr.Expr",
144145
id: this.#prevId,
145146
exprKind,
146147
};
@@ -154,7 +155,7 @@ class Builder {
154155
this.sourceInfo.positions[(++this.#prevId).toString()] = offset;
155156

156157
return {
157-
$typeName: "dev.cel.expr.Expr.CreateStruct.Entry",
158+
$typeName: "cel.expr.Expr.CreateStruct.Entry",
158159
id: this.#prevId,
159160
keyKind,
160161
value,
@@ -165,7 +166,7 @@ class Builder {
165166
newConstExpr(offset: number, constantKind: Constant["constantKind"]): Expr {
166167
return this.nextExpr(offset, {
167168
case: "constExpr",
168-
value: { $typeName: "dev.cel.expr.Constant", constantKind },
169+
value: { $typeName: "cel.expr.Constant", constantKind },
169170
});
170171
}
171172

@@ -180,7 +181,7 @@ class Builder {
180181
return this.nextExpr(offset, {
181182
case: "callExpr",
182183
value: {
183-
$typeName: "dev.cel.expr.Expr.Call",
184+
$typeName: "cel.expr.Expr.Call",
184185
function: functionName,
185186
args,
186187
},
@@ -199,7 +200,7 @@ class Builder {
199200
this.nextExpr(offset, {
200201
case: "callExpr",
201202
value: {
202-
$typeName: "dev.cel.expr.Expr.Call",
203+
$typeName: "cel.expr.Expr.Call",
203204
function: functionName,
204205
target,
205206
args,
@@ -280,7 +281,7 @@ class Builder {
280281
newIdentExpr(offset: number, name: string): Expr {
281282
const expr = this.nextExpr(offset, {
282283
case: "identExpr",
283-
value: { $typeName: "dev.cel.expr.Expr.Ident", name },
284+
value: { $typeName: "cel.expr.Expr.Ident", name },
284285
});
285286
return expr;
286287
}
@@ -293,7 +294,7 @@ class Builder {
293294
return this.nextExpr(offset, {
294295
case: "selectExpr",
295296
value: {
296-
$typeName: "dev.cel.expr.Expr.Select",
297+
$typeName: "cel.expr.Expr.Select",
297298
operand,
298299
field,
299300
testOnly: false,
@@ -318,7 +319,7 @@ class Builder {
318319
return this.nextExpr(offset, {
319320
case: "listExpr",
320321
value: {
321-
$typeName: "dev.cel.expr.Expr.CreateList",
322+
$typeName: "cel.expr.Expr.CreateList",
322323
elements,
323324
optionalIndices: [],
324325
},
@@ -336,13 +337,14 @@ class Builder {
336337
return this.nextExpr(offset, {
337338
case: "comprehensionExpr",
338339
value: {
339-
$typeName: "dev.cel.expr.Expr.Comprehension",
340+
$typeName: "cel.expr.Expr.Comprehension",
340341
accuVar: "__result__",
341342
accuInit: this.newConstExpr(offset, {
342343
case: "boolValue",
343344
value: init,
344345
}),
345346
iterVar,
347+
iterVar2: "", // not yet supported
346348
iterRange,
347349
loopStep,
348350
loopCondition,
@@ -360,10 +362,11 @@ class Builder {
360362
return this.nextExpr(offset, {
361363
case: "comprehensionExpr",
362364
value: {
363-
$typeName: "dev.cel.expr.Expr.Comprehension",
365+
$typeName: "cel.expr.Expr.Comprehension",
364366
accuVar: "__result__",
365367
accuInit: this.newListExpr(offset, []),
366368
iterVar,
369+
iterVar2: "", // not yet supported
367370
iterRange,
368371
loopCondition: this.newConstExpr(offset, {
369372
case: "boolValue",
@@ -468,13 +471,14 @@ class Builder {
468471
return this.nextExpr(offset, {
469472
case: "comprehensionExpr",
470473
value: {
471-
$typeName: "dev.cel.expr.Expr.Comprehension",
474+
$typeName: "cel.expr.Expr.Comprehension",
472475
accuVar: "__result__",
473476
accuInit: this.newConstExpr(offset, {
474477
case: "int64Value",
475478
value: BigInt(0),
476479
}),
477480
iterVar,
481+
iterVar2: "", // not yet supported
478482
iterRange,
479483
loopCondition: this.newConstExpr(offset, {
480484
case: "boolValue",
@@ -506,6 +510,7 @@ class Builder {
506510
if (call.exprKind.case === "callExpr") {
507511
const callExpr = call.exprKind.value;
508512
const varName = callExpr.args[0];
513+
const varIndex = callExpr.args.length > 1 ? callExpr.args[1] : "";
509514
if (
510515
varName !== undefined &&
511516
call.exprKind.value.target !== undefined &&
@@ -582,7 +587,7 @@ class Builder {
582587
return this.nextExpr(offset, {
583588
case: "structExpr",
584589
value: {
585-
$typeName: "dev.cel.expr.Expr.CreateStruct",
590+
$typeName: "cel.expr.Expr.CreateStruct",
586591
entries,
587592
messageName,
588593
},

cel.peggy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
{{
16-
import type { Expr, Expr_CreateStruct_Entry } from "./external/proto/dev/cel/expr/syntax_pb.ts";
16+
import type { Expr, Expr_CreateStruct_Entry } from "./external/cel/expr/syntax_pb.ts";
1717
import { LazyBuilder } from "./builder.ts";
1818
import type { Eventual } from "./builder.ts";
1919
const builder = new LazyBuilder();

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"clean": "rm -rf index.ts index.ast utility/extract-parser-tests/bin dist/ external/ node_modules/ &> /dev/null",
3535
"generate-control-parser": "peggy cel.peggy --format es -o ./index.ts",
3636
"generate-parser": "peggy cel.peggy --format bare --extra-options '{\"typescript\":true}' --plugin peggy-ts -o ./index.ts && prettier index.ts --write",
37-
"generate-proto": "buf generate --include-imports buf.build/cel/spec",
37+
"generate-proto": "buf generate --include-imports buf.build/google/cel-spec:v0.18.0",
3838
"generate-parser-ast": "peggy cel.peggy --ast --plugin peggy-ts -o ./index.ast",
3939
"bundle-init": "rm -rf dist/ &> /dev/null && mkdir dist",
4040
"bundle-cjs": "esbuild index.ts --bundle --format=cjs --outfile=dist/index.cjs && prettier dist/index.cjs --write",
@@ -71,7 +71,7 @@
7171
}
7272
},
7373
"utility": {
74-
"celSpec": "https://github.com/google/cel-spec/archive/7bcc79c7cb9a101a66dbbe9c88838855dc4b821d.tar.gz",
75-
"celGo": "https://github.com/google/cel-go/archive/3545aac7e6d484d3035b1833c4ade036c3f7bacb.tar.gz"
74+
"celSpec": "https://github.com/google/cel-spec/archive/373994d7e20e582fce56767b01ac5039524cddab.tar.gz",
75+
"celGo": "https://github.com/google/cel-go/archive/8ad600b649be1b9ef5a003e8c5632d89b9aaf790.tar.gz"
7676
}
7777
}

test/conformance.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import * as fs from "fs";
22

33
import { parse } from "../index.ts";
44
import { fromJson } from "@bufbuild/protobuf";
5-
import { ExprSchema } from "../external/proto/dev/cel/expr/syntax_pb.ts";
6-
import type {
7-
Expr,
8-
Expr_Call,
9-
} from "../external/proto/dev/cel/expr/syntax_pb.ts";
5+
import { ExprSchema } from "../external/cel/expr/syntax_pb.ts";
6+
import type { Expr, Expr_Call } from "../external/cel/expr/syntax_pb.ts";
107

118
const files = JSON.parse(
129
fs.readFileSync(`${__dirname}/data/conformance.json`, "utf8"),

0 commit comments

Comments
 (0)