Skip to content

Commit

Permalink
change to first parsing cellValueType. Change fallbacks accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
xai-msft committed Aug 28, 2024
1 parent 1fa9919 commit 5e147cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
16 changes: 15 additions & 1 deletion packages/custom-functions-metadata/src/parseTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ const CELLVALUETYPE_MAPPINGS = {
"Excel.ValueTypeNotAvailableCellValue": "unsupported",
};

const CELLVALUETYPE_TO_BASICTYPE_MAPPINGS = {
"cellvalue": "any",
"booleancellvalue": "boolean",
"doublecellvalue": "number",
"entitycellvalue": "any",
"errorcellvalue": "any",
"formattednumbercellvalue": "any",
"linkedentitycellvalue": "any",
"localimagecellvalue": "any",
"stringcellvalue": "string",
"webimagecellvalue": "any",
};

type CustomFunctionsSchemaDimensionality = "invalid" | "scalar" | "matrix";

/**
Expand Down Expand Up @@ -700,7 +713,8 @@ function getParameters(parameterItem: IGetParametersArguments): IFunctionParamet

// for backward compatibility, we put cell value type in cellValueType instead of type.
if (Object.values(CELLVALUETYPE_MAPPINGS).includes(ptype)) {
pMetadataItem.type = "any";
// @ts-ignore
pMetadataItem.type = CELLVALUETYPE_TO_BASICTYPE_MAPPINGS[ptype];
pMetadataItem.cellValueType = ptype
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"parameters": [
{
"name": "x",
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand All @@ -34,7 +34,7 @@
"parameters": [
{
"name": "x",
"type": "any",
"type": "number",
"cellValueType": "doublecellvalue"
}
],
Expand Down Expand Up @@ -112,7 +112,7 @@
"parameters": [
{
"name": "x",
"type": "any",
"type": "string",
"cellValueType": "stringcellvalue"
}
],
Expand All @@ -139,7 +139,7 @@
{
"name": "x",
"repeating": true,
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand All @@ -153,7 +153,7 @@
{
"dimensionality": "matrix",
"name": "x",
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand All @@ -168,7 +168,7 @@
"dimensionality": "matrix",
"name": "x",
"repeating": true,
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand All @@ -182,7 +182,7 @@
{
"name": "x",
"repeating": true,
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand All @@ -196,7 +196,7 @@
{
"dimensionality": "matrix",
"name": "x",
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand All @@ -211,7 +211,7 @@
"dimensionality": "matrix",
"name": "x",
"repeating": true,
"type": "any",
"type": "boolean",
"cellValueType": "booleancellvalue"
}
],
Expand Down

0 comments on commit 5e147cf

Please sign in to comment.