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

@openfn/describe-package

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfn/describe-package - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

157

dist/index.js

@@ -8,74 +8,2 @@ var __defProp = Object.defineProperty;

// src/describe-project.ts
var describeParameter = (project, symbol) => {
const typeNode = project.typeChecker.getTypeFromTypeNode(symbol.type);
const typeString = project.typeChecker.typeToString(typeNode);
return {
name: symbol.name,
optional: false,
type: typeString
};
};
var describeFunction = (project, symbol, moduleName) => {
let parent = void 0;
if (symbol.isExportAlias) {
[parent] = symbol.symbol.parent.escapedName.match(/(language-\w+)/);
}
return {
name: moduleName ? `${moduleName}.${symbol.name}` : symbol.name,
description: symbol.comment,
parameters: symbol.parameters.map((p) => describeParameter(project, p)),
magic: symbol.jsDocTags.some((tag) => tag.tagName.escapedText === "magic"),
isOperation: false,
examples: symbol.examples.map((eg) => {
if (eg.startsWith("<caption>")) {
let [caption, code] = eg.split("</caption>");
caption = caption.replace("<caption>", "");
return { caption: caption.trim(), code: code.trim() };
}
return { code: eg.trim() };
}),
parent
};
};
var describeProject = (project, typesEntry = "index.d.ts", options = {}) => {
const sourceFile = project.getSourceFile(typesEntry);
if (!sourceFile) {
throw new Error(`Couldn't find a SourceFile for: ${typesEntry}`);
}
return project.getSymbol(sourceFile).exports.filter((symbol) => {
if (options.includePrivate) {
return true;
}
return symbol.isExportAlias || symbol.isPublic;
}).reduce((symbols, symbol) => {
if (symbol.isFunctionDeclaration) {
symbols.push(describeFunction(project, symbol));
}
if (symbol.isModuleDeclaration) {
symbol.exports.map((modSymbol) => {
if (modSymbol.isFunctionDeclaration) {
symbols.push(describeFunction(project, modSymbol, symbol.name));
}
});
}
return symbols;
}, []);
};
var describe_project_default = describeProject;
// src/util.ts
var getNameAndVersion = (specifier) => {
let name;
let version;
const atIndex = specifier.lastIndexOf("@");
if (atIndex > 0) {
name = specifier.substring(0, atIndex);
version = specifier.substring(atIndex + 1);
} else {
name = specifier;
}
return { name, version };
};
// src/typescript/project.ts

@@ -232,2 +160,3 @@ import ts2 from "typescript";

// src/typescript/project.ts
var NO_SYMBOLS_FOUND = "Expected a symbol for location of SourceFile";
var _Project = class {

@@ -285,3 +214,3 @@ fsMap;

if (!sfSymbol) {
throw new Error("Expected a symbol for location of SourceFile");
throw new Error(NO_SYMBOLS_FOUND);
}

@@ -346,2 +275,84 @@ return new WrappedSymbol(this.typeChecker, sfSymbol);

// src/describe-project.ts
var describeParameter = (project, symbol) => {
const typeNode = project.typeChecker.getTypeFromTypeNode(symbol.type);
const typeString = project.typeChecker.typeToString(typeNode);
return {
name: symbol.name,
optional: false,
type: typeString
};
};
var describeFunction = (project, symbol, moduleName) => {
let parent = void 0;
if (symbol.isExportAlias) {
[parent] = symbol.symbol.parent.escapedName.match(/(language-\w+)/);
}
return {
name: moduleName ? `${moduleName}.${symbol.name}` : symbol.name,
description: symbol.comment,
parameters: symbol.parameters.map((p) => describeParameter(project, p)),
magic: symbol.jsDocTags.some((tag) => tag.tagName.escapedText === "magic"),
isOperation: false,
examples: symbol.examples.map((eg) => {
if (eg.startsWith("<caption>")) {
let [caption, code] = eg.split("</caption>");
caption = caption.replace("<caption>", "");
return { caption: caption.trim(), code: code.trim() };
}
return { code: eg.trim() };
}),
parent
};
};
var describeProject = (project, typesEntry = "index.d.ts", options = {}) => {
const sourceFile = project.getSourceFile(typesEntry);
if (!sourceFile) {
throw new Error(`Couldn't find a SourceFile for: ${typesEntry}`);
}
let symbols;
try {
symbols = project.getSymbol(sourceFile);
} catch (e) {
if (e.messsage = NO_SYMBOLS_FOUND) {
symbols = { exports: [] };
} else {
throw e;
}
}
return symbols.exports.filter((symbol) => {
if (options.includePrivate) {
return true;
}
return symbol.isExportAlias || symbol.isPublic;
}).reduce((symbols2, symbol) => {
if (symbol.isFunctionDeclaration) {
symbols2.push(describeFunction(project, symbol));
}
if (symbol.isModuleDeclaration) {
symbol.exports.map((modSymbol) => {
if (modSymbol.isFunctionDeclaration) {
symbols2.push(describeFunction(project, modSymbol, symbol.name));
}
});
}
return symbols2;
}, []);
};
var describe_project_default = describeProject;
// src/util.ts
var getNameAndVersion = (specifier) => {
let name;
let version;
const atIndex = specifier.lastIndexOf("@");
if (atIndex > 0) {
name = specifier.substring(0, atIndex);
version = specifier.substring(atIndex + 1);
} else {
name = specifier;
}
return { name, version };
};
// src/fs/package-fs.ts

@@ -348,0 +359,0 @@ import fetch from "cross-fetch";

{
"name": "@openfn/describe-package",
"version": "0.0.15",
"version": "0.0.16",
"description": "Utilities to inspect an npm package.",

@@ -5,0 +5,0 @@ "author": "Open Function Group <admin@openfn.org>",

Sorry, the diff of this file is too big to display

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