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

@metrichor/epi2me-client-web

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metrichor/epi2me-client-web - npm Package Compare versions

Comparing version 0.2.10615829 to 0.2.10629429

2

common/index.d.ts

@@ -18,4 +18,4 @@ export type { ErrorHandler } from '@apollo/client/link/error';

export { create_telemetry_client, watch_report_available, watch_report_content, has_telemetry, get_telemetry_content } from './telemetry_client';
export { WIDGET, validate_argument, resolve_workflow_configuration, resolve_file_parameters, get_instance_configuration, get_workflow_configuration } from './parameters';
export { WIDGET, validate_workflow_argument, resolve_workflow_configuration, resolve_file_parameters, get_instance_configuration, get_workflow_configuration } from './parameters';
export { WorkflowParam, WorkflowConfiguration, ResolvedWorkflowConfiguration } from './parameters.type';
//# sourceMappingURL=index.d.ts.map

@@ -8,2 +8,3 @@ import type { GraphQLClient } from './GraphQLClient.type';

text = "text_input",
number = "number_input",
hidden = "hidden_input",

@@ -24,3 +25,15 @@ dropdown = "simple_dropdown",

};
export declare const is_workflow_params: import("ts-runtime-typecheck").TypeCheck<{
export declare const is_widget_form_type: import("ts-runtime-typecheck").TypeCheck<import("ts-runtime-typecheck").Optional<{
type: "number" | "text";
minLength: import("ts-runtime-typecheck").Optional<number>;
maxLength: import("ts-runtime-typecheck").Optional<number>;
min: import("ts-runtime-typecheck").Optional<number>;
max: import("ts-runtime-typecheck").Optional<number>;
step: import("ts-runtime-typecheck").Optional<number>;
placeholder: import("ts-runtime-typecheck").Optional<string>;
readonly: import("ts-runtime-typecheck").Optional<boolean>;
}>> & {
TYPE_NAME: string;
};
export declare const is_workflow_param: import("ts-runtime-typecheck").TypeCheck<{
cgi_param: string;

@@ -41,2 +54,12 @@ component_id: number;

filetype: import("ts-runtime-typecheck").Optional<string>;
form_type: import("ts-runtime-typecheck").Optional<{
type: "number" | "text";
minLength: import("ts-runtime-typecheck").Optional<number>;
maxLength: import("ts-runtime-typecheck").Optional<number>;
min: import("ts-runtime-typecheck").Optional<number>;
max: import("ts-runtime-typecheck").Optional<number>;
step: import("ts-runtime-typecheck").Optional<number>;
placeholder: import("ts-runtime-typecheck").Optional<string>;
readonly: import("ts-runtime-typecheck").Optional<boolean>;
}>;
help: import("ts-runtime-typecheck").Optional<{

@@ -52,5 +75,8 @@ text: string;

}[]>;
}[]>;
}> & {
TYPE_NAME: string;
};
export declare function get_workflow_configuration(gql: GraphQLClient, id_workflow: string): Promise<WorkflowConfiguration>;
export declare function get_instance_configuration(gql: GraphQLClient, id_instance: string): Promise<WorkflowConfiguration>;
export declare function transform_parameter(source: unknown): WorkflowParam;
export declare function resolve_file_parameters(cfg: WorkflowConfiguration): {

@@ -62,3 +88,3 @@ source: string;

export declare function resolve_workflow_configuration(gql: GraphQLClient, cfg: WorkflowConfiguration): Promise<ResolvedWorkflowConfiguration>;
export declare function validate_argument(parameter: WorkflowParam, value: string | undefined): string | undefined;
export declare function validate_workflow_argument(parameter: WorkflowParam, value: string | undefined): string | undefined;
//# sourceMappingURL=parameters.d.ts.map

@@ -21,2 +21,12 @@ import type { Optional, Primitive } from 'ts-runtime-typecheck';

}>>;
readonly form_type?: Optional<{
readonly type: 'text' | 'number';
readonly minLength?: Optional<number>;
readonly maxLength?: Optional<number>;
readonly min?: Optional<number>;
readonly max?: Optional<number>;
readonly step?: Optional<number>;
readonly placeholder?: Optional<string>;
readonly readonly?: Optional<boolean>;
}>;
readonly filetype?: Optional<string>;

@@ -23,0 +33,0 @@ readonly values?: Optional<ReadonlyArray<{

@@ -564,2 +564,3 @@ 'use strict';

WIDGET["text"] = "text_input";
WIDGET["number"] = "number_input";
WIDGET["hidden"] = "hidden_input";

@@ -578,3 +579,13 @@ WIDGET["dropdown"] = "simple_dropdown";

});
const is_workflow_params = tsRuntimeTypecheck.isArrayOf(tsRuntimeTypecheck.isStruct({
const is_widget_form_type = tsRuntimeTypecheck.isOptStruct({
type: tsRuntimeTypecheck.isUnion(tsRuntimeTypecheck.isLiteral('text'), tsRuntimeTypecheck.isLiteral('number')),
minLength: tsRuntimeTypecheck.isOptNumber,
maxLength: tsRuntimeTypecheck.isOptNumber,
min: tsRuntimeTypecheck.isOptNumber,
max: tsRuntimeTypecheck.isOptNumber,
step: tsRuntimeTypecheck.isOptNumber,
placeholder: tsRuntimeTypecheck.isOptString,
readonly: tsRuntimeTypecheck.isOptBoolean,
});
const is_workflow_param = tsRuntimeTypecheck.isStruct({
cgi_param: tsRuntimeTypecheck.isString,

@@ -588,2 +599,3 @@ component_id: tsRuntimeTypecheck.isNumber,

filetype: tsRuntimeTypecheck.isOptString,
form_type: is_widget_form_type,
help: tsRuntimeTypecheck.isOptStruct({

@@ -599,3 +611,3 @@ text: tsRuntimeTypecheck.isString,

}))
}));
});
async function get_workflow_configuration(gql, id_workflow) {

@@ -610,4 +622,5 @@ var _a;

}
const { params: parameters, inputFormats: input_formats } = response.data.workflow;
tsRuntimeTypecheck.invariant(is_workflow_params(parameters), 'Workflow parameters are invalid');
const { params: raw_parameters, inputFormats: input_formats } = response.data.workflow;
tsRuntimeTypecheck.invariant(Array.isArray(raw_parameters), 'Workflow parameters are invalid');
const parameters = raw_parameters.map(el => transform_parameter(el));
const workflow_arguments = {};

@@ -629,3 +642,3 @@ for (const { widget, cgi_param, default: value } of parameters) {

id_workflow,
parameters: parameters.map(({ values, ...p }) => tsRuntimeTypecheck.isDictionary(values) ? p : { ...p, values }),
parameters,
arguments: workflow_arguments,

@@ -645,4 +658,5 @@ accepted_files: input_formats,

}
const { params: parameters, inputFormats: input_formats, idWorkflow: id_workflow } = instance.workflowImage.workflow;
tsRuntimeTypecheck.invariant(is_workflow_params(parameters), 'Workflow parameters are invalid');
const { params: raw_parameters, inputFormats: input_formats, idWorkflow: id_workflow } = instance.workflowImage.workflow;
tsRuntimeTypecheck.invariant(Array.isArray(raw_parameters), 'Workflow parameters are invalid');
const parameters = raw_parameters.map(el => transform_parameter(el));
const workflow_arguments = {};

@@ -658,3 +672,3 @@ const parameter_ids = Array.from(parameters, p => p.cgi_param);

id_workflow,
parameters: parameters.map(({ values, ...p }) => tsRuntimeTypecheck.isDictionary(values) ? p : { ...p, values }),
parameters,
arguments: workflow_arguments,

@@ -667,2 +681,22 @@ accepted_files: input_formats,

}
function transform_parameter(source) {
tsRuntimeTypecheck.invariant(is_workflow_param(source), 'Workflow parameters are invalid');
const { values, form_type, validation, ...param } = source;
if (tsRuntimeTypecheck.isDictionary(values)) {
return param;
}
if (values) {
return { values, ...param };
}
if (param.widget !== exports.WIDGET.text) {
return param;
}
const is_text = form_type ? form_type.type === 'text' : isNaN(+param.default);
return {
...param,
form_type,
validation,
widget: is_text ? exports.WIDGET.text : exports.WIDGET.number,
};
}
function resolve_file_parameters(cfg) {

@@ -729,3 +763,3 @@ if (cfg.id_dataset !== undefined) {

const value = (_a = cfg.arguments[parameter.cgi_param]) === null || _a === void 0 ? void 0 : _a.toString();
const error = validate_argument(parameter, value);
const error = validate_workflow_argument(parameter, value);
if (error) {

@@ -762,3 +796,3 @@ errors.push(error);

}
function validate_argument(parameter, value) {
function validate_workflow_argument(parameter, value) {
var _a, _b, _c, _d, _e, _f;

@@ -771,8 +805,11 @@ if (value === undefined || value === '') {

}
if (parameter.widget === exports.WIDGET.number && isNaN(+value)) {
return 'Expected argument to be numeric.';
}
for (const validator of (_b = parameter.validation) !== null && _b !== void 0 ? _b : []) {
if (tsRuntimeTypecheck.isDefined(validator.minLength) && validator.minLength > value.length) {
return (_c = validator.message) !== null && _c !== void 0 ? _c : `Value must be at least ${validator.minLength} characters long.`;
return (_c = validator.message) !== null && _c !== void 0 ? _c : `Value must be ${validator.minLength} characters or more.`;
}
if (tsRuntimeTypecheck.isDefined(validator.maxLength) && validator.maxLength < value.length) {
return (_d = validator.message) !== null && _d !== void 0 ? _d : `Value must be less than ${validator.maxLength} characters long.`;
return (_d = validator.message) !== null && _d !== void 0 ? _d : `Value must be ${validator.maxLength} characters or less.`;
}

@@ -787,3 +824,27 @@ if (tsRuntimeTypecheck.isDefined(validator.pattern)) {

}
if (parameter.widget === 'file' && parameter.filetype) {
if (parameter.form_type) {
if (parameter.form_type.readonly && value !== parameter.default) {
return 'Readonly value has been modified.';
}
if (parameter.widget === exports.WIDGET.number) {
const numeric = +value;
const { min, max } = parameter.form_type;
if (typeof min === 'number' && numeric < min) {
return `Value must be ${min} or higher.`;
}
if (typeof max === 'number' && numeric > max) {
return `Value must be ${max} or lower.`;
}
}
else if (parameter.widget === exports.WIDGET.text) {
const { minLength, maxLength } = parameter.form_type;
if (typeof minLength === 'number' && value.length < minLength) {
return `Value must be ${minLength} characters or more.`;
}
if (typeof maxLength === 'number' && value.length > maxLength) {
return `Value must be ${maxLength} characters or less.`;
}
}
}
if (parameter.widget === exports.WIDGET.file && parameter.filetype) {
const extensions = parameter.filetype.split(',').map((ext) => {

@@ -906,4 +967,4 @@ ext = ext.trim();

exports.session_jwt = session_jwt;
exports.validate_argument = validate_argument;
exports.validate_workflow_argument = validate_workflow_argument;
exports.watch_report_available = watch_report_available;
exports.watch_report_content = watch_report_content;
{
"name": "@metrichor/epi2me-client-web",
"version": "0.2.10615829",
"version": "0.2.10629429",
"license": "MPL-2.0",

@@ -5,0 +5,0 @@ "author": "Metrichor <support@nanoporetech.com>",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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