@prismatic-io/spectral 9.1.2 → 9.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ const createActions = (_a) => __awaiter(void 0, [_a], void 0, function* ({ compo
48
48
  typeInterface: (0, createTypeInterface_1.createTypeInterface)((_b = action.key) !== null && _b !== void 0 ? _b : actionKey),
49
49
  import: (0, createImport_1.createImport)((_c = action.key) !== null && _c !== void 0 ? _c : actionKey),
50
50
  key: action.key || actionKey,
51
- label: action.display.description,
51
+ label: action.display.label,
52
52
  description: action.display.description,
53
53
  inputs,
54
54
  },
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addPunctuation = exports.addLine = exports.DOC_BLOCK_DEFAULT = void 0;
4
+ const escapeSpecialCharacters_1 = require("../utils/escapeSpecialCharacters");
4
5
  const DOC_BLOCK_DEFAULT = (input) => {
5
6
  const comments = (0, exports.addPunctuation)(input.comments);
6
7
  const onPrem = input.onPremControlled || input.onPremiseControlled
@@ -23,9 +24,9 @@ const addLine = ({ key, value, raw }) => {
23
24
  if (typeof value === "undefined" || value === null || value === "") {
24
25
  return "";
25
26
  }
26
- const sanitizedValue = JSON.stringify(value)
27
+ const sanitizedValue = (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(JSON.stringify(value)
27
28
  .replace(/(^"|"$)|(^'|'$)/g, "")
28
- .trim();
29
+ .trim());
29
30
  return ` * ${key ? `@${key} ${sanitizedValue}` : sanitizedValue}\n`;
30
31
  };
31
32
  exports.addLine = addLine;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INPUT_TYPE_MAP = exports.getInputs = void 0;
4
+ const escapeSpecialCharacters_1 = require("../utils/escapeSpecialCharacters");
4
5
  const docBlock_1 = require("./docBlock");
5
6
  const getDefaultValue = (value) => {
6
- if (value === undefined || value === "" || typeof value === "string") {
7
+ if (value === undefined || value === "") {
7
8
  return value;
8
9
  }
9
- return JSON.stringify(value);
10
+ const stringValue = typeof value === "string" ? value : JSON.stringify(value);
11
+ return (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(stringValue);
10
12
  };
11
13
  const getInputs = ({ inputs, docBlock = docBlock_1.DOC_BLOCK_DEFAULT }) => {
12
14
  return inputs.reduce((acc, input) => {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This regex targets common characters that may be included in default
3
+ * input values (code comment blocks, backticks, etc) and would cause
4
+ * component-manifest build issues. More characters may be added
5
+ * as discovered.
6
+ */
7
+ export declare const escapeSpecialCharacters: (value?: string) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * This regex targets common characters that may be included in default
4
+ * input values (code comment blocks, backticks, etc) and would cause
5
+ * component-manifest build issues. More characters may be added
6
+ * as discovered.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.escapeSpecialCharacters = void 0;
10
+ const escapeRegEx = /(\/|\\|\`|\$)/g;
11
+ const escapeSpecialCharacters = (value = "") => {
12
+ return value.replace(escapeRegEx, "\\$&");
13
+ };
14
+ exports.escapeSpecialCharacters = escapeSpecialCharacters;
@@ -1,3 +1,6 @@
1
- import { IntegrationDefinition } from "../types";
1
+ import { IntegrationDefinition, ConfigVar, ComponentRegistry } from "../types";
2
2
  import { Component as ServerComponent } from ".";
3
+ import { RequiredConfigVariable as ServerRequiredConfigVariable } from "./integration";
3
4
  export declare const convertIntegration: (definition: IntegrationDefinition) => ServerComponent;
5
+ /** Converts a Config Var into the structure necessary for YAML generation. */
6
+ export declare const convertConfigVar: (key: string, configVar: ConfigVar, referenceKey: string, componentRegistry: ComponentRegistry) => ServerRequiredConfigVariable;
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.convertIntegration = void 0;
26
+ exports.convertConfigVar = exports.convertIntegration = void 0;
27
27
  const yaml_1 = __importDefault(require("yaml"));
28
28
  const uuid_1 = require("uuid");
29
29
  const lodash_1 = require("lodash");
@@ -99,7 +99,7 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
99
99
  documentation,
100
100
  version,
101
101
  labels,
102
- requiredConfigVars: Object.entries(configVars || {}).map(([key, configVar]) => convertConfigVar(key, configVar, referenceKey, componentRegistry)),
102
+ requiredConfigVars: Object.entries(configVars || {}).map(([key, configVar]) => (0, exports.convertConfigVar)(key, configVar, referenceKey, componentRegistry)),
103
103
  endpointType,
104
104
  preprocessFlowName: hasPreprocessFlow ? preprocessFlows[0].name : undefined,
105
105
  externalCustomerIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerIdField),
@@ -328,10 +328,24 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
328
328
  return result;
329
329
  }
330
330
  const meta = convertInputPermissionAndVisibility((0, lodash_1.pick)(input, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
331
- const defaultValue = input.collection ? [] : "";
331
+ const defaultValue = input.collection
332
+ ? (input.default || []).map((defaultValue) => {
333
+ if (typeof defaultValue === "string") {
334
+ return {
335
+ type: "value",
336
+ value: defaultValue,
337
+ };
338
+ }
339
+ return {
340
+ name: defaultValue.key,
341
+ type: "value",
342
+ value: defaultValue.value,
343
+ };
344
+ })
345
+ : input.default || "";
332
346
  return Object.assign(Object.assign({}, result), { [key]: {
333
347
  type: input.collection ? "complex" : "value",
334
- value: input.default || defaultValue,
348
+ value: defaultValue,
335
349
  meta,
336
350
  } });
337
351
  }, {}),
@@ -395,6 +409,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
395
409
  }
396
410
  return result;
397
411
  };
412
+ exports.convertConfigVar = convertConfigVar;
398
413
  /** Maps the step name field to a fully qualified input. */
399
414
  const fieldNameToReferenceInput = (stepName, fieldName) => fieldName ? { type: "reference", value: `${stepName}.results.${fieldName}` } : undefined;
400
415
  /** Actions and Triggers will be scoped to their flow by combining the flow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "9.1.2",
3
+ "version": "9.1.3",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",