@prismatic-io/spectral 10.13.0 → 10.14.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.
@@ -417,6 +417,22 @@ const convertInputValue = (value, collectionType) => {
417
417
  }));
418
418
  };
419
419
  exports.convertInputValue = convertInputValue;
420
+ const validateOnPremConnectionConfig = (connection) => {
421
+ if ((0, types_1.isConnectionDefinitionConfigVar)(connection)) {
422
+ const hasOnPremControlledInputs = Object.values(connection.inputs).some((value) => {
423
+ return "onPremControlled" in value && value.onPremControlled;
424
+ });
425
+ const { onPremConnectionConfig: config } = connection;
426
+ if (hasOnPremControlledInputs && !config) {
427
+ throw new Error(`Connection ${connection.stableKey} has onPremControlled inputs but no onPremConnectionConfig value set. Please set an onPremConnectionConfig value for the connection.`);
428
+ }
429
+ if (!hasOnPremControlledInputs && config && config !== "disallowed") {
430
+ throw new Error(`Connection ${connection.stableKey} has onPremConnectionConfig set but no onPremControlled inputs. The connection will not be valid without onPremControlled inputs (host, port).`);
431
+ }
432
+ return hasOnPremControlledInputs && config ? config : "disallowed";
433
+ }
434
+ return "disallowed";
435
+ };
420
436
  /** Converts a Config Var into the structure necessary for YAML generation. */
421
437
  const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
422
438
  var _a, _b, _c;
@@ -437,6 +453,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
437
453
  description,
438
454
  key,
439
455
  dataType: "connection",
456
+ onPremiseConnectionConfig: validateOnPremConnectionConfig(configVar),
440
457
  connection: {
441
458
  key: (0, camelCase_1.default)(key),
442
459
  component: codeNativeIntegrationComponentReference(referenceKey),
@@ -169,13 +169,14 @@ export type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceRefe
169
169
  type BaseConnectionConfigVar = BaseConfigVar & {
170
170
  dataType: "connection";
171
171
  };
172
+ export type OnPremiseConnectionConfigTypeEnum = "allowed" | "disallowed" | "required";
172
173
  type ConnectionDefinitionConfigVar = ConnectionDefinition extends infer TConnectionDefinitionType extends ConnectionDefinition ? TConnectionDefinitionType extends infer TConnectionDefinition extends ConnectionDefinition ? BaseConnectionConfigVar & Omit<TConnectionDefinition, "inputs" | "display" | "key"> & {
173
174
  icons?: TConnectionDefinition["display"]["icons"];
175
+ onPremConnectionConfig?: OnPremiseConnectionConfigTypeEnum;
174
176
  inputs: {
175
177
  [Key in keyof TConnectionDefinition["inputs"]]: TConnectionDefinition["inputs"][Key] & ConfigVarInputVisibility;
176
178
  };
177
179
  } : never : never;
178
- type OnPremiseConnectionConfigTypeEnum = "allowed" | "disallowed" | "required";
179
180
  type ConnectionReferenceConfigVar = ComponentRegistryConnection extends infer TConnectionReference ? TConnectionReference extends ComponentRegistryConnection ? BaseConnectionConfigVar & {
180
181
  connection: TConnectionReference["reference"] & ("onPremAvailable" extends keyof TConnectionReference ? TConnectionReference["onPremAvailable"] extends true ? {
181
182
  template?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.13.0",
3
+ "version": "10.14.0",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",