Skip to content

Commit a55da9a

Browse files
committed
Add syncSupport function option
1 parent e26c633 commit a55da9a

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

packages/custom-functions-metadata/src/parseTree.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface IFunctionOptions {
3030
excludeFromAutoComplete?: boolean;
3131
linkedEntityLoadService?: boolean;
3232
capturesCallingObject?: boolean;
33+
syncSupport?: boolean
3334
}
3435

3536
export interface IFunctionParameter {
@@ -132,6 +133,7 @@ const REQUIRESADDRESS = "requiresaddress";
132133
const REQUIRESPARAMETERADDRESSES = "requiresparameteraddresses";
133134
const STREAMING = "streaming";
134135
const VOLATILE = "volatile";
136+
const SYNCSUPPORT = "syncsupport";
135137

136138
const TYPE_MAPPINGS = {
137139
[ts.SyntaxKind.NumberKeyword]: "number",
@@ -462,7 +464,8 @@ export function parseTree(sourceCode: string, sourceFileName: string): IParseTre
462464
!options.requiresStreamParameterAddresses &&
463465
!options.excludeFromAutoComplete &&
464466
!options.linkedEntityLoadService &&
465-
!options.capturesCallingObject
467+
!options.capturesCallingObject &&
468+
!options.syncSupport
466469
) {
467470
delete functionMetadata.options;
468471
} else {
@@ -505,6 +508,10 @@ export function parseTree(sourceCode: string, sourceFileName: string): IParseTre
505508
if (!options.capturesCallingObject) {
506509
delete options.capturesCallingObject;
507510
}
511+
512+
if (!options.syncSupport) {
513+
delete options.syncSupport;
514+
}
508515
}
509516

510517
if (!functionMetadata.helpUrl) {
@@ -667,6 +674,7 @@ function getOptions(
667674
excludeFromAutoComplete: isExcludedFromAutoComplete(func),
668675
linkedEntityLoadService: isLinkedEntityLoadService(func),
669676
capturesCallingObject: capturesCallingObject(func),
677+
syncSupport: isSyncSupport(func),
670678
};
671679

672680
if (isAddressRequired(func) || isRequiresParameterAddresses(func)) {
@@ -1062,6 +1070,14 @@ function capturesCallingObject(node: ts.Node): boolean {
10621070
return hasTag(node, CAPTURESCALLINGOBJECT);
10631071
}
10641072

1073+
/**
1074+
* Returns true if syncSupport tag found in comments
1075+
* @param node jsDocs node
1076+
*/
1077+
function isSyncSupport(node: ts.Node): boolean {
1078+
return hasTag(node, SYNCSUPPORT);
1079+
}
1080+
10651081
function containsTag(tag: ts.JSDocTag, tagName: string): boolean {
10661082
return (tag.tagName.escapedText as string).toLowerCase() === tagName;
10671083
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Since @syncSupport is present, the last function parameter should be of type CustomFunctions.Invocation : (10,40)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Since @syncSupport is present, the last function parameter should be of type CustomFunctions.Invocation : (10,48)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
/**
5+
* Test missing invocation parameter type
6+
* @param x {string} string
7+
* @customfunction
8+
* @syncSupport
9+
*/
10+
function customFunctionInvocationTest(x) {
11+
// Empty
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
/**
5+
* Test missing invocation parameter type
6+
* @param x string
7+
* @customfunction
8+
* @syncSupport
9+
*/
10+
function customFunctionInvocationTest(x: string) {
11+
// Empty
12+
}

0 commit comments

Comments
 (0)