Currently the tree that stores fields of a complex DType (records or arrays) stores those in an ordered way (ordinal comparison). There is some code that relies on that, so codifying it as a test to make it a "specification"
The Trace function doesn't return anything. For legacy reasons, it currently returns DType.Boolean (when it was created, we didn't have DType.Void). This PR updates it to return Void instead.
Adds ability to define User-defined functions in REPL.
Parsing UDFs requires a different parser from the Texl Expression parser
and this is addressed by using the DefinitionsParser as a fallback to
check when regular parsing fails. If definitions parsing is successful
and we find UDF, we add it to the Engine.
![image](https://github.com/user-attachments/assets/ee86d499-2ee6-4232-a7cd-3b5ca9e09d1e)
Fixes#2546
We found a NRE in Power Apps telemetry that was happening in the Intellisense code on Power Fx. We don't know exactly the cause, but this change adds a defense-in-depth that will help preventing that.
Address the schema and actual response misalignment issue especially for
Teams Connector.
**Context**:
In Teams connector, the suggestions API "GetMessageLocations" is
declared as below:
```ts
// dynamic schema
"x-ms-dynamic-values": {
"operationId": "GetMessageLocations",
"value-path": "id",
"value-title": "displayName",
"value-collection": "value",
"parameters": {
"messageType": "ParentMessage",
"poster": {
"parameter": "poster"
}
}
}
// response type
{
"type": "object",
"properties": {
"locations": {
"type": "array",
"items": {
"type": "object"
},
"description": "valid locations to post a message or reply, make verbose"
}
}
}
```
It's a historical issue (PAuto supports weak type and consumes this
format) that the actual response format ("value" and "displayName") is
misaligned with the expected format ("id" and "displayName"). Then it
caused the MCS suggestions API returning empty result.
**Proposed solution**:
Fallback to accept "value" and "displayName" when building the
suggestion response if the value accessed by "value-path" or
"value-title" is empty.
(This approached was proved to work in MCS but since some version update
there was a regression.)
In the Teams connector, the operation "PostCardAndWaitForResponse"
contains extension "x-ms-notification-content" and is excluded from the
parse result of `GetFunctions`.
In MCS, we want to make this operation available to our internal users
to keep parity with Power Automate behavior.
This PR fixes the issue by
1. Creating a new setting "IncludeWebhookFunctions" to conditionally
include those "webhook" functions on demand.
2. Consume that new setting when filtering on the webhook functions, it
set to true, it won't filter away those functions.
As a result, 4 more operations inside Teams connector will be supported
by merging this change.
On MCS side, PFX `GetFunctions` will be invoked with an additional
setting parameter `IncludeWebhookFunctions = true`.
Adds Namedtype suggestions for Type arguments in functions that accept
type (ParseJSON, IsType, AsType).
Suggestion handler for TypeLiteralNode is currently in PAclient and will
be moved to this repo in a follow up PR.
Marks UDF and Nf async if they refer to cross screen control and a new
binding config to do that is enabled. There's no definite way to say
where binder is binding nf or udf rules so config would be used to
communicate the marking of top parse node as async upon countering those
references. We don't need to mark those async if all they refer to is
component definition but there's no definite way to also check that.
ExternalTemplate.IsComponent returns true for component defs and
instances but we need to check only for the former. However that
shouldn't matter as code gen to lazy load component defs would be no op
since component defs are loaded upfront.
In scenario of `F():Void = { F(); }`, when finalizing the binding, the
Binder will attempt to fetch the CallNode datasource,
Because UDF `TryGetDatasource` override needs the binding, in this
cycle/"recursive" edge case, there will be a null reference exception
without the check added in this PR.
`FilterUDF():DataSource = Filter(DataSource, Value > 10);
FilterUDF2():DataSource = Filter(FilterUDF(), Value > 11);`
`TryGetDsInfo(Callnode)` would not get a datasource for `FilterUDF()`,
leading to Binder not marking this node async. This led to an issue of
delegation not being preserved on `FilterUDF2()`.
We are adding a way for the hosts to declare a list of non-core public
functions that should be kept plain when getting function names from an
expression.
The pretty parser was broken with introduction of UDFs, though it was
never property implemented for Named Formulas either. This PR introduces
this support.
Previously at https://github.com/microsoft/Power-Fx/pull/2474 we
introduced an API to get a list of called functions from an expression.
We are now adding an option to anonymize a custom function to mask any
private information.
Unable to easily test in this repo. Tests added in PA Client.
Scenario is, e.g. for this expression, the expand info to the second
PrimaryContact access should have ManagingPartner as part of it's expand
path.
"ClearCollect(c3, Filter(Accounts,'Primary Contact'.Status <> 'Status
(Contacts)'.Active));" +
"ClearCollect(c4, Filter(Contacts, 'Managing Partner'.'Primary
Contact'.Status <> 'Status (Contacts)'.Inactive))"
This pr makes nl handler creation async so during creation time, PA can
attach context reduction filters with Nl handler which would then later
be used to trim down the context. This pr also refactors nl2fx, fx2nl
handlers to avoid class fields
For an expression such as `With({a:1}, Set(a, 10))`, the first argument of the Set function should not refer to the scope variable `a` defined by the With function.