@prismatic-io/spectral
Advanced tools
Comparing version 9.0.0-rc.7 to 9.0.0-rc.8
@@ -29,22 +29,3 @@ "use strict"; | ||
const componentDistDir = path_1.default.join(componentDir, "dist", "index.js"); | ||
if (!componentDir) { | ||
console.error("Please run this script using npm or yarn."); | ||
process.exit(1); | ||
} | ||
if (!(0, fs_extra_1.existsSync)(componentDistDir)) { | ||
console.error("Component build directory `dist` does not exist. Please verify that the component has been built."); | ||
process.exit(1); | ||
} | ||
const component = require(componentDistDir).default; | ||
if (!component || | ||
!(0, util_1.isObjectWithTruthyKeys)(component, ["key", "display"]) || | ||
!(0, util_1.isObjectWithOneTruthyKey)(component, [ | ||
"actions", | ||
"connections", | ||
"dataSources", | ||
])) { | ||
console.error("Component is invalid."); | ||
process.exit(1); | ||
} | ||
const args = process.argv.slice(3); | ||
const args = process.argv.slice(2); | ||
const flags = { | ||
@@ -115,2 +96,21 @@ name: { | ||
} | ||
if (!componentDir) { | ||
console.error("Please run this script using npm or yarn."); | ||
process.exit(1); | ||
} | ||
if (!(0, fs_extra_1.existsSync)(componentDistDir)) { | ||
console.error("Component build directory `dist` does not exist. Please verify that the component has been built."); | ||
process.exit(1); | ||
} | ||
const component = require(componentDistDir).default; | ||
if (!component || | ||
!(0, util_1.isObjectWithTruthyKeys)(component, ["key", "display"]) || | ||
!(0, util_1.isObjectWithOneTruthyKey)(component, [ | ||
"actions", | ||
"connections", | ||
"dataSources", | ||
])) { | ||
console.error("Component is invalid."); | ||
process.exit(1); | ||
} | ||
const packageJson = (0, fs_extra_1.readJsonSync)(path_1.default.join(__dirname, "../../../package.json")); | ||
@@ -117,0 +117,0 @@ yield (0, index_1.createComponentManifest)({ |
@@ -1,2 +0,2 @@ | ||
import { Component } from "../../serverTypes"; | ||
import type { Component } from "../../serverTypes"; | ||
interface CreateActionsProps { | ||
@@ -3,0 +3,0 @@ component: Component; |
@@ -21,7 +21,15 @@ "use strict"; | ||
const createTemplate_1 = require("../utils/createTemplate"); | ||
const DOCUMENT_PROPERTIES = [ | ||
"comments", | ||
"default", | ||
"example", | ||
"placeholder", | ||
const DOC_BLOCK = [ | ||
{ | ||
propertyKey: "comments", | ||
}, | ||
{ | ||
propertyKey: "default", | ||
}, | ||
{ | ||
propertyKey: "example", | ||
}, | ||
{ | ||
propertyKey: "placeholder", | ||
}, | ||
]; | ||
@@ -47,3 +55,3 @@ const createActions = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
inputs: action.inputs, | ||
documentProperties: DOCUMENT_PROPERTIES, | ||
docBlock: DOC_BLOCK, | ||
}); | ||
@@ -50,0 +58,0 @@ const imports = (0, getImports_1.getImports)({ inputs }); |
@@ -1,2 +0,2 @@ | ||
import { Component } from "../../serverTypes"; | ||
import type { Component } from "../../serverTypes"; | ||
interface CreateConnectionsProps { | ||
@@ -3,0 +3,0 @@ component: Component; |
@@ -21,7 +21,25 @@ "use strict"; | ||
const createTemplate_1 = require("../utils/createTemplate"); | ||
const DOCUMENT_PROPERTIES = [ | ||
"comments", | ||
"default", | ||
"example", | ||
"placeholder", | ||
const DOC_BLOCK = [ | ||
{ | ||
propertyKey: "comments", | ||
}, | ||
{ | ||
propertyKey: "default", | ||
}, | ||
{ | ||
propertyKey: "example", | ||
}, | ||
{ | ||
propertyKey: "placeholder", | ||
}, | ||
{ | ||
propertyKey: "onPremControlled", | ||
propertyValue: true, | ||
output: "This input will be supplied when using an on prem resource.", | ||
}, | ||
{ | ||
propertyKey: "onPremiseControlled", | ||
propertyValue: true, | ||
output: "This input will be supplied when using an on prem resource.", | ||
}, | ||
]; | ||
@@ -47,5 +65,6 @@ const createConnections = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
inputs: connection.inputs, | ||
documentProperties: DOCUMENT_PROPERTIES, | ||
docBlock: DOC_BLOCK, | ||
}); | ||
const imports = (0, getImports_1.getImports)({ inputs }); | ||
const onPremAvailable = connection.inputs.some((input) => input.onPremControlled || input.onPremiseControlled); | ||
return yield renderConnection({ | ||
@@ -57,2 +76,3 @@ connection: { | ||
inputs, | ||
onPremAvailable, | ||
}, | ||
@@ -59,0 +79,0 @@ imports, |
@@ -1,2 +0,2 @@ | ||
import { Component } from "../../serverTypes"; | ||
import type { Component } from "../../serverTypes"; | ||
interface CreateDataSourcesProps { | ||
@@ -3,0 +3,0 @@ component: Component; |
@@ -21,7 +21,15 @@ "use strict"; | ||
const createTemplate_1 = require("../utils/createTemplate"); | ||
const DOCUMENT_PROPERTIES = [ | ||
"comments", | ||
"default", | ||
"example", | ||
"placeholder", | ||
const DOC_BLOCK = [ | ||
{ | ||
propertyKey: "comments", | ||
}, | ||
{ | ||
propertyKey: "default", | ||
}, | ||
{ | ||
propertyKey: "example", | ||
}, | ||
{ | ||
propertyKey: "placeholder", | ||
}, | ||
]; | ||
@@ -47,3 +55,3 @@ const createDataSources = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
inputs: dataSource.inputs, | ||
documentProperties: DOCUMENT_PROPERTIES, | ||
docBlock: DOC_BLOCK, | ||
}); | ||
@@ -50,0 +58,0 @@ const imports = (0, getImports_1.getImports)({ inputs }); |
@@ -1,2 +0,2 @@ | ||
import { Component } from "../../serverTypes"; | ||
import type { Component } from "../../serverTypes"; | ||
export interface PackageDependencies { | ||
@@ -3,0 +3,0 @@ spectral: string; |
@@ -1,2 +0,2 @@ | ||
import { Component } from "../../serverTypes"; | ||
import type { Component } from "../../serverTypes"; | ||
interface CreateTriggersProps { | ||
@@ -3,0 +3,0 @@ component: Component; |
@@ -21,7 +21,15 @@ "use strict"; | ||
const createTemplate_1 = require("../utils/createTemplate"); | ||
const DOCUMENT_PROPERTIES = [ | ||
"comments", | ||
"default", | ||
"example", | ||
"placeholder", | ||
const DOC_BLOCK = [ | ||
{ | ||
propertyKey: "comments", | ||
}, | ||
{ | ||
propertyKey: "default", | ||
}, | ||
{ | ||
propertyKey: "example", | ||
}, | ||
{ | ||
propertyKey: "placeholder", | ||
}, | ||
]; | ||
@@ -47,3 +55,3 @@ const createTriggers = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
inputs: trigger.inputs, | ||
documentProperties: DOCUMENT_PROPERTIES, | ||
docBlock: DOC_BLOCK, | ||
}); | ||
@@ -50,0 +58,0 @@ const imports = (0, getImports_1.getImports)({ inputs }); |
@@ -1,2 +0,2 @@ | ||
import { Input } from "./getInputs"; | ||
import type { Input } from "./getInputs"; | ||
export declare type Imports = Record<string, string[]>; | ||
@@ -3,0 +3,0 @@ interface GetImportsProps { |
@@ -1,3 +0,6 @@ | ||
import { Input as ServerTypeInput } from "../../serverTypes"; | ||
import { InputFieldDefinition } from "../../types/Inputs"; | ||
import type { Input as InputBase } from "../../serverTypes"; | ||
import type { InputFieldDefinition } from "../../types/Inputs"; | ||
declare type ServerTypeInput = InputBase & { | ||
onPremControlled?: boolean; | ||
}; | ||
export interface Input { | ||
@@ -17,8 +20,14 @@ key: string; | ||
}; | ||
export declare type DocBlock = { | ||
inputKey?: string; | ||
propertyKey: keyof ServerTypeInput; | ||
propertyValue?: unknown; | ||
output?: string; | ||
}[]; | ||
interface GetInputsProps { | ||
inputs: ServerTypeInput[]; | ||
documentProperties: (keyof ServerTypeInput)[]; | ||
docBlock: DocBlock; | ||
} | ||
export declare const getInputs: ({ inputs, documentProperties, }: GetInputsProps) => Input[]; | ||
export declare const getInputs: ({ inputs, docBlock }: GetInputsProps) => Input[]; | ||
export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], InputType>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.INPUT_TYPE_MAP = exports.getInputs = void 0; | ||
const getInputs = ({ inputs, documentProperties, }) => { | ||
const getInputs = ({ inputs, docBlock }) => { | ||
return inputs.map((input) => { | ||
@@ -13,16 +13,32 @@ return { | ||
inputType: input.type, | ||
properties: documentProperties.reduce((acc, key) => { | ||
const value = input[key] | ||
? JSON.stringify(input[key]) | ||
.replace(/(^"|"$)|(^'|'$)/g, "") | ||
.trim() | ||
: null; | ||
if (typeof value === "undefined" || value === null || value === "") { | ||
onPremiseControlled: input.onPremiseControlled || input.onPremControlled, | ||
properties: docBlock.reduce((acc, { propertyKey, inputKey, propertyValue, output }) => { | ||
if (inputKey && inputKey !== input.key) { | ||
return acc; | ||
} | ||
if (output && | ||
(input[propertyKey] === propertyValue || | ||
typeof propertyValue === "undefined")) { | ||
return [ | ||
...acc, | ||
{ | ||
key: propertyKey, | ||
value: output, | ||
}, | ||
]; | ||
} | ||
if (typeof input[propertyKey] === "undefined" || | ||
input[propertyKey] === null || | ||
input[propertyKey] === "" || | ||
(typeof propertyValue !== "undefined" && | ||
input[propertyKey] !== propertyValue)) { | ||
return acc; | ||
} | ||
return [ | ||
...acc, | ||
{ | ||
key, | ||
value, | ||
key: propertyKey, | ||
value: JSON.stringify(input[propertyKey]) | ||
.replace(/(^"|"$)|(^'|'$)/g, "") | ||
.trim(), | ||
}, | ||
@@ -29,0 +45,0 @@ ]; |
@@ -1,3 +0,3 @@ | ||
import { PackageDependencies } from "./createStaticFiles"; | ||
import { Component } from "../../serverTypes"; | ||
import { type PackageDependencies } from "./createStaticFiles"; | ||
import type { Component } from "../../serverTypes"; | ||
interface CreateComponentManifestProps { | ||
@@ -4,0 +4,0 @@ component: Component; |
@@ -1,2 +0,2 @@ | ||
import { Imports } from "../componentManifest/getImports"; | ||
import type { Imports } from "../componentManifest/getImports"; | ||
export interface CreateDependencyImportsProps { | ||
@@ -3,0 +3,0 @@ imports: Imports; |
@@ -163,12 +163,13 @@ "use strict"; | ||
const convertComponentReference = (componentReference, componentRegistry) => { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
const manifest = componentRegistry[componentReference.component]; | ||
const ref = { | ||
component: { | ||
key: componentReference.component, | ||
signature: (_b = (_a = componentRegistry[componentReference.component]) === null || _a === void 0 ? void 0 : _a.signature) !== null && _b !== void 0 ? _b : "", | ||
isPublic: componentReference.isPublic, | ||
key: manifest.key, | ||
signature: (_a = manifest.signature) !== null && _a !== void 0 ? _a : "", | ||
isPublic: manifest.public, | ||
}, | ||
key: componentReference.key, | ||
}; | ||
const inputs = Object.entries((_c = componentReference.values) !== null && _c !== void 0 ? _c : {}).reduce((result, [key, value]) => { | ||
const inputs = Object.entries((_b = componentReference.values) !== null && _b !== void 0 ? _b : {}).reduce((result, [key, value]) => { | ||
if ("value" in value) { | ||
@@ -175,0 +176,0 @@ const type = value.value instanceof Object ? "complex" : "value"; |
{ | ||
"name": "@prismatic-io/spectral", | ||
"version": "9.0.0-rc.7", | ||
"version": "9.0.0-rc.8", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
297486
6286