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

@superfaceai/parser

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superfaceai/parser - npm Package Compare versions

Comparing version 1.1.0-rc.0 to 1.1.0-rc.1

10

dist/language/error.d.ts

@@ -8,6 +8,6 @@ import { CharIndexSpan, LocationSpan, Source } from './source';

PARSER = "Parser",
/** Jessie syntax error */
JESSIE_SYNTAX = "Jessie syntax",
/** Jessie forbidden construct error */
JESSIE_VALIDATION = "Jessie validation"
/** Script syntax error */
SCRIPT_SYNTAX = "Script syntax",
/** Script forbidden construct error */
SCRIPT_VALIDATION = "Script validation"
}

@@ -41,4 +41,6 @@ export declare type ProtoError = {

static fromSyntaxRuleNoMatch(source: Source, result: RuleResultNoMatch): SyntaxError;
formatVisualization(): string;
formatHints(): string;
format(): string;
get message(): string;
}

53

dist/language/error.js

@@ -157,27 +157,12 @@ "use strict";

}
function isString(i) {
return i !== undefined;
}
function formatHints() {
var hints = [];
for (var _i = 0; _i < arguments.length; _i++) {
hints[_i] = arguments[_i];
}
var filtered = hints.filter(isString);
if (filtered.length === 0) {
return '';
}
return filtered.map(function (h) { return "Hint: " + h; }).join('\n');
}
function errorCategoryStrings(category) {
var result = {
categoryDetail: undefined,
categoryHint: undefined,
categoryHints: [],
};
switch (category) {
case "Jessie syntax" /* JESSIE_SYNTAX */:
case "Jessie validation" /* JESSIE_VALIDATION */:
case "Script syntax" /* SCRIPT_SYNTAX */:
case "Script validation" /* SCRIPT_VALIDATION */:
result.categoryDetail = 'Error in script syntax';
result.categoryHint =
'This was parsed in script context, it might be an error in comlink syntax instead';
result.categoryHints.push('This was parsed in script context, it might be an error in comlink syntax instead');
break;

@@ -197,7 +182,13 @@ }

hints) {
var _a;
this.source = source;
this.location = location;
this.category = category;
var _b = errorCategoryStrings(this.category), categoryDetail = _b.categoryDetail, categoryHints = _b.categoryHints;
this.detail = detail !== null && detail !== void 0 ? detail : 'Invalid or unexpected token';
if (categoryDetail !== undefined) {
this.detail = categoryDetail + ": " + this.detail;
}
this.hints = hints !== null && hints !== void 0 ? hints : [];
(_a = this.hints).push.apply(_a, __spreadArray([], __read(categoryHints)));
}

@@ -244,16 +235,22 @@ SyntaxError.fromSyntaxRuleNoMatch = function (source, result) {

};
SyntaxError.prototype.format = function () {
SyntaxError.prototype.formatVisualization = function () {
// Generate the lines
var _a = generateErrorVisualization(this.source, this.location), visualization = _a.visualization, maxLineNumberLog = _a.maxLineNumberLog, sourceLocation = _a.sourceLocation;
var _b = errorCategoryStrings(this.category), categoryDetail = _b.categoryDetail, categoryHint = _b.categoryHint;
var detail = this.detail;
if (categoryDetail !== undefined) {
detail = categoryDetail + ": " + detail;
}
var errorLine = "SyntaxError: " + detail;
var locationLinePrefix = ' '.repeat(maxLineNumberLog) + '--> ';
var locationLine = "" + locationLinePrefix + this.source.fileName + ":" + sourceLocation.start.line + ":" + sourceLocation.start.column;
var maybeHints = formatHints.apply(void 0, __spreadArray(__spreadArray([], __read(this.hints)), [categoryHint]));
return errorLine + "\n" + locationLine + "\n" + visualization + "\n" + maybeHints;
return locationLine + "\n" + visualization;
};
SyntaxError.prototype.formatHints = function () {
function isString(i) {
return i !== undefined;
}
var filtered = this.hints.filter(isString);
if (filtered.length === 0) {
return '';
}
return filtered.map(function (h) { return "Hint: " + h; }).join('\n');
};
SyntaxError.prototype.format = function () {
return "SyntaxError: " + this.detail + "\n" + this.formatVisualization() + "\n" + this.formatHints();
};
Object.defineProperty(SyntaxError.prototype, "message", {

@@ -260,0 +257,0 @@ get: function () {

import { ProtoError, SyntaxErrorCategory } from '../../error';
export declare type JessieSyntaxProtoError = ProtoError & {
category: SyntaxErrorCategory.JESSIE_SYNTAX;
category: SyntaxErrorCategory.SCRIPT_SYNTAX;
};

@@ -5,0 +5,0 @@ export declare function transpileScript(input: string, reportDiagnostics: true): {

@@ -67,3 +67,3 @@ "use strict";

syntaxProtoError = {
category: "Jessie syntax" /* JESSIE_SYNTAX */,
category: "Script syntax" /* SCRIPT_SYNTAX */,
relativeSpan: {

@@ -70,0 +70,0 @@ start: (_a = diag.start) !== null && _a !== void 0 ? _a : 0,

import { ProtoError, SyntaxErrorCategory } from '../../error';
export declare type ForbiddenConstructProtoError = ProtoError & {
detail: string;
category: SyntaxErrorCategory.JESSIE_VALIDATION;
category: SyntaxErrorCategory.SCRIPT_VALIDATION;
};
export declare function validateScript(input: string): ForbiddenConstructProtoError[];

@@ -97,3 +97,3 @@ "use strict";

relativeSpan: { start: node.getStart(), end: node.getEnd() },
category: "Jessie validation" /* JESSIE_VALIDATION */,
category: "Script validation" /* SCRIPT_VALIDATION */,
});

@@ -115,3 +115,3 @@ }

relativeSpan: { start: node.getStart(), end: node.getEnd() },
category: "Jessie validation" /* JESSIE_VALIDATION */,
category: "Script validation" /* SCRIPT_VALIDATION */,
hints: [],

@@ -118,0 +118,0 @@ });

{
"name": "@superfaceai/parser",
"version": "1.1.0-rc.0",
"version": "1.1.0-rc.1",
"description": "Level 5 autonomous, self-driving API client, https://superface.ai",

@@ -5,0 +5,0 @@ "repository": "https://github.com/superfaceai/parser.git",

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