Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

custom-functions-metadata

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-functions-metadata - npm Package Compare versions

Comparing version 0.5.2 to 1.0.0

1

lib/generate.d.ts

@@ -50,2 +50,3 @@ import * as ts from "typescript";

export interface IExperimentalOptions {
/** @deprecated */
allowRepeatingParameters?: boolean;

@@ -52,0 +53,0 @@ }

35

lib/generate.js

@@ -128,4 +128,2 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

const ids = [];
const allowRepeatingParameters = (parseTreeOptions && parseTreeOptions.experimental && parseTreeOptions.experimental.allowRepeatingParameters)
|| ((typeof process !== "undefined") && (process.env.ALLOW_REPEATING_PARAMETERS !== undefined));
const sourceFile = ts.createSourceFile(sourceFileName, sourceCode, ts.ScriptTarget.Latest, true);

@@ -175,6 +173,6 @@ buildEnums(sourceFile);

: functionDeclaration.parameters.slice(0, functionDeclaration.parameters.length);
const parameters = getParameters(paramsToParse, jsDocParamTypeInfo, jsDocParamInfo, jsDocsParamOptionalInfo, extra, enumList, allowRepeatingParameters);
const parameters = getParameters(paramsToParse, jsDocParamTypeInfo, jsDocParamInfo, jsDocsParamOptionalInfo, extra, enumList);
const description = getDescription(functionDeclaration);
const helpUrl = normalizeLineEndings(getTagComment(functionDeclaration, HELPURL_PARAM));
const result = getResults(functionDeclaration, isStreamingFunction, lastParameter, jsDocParamTypeInfo, extra, enumList, allowRepeatingParameters);
const result = getResults(functionDeclaration, isStreamingFunction, lastParameter, jsDocParamTypeInfo, extra, enumList);
const options = getOptions(functionDeclaration, isStreamingFunction, isCancelableFunction, isInvocationFunction, extra);

@@ -361,3 +359,3 @@ const funcName = (functionDeclaration.name) ? functionDeclaration.name.text : "";

*/
function getResults(func, isStreamingFunction, lastParameter, jsDocParamTypeInfo, extra, enumList, allowRepeatingParameters) {
function getResults(func, isStreamingFunction, lastParameter, jsDocParamTypeInfo, extra, enumList) {
let resultType = "any";

@@ -399,3 +397,3 @@ let resultDim = "scalar";

}
resultType = getParamType(lastParameterType.typeArguments[0], extra, enumList, allowRepeatingParameters);
resultType = getParamType(lastParameterType.typeArguments[0], extra, enumList);
resultDim = getParamDim(lastParameterType.typeArguments[0]);

@@ -415,3 +413,3 @@ }

else {
resultType = getParamType(func.type, extra, enumList, allowRepeatingParameters);
resultType = getParamType(func.type, extra, enumList);
resultDim = getParamDim(func.type);

@@ -429,3 +427,3 @@ }

}
resultType = getParamType(returnTypeFromJSDoc, extra, enumList, allowRepeatingParameters);
resultType = getParamType(returnTypeFromJSDoc, extra, enumList);
resultDim = getParamDim(returnTypeFromJSDoc);

@@ -452,3 +450,3 @@ }

*/
function getParameters(params, jsDocParamTypeInfo, jsDocParamInfo, jsDocParamOptionalInfo, extra, enumList, allowRepeatingParameters) {
function getParameters(params, jsDocParamTypeInfo, jsDocParamInfo, jsDocParamOptionalInfo, extra, enumList) {
const parameterMetadata = [];

@@ -472,3 +470,3 @@ const parameters = params

}
const ptype = getParamType(typeNode, extra, enumList, allowRepeatingParameters);
const ptype = getParamType(typeNode, extra, enumList);
const pMetadataItem = {

@@ -495,3 +493,3 @@ description: jsDocParamInfo[name],

// only return repeating if true and allowed
if (!pMetadataItem.repeating || !allowRepeatingParameters) {
if (!pMetadataItem.repeating) {
delete pMetadataItem.repeating;

@@ -764,3 +762,3 @@ }

*/
function getParamType(t, extra, enumList, allowRepeatingParameters) {
function getParamType(t, extra, enumList) {
let type = "any";

@@ -788,14 +786,3 @@ // Only get type for typescript files. js files will return any for all types

arrayType = getArrayDimensionalityAndType(t);
if (allowRepeatingParameters) {
kind = arrayType.type;
}
else {
if (arrayType.dimensionality !== 2) {
// @ts-ignore
extra.errors.push(logError("Invalid type array: " + TYPE_MAPPINGS_SIMPLE[arrayType.type], typePosition));
}
else {
kind = arrayType.type;
}
}
kind = arrayType.type;
}

@@ -802,0 +789,0 @@ // @ts-ignore

{
"name": "custom-functions-metadata",
"version": "0.5.2",
"version": "1.0.0",
"description": "Generate metadata for Excel Custom Functions.",

@@ -30,3 +30,3 @@ "main": "./lib/main.js",

"nconf": "^0.10.0",
"office-addin-cli": "^0.2.3",
"office-addin-cli": "^0.2.4",
"optimist": "^0.6.1",

@@ -57,3 +57,3 @@ "xregexp": "^4.2.4"

},
"gitHead": "7d835751ec738a31f5772dd9ab2995c15dda1a0a"
"gitHead": "6177cf5b837b2d25595a94caacb43b4731432955"
}

@@ -50,3 +50,3 @@ # Custom Functions Metadata Specification

* The id must be unique for all custom functions.
* The characters allowed are limited to: A-Z, a-z, 0-9, and period (.).
* The characters allowed are limited to: A-Z, a-z, 0-9, underscore (_), and period (.).

@@ -53,0 +53,0 @@ #### name

@@ -65,2 +65,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

export interface IExperimentalOptions {
/** @deprecated */
allowRepeatingParameters?: boolean;

@@ -198,4 +199,2 @@ }

const ids: string[] = [];
const allowRepeatingParameters = (parseTreeOptions && parseTreeOptions.experimental && parseTreeOptions.experimental.allowRepeatingParameters)
|| ((typeof process !== "undefined") && (process.env.ALLOW_REPEATING_PARAMETERS !== undefined));

@@ -255,3 +254,3 @@ const sourceFile = ts.createSourceFile(sourceFileName, sourceCode, ts.ScriptTarget.Latest, true);

const parameters = getParameters(paramsToParse, jsDocParamTypeInfo, jsDocParamInfo, jsDocsParamOptionalInfo, extra, enumList, allowRepeatingParameters);
const parameters = getParameters(paramsToParse, jsDocParamTypeInfo, jsDocParamInfo, jsDocsParamOptionalInfo, extra, enumList);

@@ -261,3 +260,3 @@ const description = getDescription(functionDeclaration);

const result = getResults(functionDeclaration, isStreamingFunction, lastParameter, jsDocParamTypeInfo, extra, enumList, allowRepeatingParameters);
const result = getResults(functionDeclaration, isStreamingFunction, lastParameter, jsDocParamTypeInfo, extra, enumList);

@@ -472,3 +471,3 @@ const options = getOptions(functionDeclaration, isStreamingFunction, isCancelableFunction, isInvocationFunction, extra);

*/
function getResults(func: ts.FunctionDeclaration, isStreamingFunction: boolean, lastParameter: ts.ParameterDeclaration, jsDocParamTypeInfo: { [key: string]: string }, extra: IFunctionExtras, enumList: string[], allowRepeatingParameters: boolean): IFunctionResult {
function getResults(func: ts.FunctionDeclaration, isStreamingFunction: boolean, lastParameter: ts.ParameterDeclaration, jsDocParamTypeInfo: { [key: string]: string }, extra: IFunctionExtras, enumList: string[]): IFunctionResult {
let resultType = "any";

@@ -514,3 +513,3 @@ let resultDim = "scalar";

}
resultType = getParamType(lastParameterType.typeArguments[0], extra, enumList, allowRepeatingParameters);
resultType = getParamType(lastParameterType.typeArguments[0], extra, enumList);
resultDim = getParamDim(lastParameterType.typeArguments[0]);

@@ -529,3 +528,3 @@ } else if (func.type) {

} else {
resultType = getParamType(func.type, extra, enumList, allowRepeatingParameters);
resultType = getParamType(func.type, extra, enumList);
resultDim = getParamDim(func.type);

@@ -544,3 +543,3 @@ }

}
resultType = getParamType(returnTypeFromJSDoc, extra, enumList, allowRepeatingParameters);
resultType = getParamType(returnTypeFromJSDoc, extra, enumList);
resultDim = getParamDim(returnTypeFromJSDoc);

@@ -572,3 +571,3 @@ }

*/
function getParameters(params: ts.ParameterDeclaration[], jsDocParamTypeInfo: { [key: string]: string }, jsDocParamInfo: { [key: string]: string }, jsDocParamOptionalInfo: { [key: string]: string }, extra: IFunctionExtras, enumList: string[], allowRepeatingParameters: boolean ): IFunctionParameter[] {
function getParameters(params: ts.ParameterDeclaration[], jsDocParamTypeInfo: { [key: string]: string }, jsDocParamInfo: { [key: string]: string }, jsDocParamOptionalInfo: { [key: string]: string }, extra: IFunctionExtras, enumList: string[]): IFunctionParameter[] {
const parameterMetadata: IFunctionParameter[] = [];

@@ -592,3 +591,3 @@ const parameters = params

}
const ptype = getParamType(typeNode, extra, enumList, allowRepeatingParameters);
const ptype = getParamType(typeNode, extra, enumList);

@@ -620,3 +619,3 @@ const pMetadataItem: IFunctionParameter = {

// only return repeating if true and allowed
if (!pMetadataItem.repeating || !allowRepeatingParameters) {
if (!pMetadataItem.repeating) {
delete pMetadataItem.repeating;

@@ -941,3 +940,3 @@ }

*/
function getParamType(t: ts.TypeNode, extra: IFunctionExtras, enumList: string[], allowRepeatingParameters: boolean): string {
function getParamType(t: ts.TypeNode, extra: IFunctionExtras, enumList: string[]): string {
let type = "any";

@@ -965,12 +964,3 @@ // Only get type for typescript files. js files will return any for all types

arrayType = getArrayDimensionalityAndType(t);
if (allowRepeatingParameters) {
kind = arrayType.type;
} else {
if (arrayType.dimensionality !== 2) {
// @ts-ignore
extra.errors.push(logError("Invalid type array: " + TYPE_MAPPINGS_SIMPLE[arrayType.type], typePosition));
} else {
kind = arrayType.type;
}
}
kind = arrayType.type;
}

@@ -977,0 +967,0 @@ // @ts-ignore

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc