diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json index 83e24ec1..e895a74f 100644 --- a/bindings/nodejs/package.json +++ b/bindings/nodejs/package.json @@ -71,7 +71,7 @@ "url": "git+https://github.com/gorules/zen.git" }, "scripts": { - "build": "napi build --dts false --platform --release", + "build": "napi build --dts temp.d.ts --platform --release && rm temp.d.ts", "build:debug": "napi build --platform --js index.js --dts index.d.ts", "watch": "cargo watch --ignore '{index.js,index.d.ts}' -- npm run build:debug", "test": "jest", diff --git a/test-data/graphs/expression-default.json b/test-data/graphs/expression-default.json new file mode 100644 index 00000000..c5fb8940 --- /dev/null +++ b/test-data/graphs/expression-default.json @@ -0,0 +1,93 @@ +{ + "tests": [ + { + "input": { + "a": 1, + "b": 2, + "extra": "This should not pass through" + }, + "output": { + "sum": 3 + } + }, + { + "input": { + "a": 5, + "b": 3, + "sum": 100 + }, + "output": { + "sum": 8 + } + }, + { + "input": { + "a": 10, + "b": 20, + "c": 30, + "d": 40 + }, + "output": { + "sum": 30 + } + }, + { + "input": { + "a": 7, + "b": 3, + "passThrough": "This should not appear in output" + }, + "output": { + "sum": 10 + } + }, + { + "input": { + "a": -5, + "b": 5, + "negative": true + }, + "output": { + "sum": 0 + } + } + ], + "nodes": [ + { + "type": "inputNode", + "id": "deced339-bace-452a-8db0-777f038bffe8", + "name": "request", + "position": { + "x": 145, + "y": 235 + } + }, + { + "type": "expressionNode", + "content": { + "expressions": [ + { + "id": "d54641c2-5f24-4140-a9c4-8453542a622a", + "key": "sum", + "value": "a + b" + } + ], + "passThrough": false + }, + "id": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770", + "name": "expression1", + "position": { + "x": 475, + "y": 235 + } + } + ], + "edges": [ + { + "id": "639f3a3a-7545-4e98-aa79-7a9bd9644af1", + "sourceId": "deced339-bace-452a-8db0-777f038bffe8", + "type": "edge", + "targetId": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770" + } + ] +} \ No newline at end of file diff --git a/test-data/graphs/expression-fields.json b/test-data/graphs/expression-fields.json new file mode 100644 index 00000000..18df3783 --- /dev/null +++ b/test-data/graphs/expression-fields.json @@ -0,0 +1,94 @@ +{ + "tests": [ + { + "input": { + "customer": { + "firstName": "John", + "lastName": "Doe", + "age": 30 + }, + "order": { + "id": "ORD-001", + "total": 100 + } + }, + "output": { + "customer": { + "firstName": "John", + "lastName": "Doe", + "age": 30, + "fullName": "John Doe" + }, + "order": { + "id": "ORD-001", + "total": 100 + } + } + }, + { + "input": { + "customer": { + "firstName": "Jane", + "lastName": "Smith", + "age": 25 + }, + "order": { + "id": "ORD-002", + "total": 150 + } + }, + "output": { + "customer": { + "firstName": "Jane", + "lastName": "Smith", + "age": 25, + "fullName": "Jane Smith" + }, + "order": { + "id": "ORD-002", + "total": 150 + } + } + } + ], + "nodes": [ + { + "type": "inputNode", + "id": "input-node", + "name": "request", + "position": { + "x": 100, + "y": 100 + } + }, + { + "type": "expressionNode", + "id": "expression-node-1", + "name": "customerFullName", + "position": { + "x": 300, + "y": 100 + }, + "content": { + "inputField": "customer", + "outputPath": "customer", + "expressions": [ + { + "id": "07795ded-cb9b-4165-9b5e-783b066dda61", + "key": "fullName", + "value": "`${firstName} ${lastName}`" + } + ], + "passThrough": true + } + } + ], + "edges": [ + { + "id": "edge-1", + "sourceId": "input-node", + "targetId": "expression-node-1", + "type": "edge" + } + ] +} \ No newline at end of file diff --git a/test-data/graphs/expression-loop.json b/test-data/graphs/expression-loop.json new file mode 100644 index 00000000..29d48e2b --- /dev/null +++ b/test-data/graphs/expression-loop.json @@ -0,0 +1,94 @@ +{ + "tests": [ + { + "input": { + "cart": { + "items": [ + { + "name": "Apple", + "price": 0.5, + "quantity": 3 + }, + { + "name": "Banana", + "price": 0.3, + "quantity": 5 + }, + { + "name": "Orange", + "price": 0.7, + "quantity": 2 + } + ], + "customerId": "CUST-001" + } + }, + "output": { + "cart": { + "items": [ + { + "name": "Apple", + "price": 0.5, + "quantity": 3, + "totalPrice": 1.5 + }, + { + "name": "Banana", + "price": 0.3, + "quantity": 5, + "totalPrice": 1.5 + }, + { + "name": "Orange", + "price": 0.7, + "quantity": 2, + "totalPrice": 1.4 + } + ], + "customerId": "CUST-001" + } + } + } + ], + "nodes": [ + { + "type": "inputNode", + "id": "input-node", + "name": "request", + "position": { + "x": 100, + "y": 100 + } + }, + { + "type": "expressionNode", + "id": "expression-node-1", + "name": "calculateItemTotal", + "position": { + "x": 300, + "y": 100 + }, + "content": { + "inputField": "cart.items", + "outputPath": "cart.items", + "executionMode": "loop", + "expressions": [ + { + "id": "total-price-exp", + "key": "totalPrice", + "value": "price * quantity" + } + ], + "passThrough": true + } + } + ], + "edges": [ + { + "id": "edge-1", + "sourceId": "input-node", + "targetId": "expression-node-1", + "type": "edge" + } + ] +} \ No newline at end of file diff --git a/test-data/graphs/expression-passthrough.json b/test-data/graphs/expression-passthrough.json new file mode 100644 index 00000000..1b8bf907 --- /dev/null +++ b/test-data/graphs/expression-passthrough.json @@ -0,0 +1,108 @@ +{ + "tests": [ + { + "input": { + "a": 1, + "b": 2, + "sum": [] + }, + "output": { + "a": 1, + "b": 2, + "sum": 3 + } + }, + { + "input": { + "a": 5, + "b": 3, + "sum": 100 + }, + "output": { + "a": 5, + "b": 3, + "sum": 8 + } + }, + { + "input": { + "a": 10, + "b": 20, + "extra": "This should pass through" + }, + "output": { + "a": 10, + "b": 20, + "sum": 30, + "extra": "This should pass through" + } + }, + { + "input": { + "a": 7, + "b": 3, + "sum": "Original", + "passThrough": "Test" + }, + "output": { + "a": 7, + "b": 3, + "sum": 10, + "passThrough": "Test" + } + }, + { + "input": { + "a": 1, + "b": 1, + "c": 3, + "d": 4 + }, + "output": { + "a": 1, + "b": 1, + "c": 3, + "d": 4, + "sum": 2 + } + } + ], + "nodes": [ + { + "type": "inputNode", + "id": "deced339-bace-452a-8db0-777f038bffe8", + "name": "request", + "position": { + "x": 145, + "y": 235 + } + }, + { + "type": "expressionNode", + "content": { + "expressions": [ + { + "id": "d54641c2-5f24-4140-a9c4-8453542a622a", + "key": "sum", + "value": "a + b" + } + ], + "passThrough": true + }, + "id": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770", + "name": "expression1", + "position": { + "x": 475, + "y": 235 + } + } + ], + "edges": [ + { + "id": "639f3a3a-7545-4e98-aa79-7a9bd9644af1", + "sourceId": "deced339-bace-452a-8db0-777f038bffe8", + "type": "edge", + "targetId": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770" + } + ] +} \ No newline at end of file