@prismatic-io/spectral 10.11.0 → 10.11.1

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.
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INPUT_TYPE_MAP = exports.getInputs = void 0;
4
4
  const escapeSpecialCharacters_1 = require("../utils/escapeSpecialCharacters");
5
5
  const docBlock_1 = require("./docBlock");
6
- const getDefaultValue = (value) => {
6
+ const getDefaultValue = (value, isCollection) => {
7
7
  if (value === undefined || value === "") {
8
- return value;
8
+ return isCollection ? [] : value;
9
9
  }
10
10
  const stringValue = typeof value === "string" ? value : JSON.stringify(value);
11
11
  return (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(stringValue);
@@ -29,7 +29,7 @@ const getInputs = ({ inputs, docBlock = docBlock_1.DOC_BLOCK_DEFAULT }) => {
29
29
  collection: input.collection,
30
30
  onPremControlled: input.onPremiseControlled || input.onPremControlled,
31
31
  docBlock: docBlock(input),
32
- default: getDefaultValue(input.default),
32
+ default: getDefaultValue(input.default, Boolean(input.collection)),
33
33
  },
34
34
  ];
35
35
  }, []);
@@ -6,7 +6,9 @@
6
6
  <%_ } else { -%>
7
7
  collection: undefined,
8
8
  <%_ } -%>
9
- <%_ if (typeof input.default !== 'undefined') { -%>
9
+ <%_ if (Array.isArray(input.default)) { -%>
10
+ default: <%- JSON.stringify(input.default) %>,
11
+ <%_ } else if (typeof input.default !== 'undefined') { -%>
10
12
  default: `<%- input.default %>`,
11
13
  <%_ } else { -%>
12
14
  default: undefined,
@@ -211,15 +211,16 @@ const convertComponentReference = (componentReference, componentRegistry, refere
211
211
  };
212
212
  const inputs = Object.entries(manifestEntry.inputs).reduce((result, [key, manifestEntryInput]) => {
213
213
  var _a, _b, _c;
214
+ const isCollection = Boolean(manifestEntryInput.collection);
214
215
  // Retrieve the input value or default to the manifest's default value
215
216
  const value = (_b = (_a = componentReference.values) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : {
216
- value: (_c = manifestEntryInput.default) !== null && _c !== void 0 ? _c : "",
217
+ value: isCollection
218
+ ? manifestEntryInput.default === ""
219
+ ? []
220
+ : manifestEntryInput.default
221
+ : (_c = manifestEntryInput.default) !== null && _c !== void 0 ? _c : "",
217
222
  };
218
- const type = manifestEntryInput.collection
219
- ? "complex"
220
- : "value" in value
221
- ? "value"
222
- : "configVar";
223
+ const type = isCollection ? "complex" : "value" in value ? "value" : "configVar";
223
224
  if ("value" in value) {
224
225
  const valueExpr = manifestEntryInput.collection === "keyvaluelist" && value.value instanceof Object
225
226
  ? Object.entries(value.value).map(([k, v]) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.11.0",
3
+ "version": "10.11.1",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",