Skip to content

Commit 39ea892

Browse files
feat: Enable chrono feature so we can add duration to timestamp
1 parent ec5c850 commit 39ea892

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

libs/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ crate-type = ["cdylib"]
99
[dependencies]
1010
napi = { version = "2.12.2", features = ["serde-json"] }
1111
napi-derive = "2.12.2"
12-
cel-interpreter = { path = "cel-rust/interpreter" }
12+
cel-interpreter = { path = "cel-rust/interpreter", features = ["chrono"] }
1313
serde = { version = "1.0", features = ["derive"] }
1414
serde_json = "1.0"
1515

libs/core/__tests__/cel.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import { beforeEach, describe, expect, it } from "vitest";
22
import { CelProgram, evaluate } from "../src/index.js";
33

44
describe("evaluate", () => {
5+
it("should add a duration to a timestamp using chrono feature", async () => {
6+
const result = await evaluate(
7+
"timestamp('2023-01-01T00:00:00Z') + duration('1h')",
8+
{},
9+
);
10+
// The expected result is '2023-01-01T01:00:00Z' as an ISO string
11+
expect(result).toBe("2023-01-01T01:00:00Z");
12+
});
513
it("should evaluate a simple expression", async () => {
614
const result = await evaluate("size(message) > 5", {
715
message: "Hello World",

libs/core/project.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@kevinmichaelchen/cel-typescript-core",
33
"$schema": "node_modules/nx/schemas/project-schema.json",
44
"targets": {
5+
"build": {
6+
"executor": "nx:noop",
7+
"dependsOn": ["build:native", "build:ts"]
8+
},
59
"build:native": {
610
"cache": false,
711
"executor": "nx:run-commands",
@@ -26,10 +30,6 @@
2630
},
2731
"outputs": ["{projectRoot}/dist/**/*"]
2832
},
29-
"build": {
30-
"executor": "nx:noop",
31-
"dependsOn": ["build:native", "build:ts"]
32-
},
3333
"clean": {
3434
"cache": false,
3535
"executor": "nx:run-commands",

0 commit comments

Comments
 (0)