@prismatic-io/spectral 9.3.0 → 10.0.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.
@@ -1,4 +1,5 @@
1
- import { InputFieldDefinition, ComponentDefinition, OnPremConnectionInput } from "../types";
2
- import { Component as ServerComponent, Input as ServerInput } from ".";
1
+ import { InputFieldDefinition, ComponentDefinition, ConnectionDefinition, OnPremConnectionInput } from "../types";
2
+ import { Component as ServerComponent, Connection as ServerConnection, Input as ServerInput } from ".";
3
3
  export declare const convertInput: (key: string, { default: defaultValue, type, label, collection, ...rest }: InputFieldDefinition | OnPremConnectionInput) => ServerInput;
4
+ export declare const convertConnection: ({ inputs, ...connection }: ConnectionDefinition) => ServerConnection;
4
5
  export declare const convertComponent: <TPublic extends boolean, TKey extends string>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent;
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.convertComponent = exports.convertInput = void 0;
14
+ exports.convertComponent = exports.convertConnection = exports.convertInput = void 0;
15
15
  const types_1 = require("../types");
16
16
  const perform_1 = require("./perform");
17
17
  const lodash_1 = require("lodash");
@@ -72,13 +72,16 @@ const convertDataSource = (dataSourceKey, _a, hooks) => {
72
72
  const convertConnection = (_a) => {
73
73
  var { inputs = {} } = _a, connection = __rest(_a, ["inputs"]);
74
74
  const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
75
- return Object.assign(Object.assign({}, connection), { inputs: convertedInputs });
75
+ const { display: { label, icons, description: comments } } = connection, remaining = __rest(connection, ["display"]);
76
+ return Object.assign(Object.assign({}, remaining), { label,
77
+ comments, iconPath: icons === null || icons === void 0 ? void 0 : icons.oauth2ConnectionIconPath, avatarIconPath: icons === null || icons === void 0 ? void 0 : icons.avatarPath, inputs: convertedInputs });
76
78
  };
79
+ exports.convertConnection = convertConnection;
77
80
  const convertComponent = (_a) => {
78
81
  var { connections = [], actions = {}, triggers = {}, dataSources = {}, hooks } = _a, definition = __rest(_a, ["connections", "actions", "triggers", "dataSources", "hooks"]);
79
82
  const convertedActions = Object.entries(actions).reduce((result, [actionKey, action]) => (Object.assign(Object.assign({}, result), { [actionKey]: convertAction(actionKey, action, hooks) })), {});
80
83
  const convertedTriggers = Object.entries(triggers).reduce((result, [triggerKey, trigger]) => (Object.assign(Object.assign({}, result), { [triggerKey]: convertTrigger(triggerKey, trigger, hooks) })), {});
81
84
  const convertedDataSources = Object.entries(dataSources).reduce((result, [dataSourceKey, dataSource]) => (Object.assign(Object.assign({}, result), { [dataSourceKey]: convertDataSource(dataSourceKey, dataSource, hooks) })), {});
82
- return Object.assign(Object.assign({}, definition), { connections: connections.map(convertConnection), actions: convertedActions, triggers: convertedTriggers, dataSources: convertedDataSources });
85
+ return Object.assign(Object.assign({}, definition), { connections: connections.map(exports.convertConnection), actions: convertedActions, triggers: convertedTriggers, dataSources: convertedDataSources });
83
86
  };
84
87
  exports.convertComponent = convertComponent;
@@ -195,6 +195,10 @@ const convertComponentReference = (componentReference, componentRegistry, refere
195
195
  ? valueExpr
196
196
  : JSON.stringify(valueExpr);
197
197
  const meta = convertInputPermissionAndVisibility((0, lodash_1.pick)(value, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
198
+ const { writeOnly } = (0, lodash_1.pick)(value, ["writeOnly"]);
199
+ if (writeOnly) {
200
+ meta.writeOnly = writeOnly;
201
+ }
198
202
  return Object.assign(Object.assign({}, result), { [key]: { type: type, value: formattedValue, meta } });
199
203
  }
200
204
  if ("configVar" in value) {
@@ -560,7 +564,11 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
560
564
  } });
561
565
  }, {});
562
566
  const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, schedule }) => {
563
- if (!flowUsesWrapperTrigger({ onTrigger, onInstanceDelete, onInstanceDeploy })) {
567
+ if (!flowUsesWrapperTrigger({
568
+ onTrigger,
569
+ onInstanceDelete,
570
+ onInstanceDeploy,
571
+ })) {
564
572
  // In this scenario, the user has defined an existing component trigger
565
573
  // without any custom behavior, so we don't need to wrap anything.
566
574
  return result;
@@ -610,14 +618,17 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
610
618
  }, inputs: [] }) });
611
619
  }, {});
612
620
  const convertedConnections = Object.entries(configVars).reduce((result, [key, configVar]) => {
621
+ var _a;
613
622
  if (!(0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
614
623
  return result;
615
624
  }
616
625
  const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convertComponent_1.convertInput)(key, value));
617
- const connection = (0, lodash_1.pick)(configVar, ["oauth2Type", "iconPath"]);
626
+ const connection = (0, lodash_1.pick)(configVar, ["oauth2Type"]);
627
+ const { avatarPath: avatarIconPath, oauth2ConnectionIconPath: iconPath } = (_a = configVar.icons) !== null && _a !== void 0 ? _a : {};
618
628
  return [
619
629
  ...result,
620
- Object.assign(Object.assign({}, connection), { inputs: convertedInputs, key: (0, lodash_1.camelCase)(key), label: key }),
630
+ Object.assign(Object.assign({}, connection), { iconPath,
631
+ avatarIconPath, inputs: convertedInputs, key: (0, lodash_1.camelCase)(key), label: key }),
621
632
  ];
622
633
  }, []);
623
634
  return {
@@ -176,6 +176,7 @@ export interface Connection {
176
176
  comments?: string;
177
177
  oauth2Type?: OAuth2Type;
178
178
  iconPath?: string;
179
+ avatarIconPath?: string;
179
180
  inputs: (Input & {
180
181
  shown?: boolean;
181
182
  onPremControlled?: boolean;
@@ -30,7 +30,9 @@ type ComponentReferenceTypeValueMap<TValue, TMap extends Record<ComponentReferen
30
30
  actions: ValueExpression<TValue>;
31
31
  triggers: ValueExpression<TValue> | ConfigVarExpression;
32
32
  dataSources: ValueExpression<TValue> | ConfigVarExpression;
33
- connections: (ValueExpression<TValue> | ConfigVarExpression) & ConfigVarVisibility;
33
+ connections: (ValueExpression<TValue> | ConfigVarExpression) & ConfigVarVisibility & {
34
+ writeOnly?: true;
35
+ };
34
36
  }> = TMap;
35
37
  export type ComponentReference<TComponentReference extends {
36
38
  component: string;
@@ -141,7 +141,8 @@ export type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceRefe
141
141
  type BaseConnectionConfigVar = BaseConfigVar & {
142
142
  dataType: "connection";
143
143
  };
144
- type ConnectionDefinitionConfigVar = ConnectionDefinition extends infer TConnectionDefinitionType extends ConnectionDefinition ? TConnectionDefinitionType extends infer TConnectionDefinition extends ConnectionDefinition ? BaseConnectionConfigVar & Omit<TConnectionDefinition, "inputs" | "label" | "comments" | "key"> & {
144
+ type ConnectionDefinitionConfigVar = ConnectionDefinition extends infer TConnectionDefinitionType extends ConnectionDefinition ? TConnectionDefinitionType extends infer TConnectionDefinition extends ConnectionDefinition ? BaseConnectionConfigVar & Omit<TConnectionDefinition, "inputs" | "display" | "key"> & {
145
+ icons?: TConnectionDefinition["display"]["icons"];
145
146
  inputs: {
146
147
  [Key in keyof TConnectionDefinition["inputs"]]: TConnectionDefinition["inputs"][Key] & ConfigVarInputVisibility;
147
148
  };
@@ -1,4 +1,4 @@
1
- import type { ConnectionInput, OnPremConnectionInput } from ".";
1
+ import type { ConnectionDisplayDefinition, ConnectionInput, OnPremConnectionInput } from ".";
2
2
  export declare enum OAuth2Type {
3
3
  ClientCredentials = "client_credentials",
4
4
  AuthorizationCode = "authorization_code"
@@ -9,9 +9,7 @@ export declare enum OAuth2PkceMethod {
9
9
  }
10
10
  interface BaseConnectionDefinition {
11
11
  key: string;
12
- label: string;
13
- comments?: string;
14
- iconPath?: string;
12
+ display: ConnectionDisplayDefinition;
15
13
  oauth2Type?: OAuth2Type;
16
14
  }
17
15
  export interface DefaultConnectionDefinition extends BaseConnectionDefinition {
@@ -24,4 +24,13 @@ export interface ActionDisplayDefinition extends DisplayDefinition {
24
24
  /** Indicate that this Action is important and/or commonly used from the parent Component. Should be enabled sparingly. */
25
25
  important?: boolean;
26
26
  }
27
+ /** Connection-specific Display attributes. */
28
+ export interface ConnectionDisplayDefinition extends DisplayDefinition {
29
+ icons?: {
30
+ /** Path to icon to use for this Connection. Path should be relative to the built component source. */
31
+ avatarPath?: string;
32
+ /** Path to icon to use for this Connection's "Connect" button. Path should be relative to the built component source. */
33
+ oauth2ConnectionIconPath?: string;
34
+ };
35
+ }
27
36
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "9.3.0",
3
+ "version": "10.0.0",
4
4
  "description": "Utility library for building Prismatic components and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",