@prismatic-io/spectral 8.1.6 → 8.1.7

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.
@@ -93,7 +93,15 @@ const convertComponentReference = ({ key, component: componentRef, values, }) =>
93
93
  };
94
94
  const inputs = Object.entries(values !== null && values !== void 0 ? values : {}).reduce((result, [key, value]) => {
95
95
  if ("value" in value) {
96
- return Object.assign(Object.assign({}, result), { [key]: { type: "value", value: value.value } });
96
+ const type = value.value instanceof Object ? "complex" : "value";
97
+ const valueExpr = value.value instanceof Object && !Array.isArray(value.value)
98
+ ? Object.entries(value.value).map(([k, v]) => ({
99
+ name: { type: "value", value: k },
100
+ type: "value",
101
+ value: v,
102
+ }))
103
+ : value.value;
104
+ return Object.assign(Object.assign({}, result), { [key]: { type: type, value: valueExpr } });
97
105
  }
98
106
  if ("configVar" in value) {
99
107
  return Object.assign(Object.assign({}, result), { [key]: { type: "configVar", value: value.configVar } });
@@ -185,12 +193,11 @@ const convertConfigVar = (key, configVar, referenceKey) => {
185
193
  if (input.shown === false) {
186
194
  return result;
187
195
  }
188
- const value = input.default
189
- ? input.default
190
- : input.collection
191
- ? []
192
- : "";
193
- return Object.assign(Object.assign({}, result), { [key]: { type: "value", value } });
196
+ const defaultValue = input.collection ? [] : "";
197
+ return Object.assign(Object.assign({}, result), { [key]: {
198
+ type: input.collection ? "complex" : "value",
199
+ value: input.default || defaultValue,
200
+ } });
194
201
  }, {}), meta });
195
202
  }
196
203
  if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
@@ -9,12 +9,12 @@ export interface ComponentReference {
9
9
  template?: string;
10
10
  }
11
11
  export declare type Input = {
12
- name?: string;
12
+ name?: string | Input;
13
13
  type: "value" | "reference" | "configVar" | "template";
14
14
  value: string;
15
15
  meta?: Record<string, unknown>;
16
16
  } | {
17
- name?: string;
17
+ name?: string | Input;
18
18
  type: "complex";
19
19
  value: string | Input;
20
20
  meta?: Record<string, unknown>;
@@ -16,6 +16,7 @@ declare type DataSourceTypeMap = {
16
16
  jsonForm: JSONForm;
17
17
  };
18
18
  export declare type DataSourceType = keyof DataSourceTypeMap;
19
+ export declare type CollectionDataSourceType = Exclude<DataSourceType, "objectSelection" | "objectFieldMap" | "jsonForm">;
19
20
  export declare type DataSourceResultType = DataSourceTypeMap[DataSourceType];
20
21
  /** Represents the result of a Data Source action. */
21
22
  export declare type DataSourceResult<TDataSourceType extends DataSourceType> = {
@@ -1,4 +1,4 @@
1
- import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule } from ".";
1
+ import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule, CollectionDataSourceType } from ".";
2
2
  import { Prettify, UnionToIntersection, ValueOf } from "./utils";
3
3
  export declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string;
4
4
  export declare type ElementToRuntimeType<TElement extends ConfigPageElement<any>> = TElement extends ConnectionConfigVar<any> ? Connection : TElement extends DataSourceConfigVar<any> ? ToDataSourceRuntimeType<TElement["dataSourceType"]> : TElement extends ScheduleConfigVar ? Schedule : TElement extends StandardConfigVar ? string : never;
@@ -87,21 +87,27 @@ declare type BaseConfigVar = {
87
87
  visibleToOrgDeployer?: boolean;
88
88
  /** Optional value that specifies whether this Config Var is visible to a Customer deployer. @default true */
89
89
  visibleToCustomerDeployer?: boolean;
90
+ /** Optional default value for the Config Var. */
91
+ defaultValue?: string;
92
+ /** Optional list of picklist values if the Config Var is a multi-choice selection value. */
93
+ pickList?: string[];
94
+ /** Optional value to specify the type of collection if the Config Var is multi-value. */
95
+ collectionType?: CollectionType;
90
96
  };
91
97
  /** Defines attributes of a standard Config Var. */
92
98
  export declare type StandardConfigVar = BaseConfigVar & {
93
99
  /** The data type of the Config Var. */
94
- dataType: Exclude<ConfigVarDataType, "schedule">;
100
+ dataType: Exclude<ConfigVarDataType, "schedule" | "code">;
101
+ };
102
+ export declare type CodeConfigVar = BaseConfigVar & {
103
+ /** The data type of the Config Var. */
104
+ dataType: "code";
95
105
  /** Optional default value for the Config Var. */
96
106
  defaultValue?: string;
97
- /** Optional list of picklist values if the Config Var is a multi-choice selection value. */
98
- pickList?: string[];
99
107
  /** Optional value to specify the type of language if the Config Var is a code value. */
100
108
  codeLanguage?: CodeLanguageType;
101
- /** Optional value to specify the type of collection if the Config Var is multi-value. */
102
- collectionType?: CollectionType;
103
109
  };
104
- export declare type ScheduleConfigVar = BaseConfigVar & {
110
+ export declare type ScheduleConfigVar = Omit<BaseConfigVar, "collectionType"> & {
105
111
  /** The data type of the Config Var. */
106
112
  dataType: "schedule";
107
113
  /** Optional default value for the Config Var. */
@@ -109,22 +115,28 @@ export declare type ScheduleConfigVar = BaseConfigVar & {
109
115
  /** Optional timezone for the schedule. */
110
116
  timeZone?: string;
111
117
  };
112
- declare type DataSourceDefinitionConfigVar = BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload">;
113
- declare type DataSourceReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
114
- dataSourceType: DataSourceType;
118
+ declare type BaseDataSourceConfigVar = ({
119
+ dataSourceType: CollectionDataSourceType;
120
+ } & BaseConfigVar) | ({
121
+ dataSourceType: Exclude<DataSourceType, CollectionDataSourceType>;
122
+ } & Omit<BaseConfigVar, "collectionType">);
123
+ declare type DataSourceDefinitionConfigVar = BaseDataSourceConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload" | "dataSourceType" | "detailDataSource">;
124
+ declare type DataSourceReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseDataSourceConfigVar & {
115
125
  dataSource: ToComponentReferences<"dataSource", TComponents, ConfigPages<TComponents>>;
116
126
  };
117
127
  /** Defines attributes of a data source Config Var. */
118
128
  export declare type DataSourceConfigVar<TComponents extends ComponentSelector<any>> = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar<TComponents>;
119
- declare type ConnectionDefinitionConfigVar = BaseConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
120
- declare type ConnectionReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
129
+ declare type BaseConnectionConfigVar = Omit<BaseConfigVar, "collectionType">;
130
+ declare type ConnectionDefinitionConfigVar = BaseConnectionConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
131
+ declare type ConnectionReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConnectionConfigVar & {
121
132
  connection: ToComponentReferences<"connection", TComponents> & {
122
133
  template?: string;
123
134
  };
124
135
  };
125
136
  /** Defines attributes of a Config Var that represents a Connection. */
126
137
  export declare type ConnectionConfigVar<TComponents extends ComponentSelector<any>> = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar<TComponents>;
127
- export declare type ConfigVar<TComponents extends ComponentSelector<any>> = StandardConfigVar | ScheduleConfigVar | DataSourceConfigVar<TComponents> | ConnectionConfigVar<TComponents>;
138
+ export declare type ConfigVar<TComponents extends ComponentSelector<any>> = StandardConfigVar | CodeConfigVar | ScheduleConfigVar | DataSourceConfigVar<TComponents> | ConnectionConfigVar<TComponents>;
139
+ export declare const isCodeConfigVar: (cv: ConfigVar<any>) => cv is CodeConfigVar;
128
140
  export declare const isScheduleConfigVar: (cv: ConfigVar<any>) => cv is ScheduleConfigVar;
129
141
  export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar<any>) => cv is DataSourceDefinitionConfigVar;
130
142
  export declare const isDataSourceReferenceConfigVar: <TComponents extends ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is DataSourceReferenceConfigVar<TComponents>;
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isComponentReference = exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = void 0;
3
+ exports.isComponentReference = exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = exports.isCodeConfigVar = void 0;
4
+ const isCodeConfigVar = (cv) => "dataType" in cv && cv.dataType === "code";
5
+ exports.isCodeConfigVar = isCodeConfigVar;
4
6
  const isScheduleConfigVar = (cv) => "dataType" in cv && cv.dataType === "schedule";
5
7
  exports.isScheduleConfigVar = isScheduleConfigVar;
6
8
  const isDataSourceDefinitionConfigVar = (cv) => "dataSourceType" in cv && "perform" in cv && typeof cv.perform === "function";
7
9
  exports.isDataSourceDefinitionConfigVar = isDataSourceDefinitionConfigVar;
8
- const isDataSourceReferenceConfigVar = (cv) => "dataSource" in cv && (0, exports.isComponentReference)(cv.dataSource);
10
+ const isDataSourceReferenceConfigVar = (cv) => "dataSourceType" in cv &&
11
+ "dataSource" in cv &&
12
+ (0, exports.isComponentReference)(cv.dataSource);
9
13
  exports.isDataSourceReferenceConfigVar = isDataSourceReferenceConfigVar;
10
14
  const isConnectionDefinitionConfigVar = (cv) => "inputs" in cv;
11
15
  exports.isConnectionDefinitionConfigVar = isConnectionDefinitionConfigVar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "8.1.6",
3
+ "version": "8.1.7",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"