@prismatic-io/spectral 10.11.5 → 10.12.0

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.
@@ -504,6 +504,15 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
504
504
  if ((0, types_1.isJsonFormConfigVar)(configVar) || (0, types_1.isJsonFormDataSourceConfigVar)(configVar)) {
505
505
  result.meta = Object.assign(Object.assign({}, result.meta), { validationMode: (_c = configVar === null || configVar === void 0 ? void 0 : configVar.validationMode) !== null && _c !== void 0 ? _c : "ValidateAndShow" });
506
506
  }
507
+ if ((0, types_1.isJsonFormDataSourceConfigVar)(configVar) && configVar.dataSourceReset) {
508
+ result.meta = Object.assign(Object.assign({}, result.meta), { dataSourceReset: configVar.dataSourceReset.mode });
509
+ // Create placeholder inputs for each config variable dependency, so that
510
+ // the config wizard can detect if any changed and reset the data source.
511
+ result.inputs = (configVar.dataSourceReset.dependencies || []).reduce((acc, dep, idx) => (Object.assign(Object.assign({}, acc), { [`input${idx}`]: {
512
+ type: "configVar",
513
+ value: dep,
514
+ } })), {});
515
+ }
507
516
  if ((0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
508
517
  result.dataType = configVar.dataSourceType;
509
518
  result.dataSource = {
@@ -520,6 +529,9 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
520
529
  if (configVar.validationMode) {
521
530
  result.meta = Object.assign(Object.assign({}, result.meta), { validationMode: configVar.validationMode });
522
531
  }
532
+ if (configVar.dataSourceReset) {
533
+ result.meta = Object.assign(Object.assign({}, result.meta), { dataSourceReset: configVar.dataSourceReset.mode });
534
+ }
523
535
  }
524
536
  return result;
525
537
  };
@@ -688,7 +700,16 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
688
700
  return Object.assign(Object.assign({}, result), { [camelKey]: Object.assign(Object.assign({}, dataSource), { key: camelKey, display: {
689
701
  label: key,
690
702
  description: key,
691
- }, inputs: [] }) });
703
+ }, inputs:
704
+ // Create placeholder inputs for each config variable dependency,so that
705
+ // the config wizard can detect if any changed and reset the data source.
706
+ (0, types_1.isJsonFormDataSourceConfigVar)(configVar) && configVar.dataSourceReset
707
+ ? (configVar.dataSourceReset.dependencies || []).map((dep, idx) => ({
708
+ key: `input${idx}`,
709
+ label: dep,
710
+ type: "string",
711
+ }))
712
+ : [] }) });
692
713
  }, {});
693
714
  const convertedConnections = Object.entries(configVars).reduce((result, [key, configVar]) => {
694
715
  var _a;
@@ -126,11 +126,18 @@ type ScheduleConfigVar = CreateStandardConfigVar<"schedule"> & {
126
126
  };
127
127
  type ObjectSelectionConfigVar = CreateStandardConfigVar<"objectSelection">;
128
128
  type ObjectFieldMapConfigVar = CreateStandardConfigVar<"objectFieldMap">;
129
+ type DataSourceReset = {
130
+ /** Either always prompt a user to reset the data source when a dependent config variable changes, or always reset the data source */
131
+ mode: "prompt" | "always";
132
+ /** List of config variable names that, if changed, should trigger a reset of the JSON Form */
133
+ dependencies?: string[];
134
+ };
129
135
  type JsonFormConfigVar = CreateStandardConfigVar<"jsonForm"> & {
130
136
  validationMode?: ValidationMode;
131
137
  };
132
138
  type JsonFormDataSourceDefinitionConfigVar = DataSourceDefinitionConfigVar & {
133
139
  validationMode?: ValidationMode;
140
+ dataSourceReset?: DataSourceReset;
134
141
  };
135
142
  type HtmlElementConfigVar = CreateStandardConfigVar<"htmlElement">;
136
143
  export type StandardConfigVar = StringConfigVar | DateConfigVar | TimestampConfigVar | PicklistConfigVar | CodeConfigVar | BooleanConfigVar | NumberConfigVar | ScheduleConfigVar | ObjectSelectionConfigVar | ObjectFieldMapConfigVar | JsonFormConfigVar | HtmlElementConfigVar;
@@ -155,6 +162,7 @@ type DataSourceDefinitionConfigVar = DataSourceType extends infer TDataSourceTyp
155
162
  type DataSourceReferenceConfigVar = ComponentRegistryDataSource extends infer TDataSourceReference extends ComponentRegistryDataSource ? Omit<BaseDataSourceConfigVar<TDataSourceReference["dataSourceType"]>, "dataSourceType"> & {
156
163
  dataSource: TDataSourceReference["reference"];
157
164
  validationMode?: ValidationMode;
165
+ dataSourceReset?: Omit<DataSourceReset, "dependencies">;
158
166
  } : never;
159
167
  /** Defines attributes of a data source config variable. */
160
168
  export type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.11.5",
3
+ "version": "10.12.0",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",