Skip to content

Commit e22f439

Browse files
committed
feat(cli): Pull function variable key,value only
1 parent 98bfee6 commit e22f439

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

templates/cli/lib/config.js.twig

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const _path = require("path");
44
const process = require("process");
55
const JSONbig = require("json-bigint")({ storeAsString: false });
66

7+
const KeysVars = new Set(["key", "value"]);
78
const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
89
const KeysDatabase = new Set(["$id", "name", "enabled"]);
910
const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]);
@@ -38,10 +39,10 @@ const KeysAttributes = new Set([
3839
const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
3940

4041
function whitelistKeys(value, keys, nestedKeys = {}) {
41-
if(Array.isArray(value)) {
42+
if (Array.isArray(value)) {
4243
const newValue = [];
4344

44-
for(const item of value) {
45+
for (const item of value) {
4546
newValue.push(whitelistKeys(item, keys, nestedKeys));
4647
}
4748

@@ -50,8 +51,8 @@ function whitelistKeys(value, keys, nestedKeys = {}) {
5051

5152
const newValue = {};
5253
Object.keys(value).forEach((key) => {
53-
if(keys.has(key)) {
54-
if(nestedKeys[key]) {
54+
if (keys.has(key)) {
55+
if (nestedKeys[key]) {
5556
newValue[key] = whitelistKeys(value[key], nestedKeys[key]);
5657
} else {
5758
newValue[key] = value[key];
@@ -151,7 +152,9 @@ class Local extends Config {
151152
}
152153

153154
addFunction(props) {
154-
props = whitelistKeys(props, KeysFunction);
155+
props = whitelistKeys(props, KeysFunction, {
156+
vars: KeysVars
157+
});
155158

156159
if (!this.has("functions")) {
157160
this.set("functions", []);

0 commit comments

Comments
 (0)