Socket
Socket
Sign inDemoInstall

@prismatic-io/spectral

Package Overview
Dependencies
Maintainers
0
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismatic-io/spectral - npm Package Compare versions

Comparing version 9.0.0-rc.4 to 9.0.0-rc.5

dist/generators/componentManifest/templates/partials/inputs.ejs

27

dist/generators/componentManifest/cli.js

@@ -48,2 +48,3 @@ "use strict";

}
const args = process.argv.slice(3);
const flags = {

@@ -53,3 +54,3 @@ name: {

value: (0, getFlagStringValue_1.getFlagsStringValue)({
args: process.argv.slice(3),
args,
flags: ["--name", "-n"],

@@ -62,3 +63,3 @@ }),

value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
args: process.argv.slice(3),
args,
flags: ["--verbose", "-v"],

@@ -71,3 +72,3 @@ }),

value: (0, getFlagStringValue_1.getFlagsStringValue)({
args: process.argv.slice(3),
args,
flags: ["--output-dir", "-o"],

@@ -80,3 +81,3 @@ }),

value: (0, getFlagStringValue_1.getFlagsStringValue)({
args: process.argv.slice(3),
args,
flags: ["--registry", "-r"],

@@ -89,3 +90,3 @@ }),

value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
args: process.argv.slice(3),
args,
flags: ["--dry-run", "-d"],

@@ -95,9 +96,9 @@ }),

},
include_signature: {
flag: ["--include-signature", "-s"],
skip_signature_verify: {
flag: ["--skip-signature-verify"],
value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
args: process.argv.slice(3),
flags: ["--include-signature", "-s"],
args,
flags: ["--skip-signature-verify"],
}),
description: "This will include the published component's signature key. Allowing you to publish the Code Native Integrations (CNI) where this component manifest is used.",
description: "This skips the signature verification process, always returning a component signature in the component manifest.",
},

@@ -107,3 +108,3 @@ help: {

value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
args: process.argv.slice(3),
args,
flags: ["--help", "-h"],

@@ -125,4 +126,4 @@ }),

dryRun: flags.dry_run.value,
includeSignature: flags.include_signature.value,
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@components/${component.key}-manifest`,
skipSignatureVerify: flags.skip_signature_verify.value,
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@component-manifests/${component.key}`,
dependencies: {

@@ -129,0 +130,0 @@ spectral: packageJson.version,

@@ -11,2 +11,4 @@ "use strict";

required: input.required,
collection: input.collection,
inputType: input.type,
properties: documentProperties.reduce((acc, key) => {

@@ -64,5 +66,12 @@ const value = input[key]

const getInputType = (input) => {
return input.model
const valueType = input.model
? input.model.map((choice) => `"${choice.value}"`).join(" | ")
: exports.INPUT_TYPE_MAP[input.type] || "never";
if (input.collection === "keyvaluelist") {
return `Record<string, ${valueType}>`;
}
if (input.collection === "valuelist") {
return `${valueType}[]`;
}
return valueType;
};

@@ -6,3 +6,3 @@ import { PackageDependencies } from "./createStaticFiles";

dryRun: boolean;
includeSignature: boolean;
skipSignatureVerify: boolean;
packageName: string;

@@ -15,3 +15,3 @@ dependencies: PackageDependencies;

}
export declare const createComponentManifest: ({ component, dryRun, includeSignature, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateComponentManifestProps) => Promise<void>;
export declare const createComponentManifest: ({ component, dryRun, skipSignatureVerify, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateComponentManifestProps) => Promise<void>;
export {};

@@ -24,6 +24,6 @@ "use strict";

const getComponentSignatureWithPrism_1 = require("../utils/getComponentSignatureWithPrism");
const createComponentManifest = ({ component, dryRun, includeSignature, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }) => __awaiter(void 0, void 0, void 0, function* () {
const signature = includeSignature
? yield (0, getComponentSignatureWithPrism_1.getComponentSignatureWithPrism)()
: null;
const createComponentManifest = ({ component, dryRun, skipSignatureVerify, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }) => __awaiter(void 0, void 0, void 0, function* () {
const signature = yield (0, getComponentSignatureWithPrism_1.getComponentSignatureWithPrism)({
skipSignatureVerify,
});
if (verbose) {

@@ -30,0 +30,0 @@ console.info(`Creating a component manifest for ${component.display.label}...`);

@@ -1,1 +0,5 @@

export declare const getComponentSignatureWithPrism: () => Promise<string | null>;
interface GetComponentSignatureWithPrismProps {
skipSignatureVerify: boolean;
}
export declare const getComponentSignatureWithPrism: ({ skipSignatureVerify, }: GetComponentSignatureWithPrismProps) => Promise<string | null>;
export {};

@@ -16,8 +16,8 @@ "use strict";

const exec = (0, util_1.promisify)(child_process_1.exec);
const getComponentSignatureWithPrism = () => __awaiter(void 0, void 0, void 0, function* () {
const getComponentSignatureWithPrism = ({ skipSignatureVerify, }) => __awaiter(void 0, void 0, void 0, function* () {
if (!(yield isPrismAvailable())) {
console.log("Prism must be installed");
console.log("Prism must be installed.");
process.exit(1);
}
const { stdout } = yield exec("prism components:signature", {
const { stdout } = yield exec(`prism components:signature ${skipSignatureVerify ? "--skip-signature-verify" : ""}`, {
windowsHide: true,

@@ -27,3 +27,3 @@ });

if (!signatureKey) {
console.log("Failed to get component signature. Please verify your Component has been published.");
console.log("Failed to get component signature, please verify your component has been published.");
process.exit(1);

@@ -30,0 +30,0 @@ }

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {

@@ -30,4 +39,15 @@ var t = {};

const referenceKey = (0, uuid_1.v4)();
const configVars = Object.assign({}, ...Object.values((_a = definition.configPages) !== null && _a !== void 0 ? _a : {}).map(({ elements }) => elements));
return Object.assign(Object.assign({}, codeNativeIntegrationComponent(definition, referenceKey, configVars)), { codeNativeIntegrationYAML: codeNativeIntegrationYaml(definition, referenceKey, configVars) });
const configVars = Object.values((_a = definition.configPages) !== null && _a !== void 0 ? _a : {}).reduce((acc, configPage) => Object.entries(configPage.elements).reduce((acc, [key, element]) => {
// "string" elements are HTML elements and should be ignored.
if (typeof element === "string") {
return acc;
}
if (key in acc) {
throw new Error('Duplicate config var key "' + key + '"');
}
return Object.assign(Object.assign({}, acc), { [key]: element });
}, acc), {});
const cniComponent = codeNativeIntegrationComponent(definition, referenceKey, configVars);
const cniYaml = codeNativeIntegrationYaml(definition, referenceKey, configVars);
return Object.assign(Object.assign({}, cniComponent), { codeNativeIntegrationYAML: cniYaml });
};

@@ -42,6 +62,11 @@ exports.convertIntegration = convertIntegration;

tagline,
elements: Object.keys(elements).map((key) => ({
type: "configVar",
value: key,
})),
elements: Object.entries(elements).map(([key, value]) => typeof value === "string"
? {
type: "htmlElement",
value,
}
: {
type: "configVar",
value: key,
}),
}));

@@ -94,2 +119,44 @@ };

};
const permissionAndVisibilityTypeValueMap = {
customer: {
orgOnly: false,
visibleToOrgDeployer: true,
visibleToCustomerDeployer: true,
},
embedded: {
orgOnly: false,
visibleToOrgDeployer: true,
visibleToCustomerDeployer: false,
},
organization: {
orgOnly: true,
visibleToOrgDeployer: true,
visibleToCustomerDeployer: false,
},
};
const getPermissionAndVisibilityValues = ({ permissionAndVisibilityType = "customer", visibleToOrgDeployer = true, }) => {
return Object.assign(Object.assign({}, permissionAndVisibilityTypeValueMap[permissionAndVisibilityType]), (visibleToOrgDeployer !== undefined ? { visibleToOrgDeployer } : {}));
};
/** Converts permission and visibility properties into `meta` properties for inputs. */
const convertInputPermissionAndVisibility = ({ permissionAndVisibilityType, visibleToOrgDeployer, }) => {
const meta = getPermissionAndVisibilityValues({
permissionAndVisibilityType,
visibleToOrgDeployer,
});
return meta;
};
/** Converts permission and visibility properties into `meta` properties for config vars. */
const convertConfigVarPermissionAndVisibility = ({ permissionAndVisibilityType, visibleToOrgDeployer: visibleToOrgDeployerBase, }) => {
const { orgOnly, visibleToCustomerDeployer, visibleToOrgDeployer } = getPermissionAndVisibilityValues({
permissionAndVisibilityType,
visibleToOrgDeployer: visibleToOrgDeployerBase,
});
return {
orgOnly,
meta: {
visibleToCustomerDeployer,
visibleToOrgDeployer,
},
};
};
const convertComponentReference = (componentReference, componentRegistry) => {

@@ -115,3 +182,7 @@ var _a, _b, _c;

: value.value;
return Object.assign(Object.assign({}, result), { [key]: { type: type, value: valueExpr } });
const meta = convertInputPermissionAndVisibility((0, lodash_1.pick)(value, [
"permissionAndVisibilityType",
"visibleToOrgDeployer",
]));
return Object.assign(Object.assign({}, result), { [key]: { type: type, value: valueExpr, meta } });
}

@@ -216,11 +287,18 @@ if ("configVar" in value) {

const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
const meta = (0, lodash_1.pick)(configVar, [
"visibleToCustomerDeployer",
"visibleToOrgDeployer",
]);
const { orgOnly, meta } = convertConfigVarPermissionAndVisibility((0, lodash_1.pick)(configVar, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: {
const { stableKey, description } = (0, lodash_1.pick)(configVar, [
"stableKey",
"description",
]);
return {
stableKey,
description,
key,
dataType: "connection",
connection: {
key: (0, lodash_1.camelCase)(key),
component: codeNativeIntegrationComponentReference(referenceKey),
}, inputs: Object.entries(configVar.inputs).reduce((result, [key, input]) => {
},
inputs: Object.entries(configVar.inputs).reduce((result, [key, input]) => {
if (input.shown === false) {

@@ -234,12 +312,24 @@ return result;

} });
}, {}), meta });
}, {}),
orgOnly,
meta,
};
}
if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
const { ref, inputs } = convertComponentReference(configVar.connection, componentRegistry);
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: Object.assign(Object.assign({}, ref), { template: configVar.connection.template }), inputs });
const { stableKey = "", description, connection: { template }, } = (0, lodash_1.pick)(configVar, ["stableKey", "description", "connection"]);
return {
stableKey,
description,
key,
dataType: "connection",
connection: Object.assign(Object.assign({}, ref), { template }),
inputs,
orgOnly,
meta,
};
}
const result = (0, lodash_1.assign)({ meta, key }, (0, lodash_1.pick)(configVar, [
const result = (0, lodash_1.assign)({ orgOnly, meta, key }, (0, lodash_1.pick)(configVar, [
"stableKey",
"description",
"orgOnly",
"defaultValue",

@@ -293,13 +383,40 @@ "dataType",

.invoke;
const componentMethods = Object.entries(componentRegistry).reduce((acc, [componentKey, { actions, public: isPublic, signature }]) => {
return Object.assign(Object.assign({}, acc), { [componentKey]: Object.keys(actions).reduce((acc, actionKey) => (Object.assign(Object.assign({}, acc), { [actionKey]: (values) => {
return invoke({
component: {
key: componentKey,
signature: signature !== null && signature !== void 0 ? signature : "",
isPublic,
},
key: actionKey,
}, context, values);
} })), {}) });
// Construct the component methods from the component registry
const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature },]) => {
// Create an object to hold the methods for each action
const methods = Object.keys(actions).reduce((methodsAccumulator, actionKey) => {
const action = actions[actionKey];
// Define the method to be called for the action
methodsAccumulator[actionKey] = (values) => __awaiter(void 0, void 0, void 0, function* () {
// Transform the input values based on the action's inputs
const transformedValues = Object.entries(values).reduce((transformedAccumulator, [inputKey, inputValue]) => {
const { collection } = action.inputs[inputKey];
// Transform key-value list inputs
if (collection === "keyvaluelist" &&
Object.keys(inputValue).length) {
transformedAccumulator[inputKey] = Object.entries(inputValue).map(([keyItem, valueItem]) => ({
key: keyItem,
value: valueItem,
}));
}
else {
transformedAccumulator[inputKey] = inputValue;
}
return transformedAccumulator;
}, {});
// Invoke the action with the transformed values
return invoke({
component: {
key: componentKey,
signature: signature !== null && signature !== void 0 ? signature : "",
isPublic,
},
key: actionKey,
}, context, transformedValues);
});
return methodsAccumulator;
}, {});
// Add the methods to the accumulator under the registry component key
accumulator[registryComponentKey] = methods;
return accumulator;
}, {});

@@ -306,0 +423,0 @@ return onExecution(Object.assign(Object.assign({}, remainingContext), { components: componentMethods }), params);

@@ -58,3 +58,7 @@ /// <reference types="node" />

configVars: TConfigVars;
components: TComponentActions;
components: {
[K in keyof TComponentActions]: {
[A in keyof TComponentActions[K]]: TComponentActions[K][A]["perform"];
};
};
stepId: string;

@@ -61,0 +65,0 @@ executionId: string;

@@ -19,3 +19,7 @@ import { Inputs, ConfigVarResultCollection, ActionPerformReturn, ActionInputParameters, ActionLogger, InstanceAttributes, CustomerAttributes, UserAttributes, IntegrationAttributes, FlowAttributes, ComponentManifest } from ".";

/** Available component actions registered in the `componentRegistry`. */
components: TComponentActions;
components: {
[K in keyof TComponentActions]: {
[A in keyof TComponentActions[K]]: TComponentActions[K][A]["perform"];
};
};
/** A unique id that corresponds to the step on the Integration */

@@ -22,0 +26,0 @@ stepId: string;

@@ -10,5 +10,29 @@ export interface ComponentManifest {

}
export declare type ComponentManifestAction = (values: any) => Promise<unknown>;
export declare type ComponentManifestTrigger = (values: any) => Promise<unknown>;
export declare type ComponentManifestDataSource = (values: any) => Promise<unknown>;
export declare type ComponentManifestConnection = (values: any) => Promise<unknown>;
export interface ComponentManifestAction {
perform: (values: any) => Promise<unknown>;
inputs: Record<string, {
inputType: string;
collection: "keyvaluelist" | "valuelist" | null;
}>;
}
export interface ComponentManifestTrigger {
perform: (values: any) => Promise<unknown>;
inputs: Record<string, {
inputType: string;
collection: "keyvaluelist" | "valuelist" | null;
}>;
}
export interface ComponentManifestDataSource {
perform: (values: any) => Promise<unknown>;
inputs: Record<string, {
inputType: string;
collection: "keyvaluelist" | "valuelist" | null;
}>;
}
export interface ComponentManifestConnection {
perform: (values: any) => Promise<unknown>;
inputs: Record<string, {
inputType: string;
collection: "keyvaluelist" | "valuelist" | null;
}>;
}

@@ -103,2 +103,3 @@ import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule, CollectionDataSourceType, ComponentManifest } from ".";

}
export declare type PermissionAndVisibilityType = "customer" | "embedded" | "organization";
/** Common attribute shared by all types of Config Vars. */

@@ -110,8 +111,12 @@ declare type BaseConfigVar = {

description?: string;
/** Optional value that specifies whether this Config Var is only configurable by Organization users. @default false */
orgOnly?: boolean;
/**
* Optional value that sets the permission and visibility of the Config Var. @default "customer"
*
* "customer" - Customers can view and edit the Config Var.
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically.
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization.
*/
permissionAndVisibilityType?: PermissionAndVisibilityType;
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */
visibleToOrgDeployer?: boolean;
/** Optional value that specifies whether this Config Var is visible to a Customer deployer. @default true */
visibleToCustomerDeployer?: boolean;
/** Optional default value for the Config Var. */

@@ -150,2 +155,14 @@ defaultValue?: string;

} : never : never>;
interface ConnectionInputPermissionAndVisibility {
/**
* Optional value that sets the permission and visibility of the Config Var. @default "customer"
*
* "customer" - Customers can view and edit the Config Var.
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically.
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization.
*/
permissionAndVisibilityType?: PermissionAndVisibilityType;
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */
visibleToOrgDeployer?: boolean;
}
declare type ComponentReferenceType = Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections">;

@@ -156,3 +173,3 @@ declare type ComponentReferenceTypeValueMap<TValue, TMap extends Record<ComponentReferenceType, unknown> = {

dataSources: ValueExpression<TValue> | ConfigVarExpression;
connections: ValueExpression<TValue> | ConfigVarExpression;
connections: (ValueExpression<TValue> | ConfigVarExpression) & ConnectionInputPermissionAndVisibility;
}> = TMap;

@@ -186,3 +203,3 @@ export declare type ComponentReference<TComponentReference extends {

declare type ComponentReferencesByType = UnionToIntersection<ComponentReferenceType extends infer TComponentReferenceType ? TComponentReferenceType extends Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections"> ? {
[Key in TComponentReferenceType]: keyof ComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof ComponentRegistry ? TComponentKey extends string ? TComponentReferenceType extends keyof ComponentRegistry[TComponentKey] ? keyof ComponentRegistry[TComponentKey][TComponentReferenceType] extends infer TComponentPropertyKey ? TComponentPropertyKey extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType] ? TComponentPropertyKey extends string ? ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey] extends (...args: any[]) => any ? Parameters<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]>[0] extends infer TInputs ? ComponentReference<{
[Key in TComponentReferenceType]: keyof ComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof ComponentRegistry ? TComponentKey extends string ? TComponentReferenceType extends keyof ComponentRegistry[TComponentKey] ? keyof ComponentRegistry[TComponentKey][TComponentReferenceType] extends infer TComponentPropertyKey ? TComponentPropertyKey extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType] ? TComponentPropertyKey extends string ? "perform" extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey] ? ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]["perform"] extends (...args: any[]) => any ? Parameters<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]["perform"]>[0] extends infer TInputs ? ComponentReference<{
component: TComponentKey;

@@ -194,3 +211,3 @@ isPublic: ComponentRegistry[TComponentKey]["public"];

};
}> : never : never : never : never : never : never : never : never : never;
}> : never : never : never : never : never : never : never : never : never : never;
} : never : never>;

@@ -197,0 +214,0 @@ export declare type TriggerReference = ComponentReferencesByType["triggers"];

{
"name": "@prismatic-io/spectral",
"version": "9.0.0-rc.4",
"version": "9.0.0-rc.5",
"description": "Utility library for building Prismatic components",

@@ -5,0 +5,0 @@ "keywords": [

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