@prismatic-io/spectral 9.0.0-rc.8 → 9.0.0-rc.9

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,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getImports = void 0;
4
4
  const getImports = ({ inputs }) => {
5
5
  return inputs.reduce((acc, input) => {
6
- if (typeof input.type === "string") {
6
+ if (typeof input.valueType === "string") {
7
7
  return acc;
8
8
  }
9
- return Object.assign(Object.assign({}, acc), { [input.type.module]: acc[input.type.module]
10
- ? !acc[input.type.module].includes(input.type.type)
11
- ? [...acc[input.type.module], input.type.type]
12
- : acc[input.type.module]
13
- : [input.type.type] });
9
+ return Object.assign(Object.assign({}, acc), { [input.valueType.module]: acc[input.valueType.module]
10
+ ? !acc[input.valueType.module].includes(input.valueType.type)
11
+ ? [...acc[input.valueType.module], input.valueType.type]
12
+ : acc[input.valueType.module]
13
+ : [input.valueType.type] });
14
14
  }, {});
15
15
  };
16
16
  exports.getImports = getImports;
@@ -6,14 +6,15 @@ declare type ServerTypeInput = InputBase & {
6
6
  export interface Input {
7
7
  key: string;
8
8
  label: string;
9
- type: InputType;
9
+ inputType: string;
10
+ valueType: ValueType;
10
11
  required: boolean | undefined;
11
12
  properties: {
12
13
  key: keyof ServerTypeInput;
13
14
  value: string;
14
15
  }[];
15
16
  }
16
- export declare type InputType = string | {
17
+ export declare type ValueType = string | {
17
18
  type: string;
18
19
  module: string;
19
20
  };
@@ -28,5 +29,5 @@ interface GetInputsProps {
28
29
  docBlock: DocBlock;
29
30
  }
30
31
  export declare const getInputs: ({ inputs, docBlock }: GetInputsProps) => Input[];
31
- export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], InputType>;
32
+ export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], ValueType>;
32
33
  export {};
@@ -6,11 +6,11 @@ const getInputs = ({ inputs, docBlock }) => {
6
6
  return {
7
7
  key: input.key,
8
8
  label: input.label,
9
- type: getInputType(input),
9
+ inputType: input.type,
10
+ valueType: getInputValueType(input),
10
11
  required: input.required,
11
12
  collection: input.collection,
12
- inputType: input.type,
13
- onPremiseControlled: input.onPremiseControlled || input.onPremControlled,
13
+ onPremControlled: input.onPremiseControlled || input.onPremControlled,
14
14
  properties: docBlock.reduce((acc, { propertyKey, inputKey, propertyValue, output }) => {
15
15
  if (inputKey && inputKey !== input.key) {
16
16
  return acc;
@@ -77,12 +77,12 @@ exports.INPUT_TYPE_MAP = {
77
77
  dynamicObjectSelection: "string",
78
78
  dynamicFieldSelection: "string",
79
79
  };
80
- const getInputType = (input) => {
80
+ const getInputValueType = (input) => {
81
81
  const valueType = input.model
82
82
  ? input.model.map((choice) => `"${choice.value}"`).join(" | ")
83
83
  : exports.INPUT_TYPE_MAP[input.type] || "never";
84
84
  if (input.collection === "keyvaluelist") {
85
- return `Record<string, ${valueType}>`;
85
+ return `Record<string, ${valueType}> | Array<{key: string, value: ${valueType}}>`;
86
86
  }
87
87
  if (input.collection === "valuelist") {
88
88
  return `${valueType}[]`;
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeComponentManifest = void 0;
4
- const fs_extra_1 = require("fs-extra");
4
+ const fs_1 = require("fs");
5
5
  const removeComponentManifest = ({ destinationDir, verbose, }) => {
6
6
  if (verbose) {
7
7
  console.info("Removing existing component manifest files...");
8
8
  }
9
9
  try {
10
- (0, fs_extra_1.removeSync)(destinationDir);
10
+ if ((0, fs_1.existsSync)(destinationDir)) {
11
+ (0, fs_1.rmSync)(destinationDir, { recursive: true, force: true });
12
+ }
11
13
  }
12
14
  catch (err) {
13
15
  console.error(err);
@@ -1,6 +1,7 @@
1
1
  <% inputs.forEach((input) => { -%>
2
2
  <%= input.key %>: {
3
- inputType: "<%= input.defaultType %>",
3
+ valueType: "<%- input.valueType.type ? input.valueType.type : input.valueType %>",
4
+ inputType: "<%= input.inputType %>",
4
5
  <%_ if (input.collection) { -%>
5
6
  collection: "<%= input.collection %>" as const,
6
7
  <%_ } else { -%>
@@ -6,5 +6,5 @@
6
6
  * @<%= property.key %> <%- property.value %>
7
7
  <%_ }); -%>
8
8
  */
9
- <%= input.key %><%= input.required ? "" : "?" %>: <%- input.type.type ? input.type.type : input.type %>;
9
+ <%= input.key %><%= input.required ? "" : "?" %>: <%- input.valueType.type ? input.valueType.type : input.valueType %>;
10
10
  <% }); -%>
@@ -388,6 +388,13 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
388
388
  // Transform the input values based on the action's inputs
389
389
  const transformedValues = Object.entries(values).reduce((transformedAccumulator, [inputKey, inputValue]) => {
390
390
  const { collection } = action.inputs[inputKey];
391
+ if (collection === "keyvaluelist" &&
392
+ Array.isArray(inputValue)) {
393
+ transformedAccumulator[inputKey] = inputValue.reduce((acc, { key, value }) => {
394
+ return [...acc, { key, value }];
395
+ }, []);
396
+ return transformedAccumulator;
397
+ }
391
398
  // Transform key-value list inputs
392
399
  if (collection === "keyvaluelist" &&
393
400
  Object.keys(inputValue).length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "9.0.0-rc.8",
3
+ "version": "9.0.0-rc.9",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"