@prismatic-io/spectral 10.11.0 → 10.11.2

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.
@@ -90,3 +90,9 @@ export type BooleanExpression = [
90
90
  ...ConditionalExpression[]
91
91
  ];
92
92
  export type ConditionalExpression = TermExpression | BooleanExpression;
93
+ export declare const OPERATOR_PHRASE_TO_EXPRESSION: {
94
+ [clause: string]: {
95
+ expression: string;
96
+ includes?: Array<string>;
97
+ };
98
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TermOperatorPhrase = exports.BinaryOperatorPhrase = exports.BinaryOperator = exports.UnaryOperatorPhrase = exports.UnaryOperator = exports.BooleanOperatorPhrase = exports.BooleanOperator = void 0;
3
+ exports.OPERATOR_PHRASE_TO_EXPRESSION = exports.TermOperatorPhrase = exports.BinaryOperatorPhrase = exports.BinaryOperator = exports.UnaryOperatorPhrase = exports.UnaryOperator = exports.BooleanOperatorPhrase = exports.BooleanOperator = void 0;
4
4
  // GraphQL-derived enums use the same name as the constant for the value,
5
5
  // but depending on how things shake out, we may be able to combine with the phrases below.
6
6
  var BooleanOperator;
@@ -66,3 +66,95 @@ exports.BinaryOperatorPhrase = {
66
66
  [BinaryOperator.dateTimeSame]: "is the same (date/time)",
67
67
  };
68
68
  exports.TermOperatorPhrase = Object.assign(Object.assign({}, exports.UnaryOperatorPhrase), exports.BinaryOperatorPhrase);
69
+ exports.OPERATOR_PHRASE_TO_EXPRESSION = {
70
+ [BinaryOperator.equal]: {
71
+ expression: "isEqual($LEFT_TERM, $RIGHT_TERM)",
72
+ includes: ["isEqual"],
73
+ },
74
+ [BinaryOperator.exactlyMatches]: {
75
+ expression: "$LEFT_TERM === $RIGHT_TERM || isDeepEqual($LEFT_TERM, $RIGHT_TERM)",
76
+ includes: ["isDeepEqual"],
77
+ },
78
+ [BinaryOperator.notEqual]: {
79
+ expression: "!(isEqual($LEFT_TERM, $RIGHT_TERM))",
80
+ includes: ["isEqual"],
81
+ },
82
+ [BinaryOperator.doesNotExactlyMatch]: {
83
+ expression: "!($LEFT_TERM === $RIGHT_TERM || isDeepEqual($LEFT_TERM, $RIGHT_TERM))",
84
+ includes: ["isDeepEqual"],
85
+ },
86
+ [BinaryOperator.greaterThan]: {
87
+ expression: "$LEFT_TERM > $RIGHT_TERM",
88
+ },
89
+ [BinaryOperator.greaterThanOrEqual]: {
90
+ expression: "$LEFT_TERM >= $RIGHT_TERM",
91
+ },
92
+ [BinaryOperator.lessThan]: {
93
+ expression: "$LEFT_TERM < $RIGHT_TERM",
94
+ },
95
+ [BinaryOperator.lessThanOrEqual]: {
96
+ expression: "$LEFT_TERM <= $RIGHT_TERM",
97
+ },
98
+ [BinaryOperator.in]: {
99
+ expression: "contains($RIGHT_TERM, $LEFT_TERM)",
100
+ includes: ["contains"],
101
+ },
102
+ [BinaryOperator.notIn]: {
103
+ expression: "!contains($RIGHT_TERM, $LEFT_TERM)",
104
+ includes: ["contains"],
105
+ },
106
+ [BinaryOperator.startsWith]: {
107
+ expression: "$RIGHT_TERM.startsWith($LEFT_TERM)",
108
+ },
109
+ [BinaryOperator.doesNotStartWith]: {
110
+ expression: "!$RIGHT_TERM.startsWith($LEFT_TERM)",
111
+ },
112
+ [BinaryOperator.endsWith]: {
113
+ expression: "$RIGHT_TERM.endsWith($LEFT_TERM)",
114
+ },
115
+ [BinaryOperator.doesNotEndWith]: {
116
+ expression: "!$RIGHT_TERM.endsWith($LEFT_TERM)",
117
+ },
118
+ [BinaryOperator.dateTimeAfter]: {
119
+ expression: "dateIsAfter($LEFT_TERM, $RIGHT_TERM)",
120
+ includes: ["dateIsAfter"],
121
+ },
122
+ [BinaryOperator.dateTimeBefore]: {
123
+ expression: "dateIsBefore($LEFT_TERM, $RIGHT_TERM)",
124
+ includes: ["dateIsBefore"],
125
+ },
126
+ [BinaryOperator.dateTimeSame]: {
127
+ expression: "dateIsEqual($LEFT_TERM, $RIGHT_TERM)",
128
+ includes: ["dateIsEqual"],
129
+ },
130
+ [BooleanOperator.and]: {
131
+ expression: "$LEFT_TERM && $RIGHT_TERM",
132
+ },
133
+ [BooleanOperator.or]: {
134
+ expression: "$LEFT_TERM || $RIGHT_TERM",
135
+ },
136
+ [UnaryOperator.isTrue]: {
137
+ expression: "evaluatesTrue($LEFT_TERM)",
138
+ includes: ["evaluatesTrue"],
139
+ },
140
+ [UnaryOperator.isFalse]: {
141
+ expression: "evaluatesFalse($LEFT_TERM)",
142
+ includes: ["evaluatesFalse"],
143
+ },
144
+ [UnaryOperator.doesNotExist]: {
145
+ expression: "evaluatesNull($LEFT_TERM)",
146
+ includes: ["evaluatesNull"],
147
+ },
148
+ [UnaryOperator.exists]: {
149
+ expression: "!evaluatesNull($LEFT_TERM)",
150
+ includes: ["evaluatesNull"],
151
+ },
152
+ [UnaryOperator.isEmpty]: {
153
+ expression: "evaluatesEmpty($LEFT_TERM)",
154
+ includes: ["evaluatesEmpty"],
155
+ },
156
+ [UnaryOperator.isNotEmpty]: {
157
+ expression: "!evaluatesNull($LEFT_TERM)",
158
+ includes: ["evaluatesNull"],
159
+ },
160
+ };
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INPUT_TYPE_MAP = exports.getInputs = void 0;
4
4
  const escapeSpecialCharacters_1 = require("../utils/escapeSpecialCharacters");
5
5
  const docBlock_1 = require("./docBlock");
6
- const getDefaultValue = (value) => {
6
+ const getDefaultValue = (value, isCollection) => {
7
7
  if (value === undefined || value === "") {
8
- return value;
8
+ return isCollection ? [] : value;
9
9
  }
10
10
  const stringValue = typeof value === "string" ? value : JSON.stringify(value);
11
11
  return (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(stringValue);
@@ -29,7 +29,7 @@ const getInputs = ({ inputs, docBlock = docBlock_1.DOC_BLOCK_DEFAULT }) => {
29
29
  collection: input.collection,
30
30
  onPremControlled: input.onPremiseControlled || input.onPremControlled,
31
31
  docBlock: docBlock(input),
32
- default: getDefaultValue(input.default),
32
+ default: getDefaultValue(input.default, Boolean(input.collection)),
33
33
  },
34
34
  ];
35
35
  }, []);
@@ -6,7 +6,9 @@
6
6
  <%_ } else { -%>
7
7
  collection: undefined,
8
8
  <%_ } -%>
9
- <%_ if (typeof input.default !== 'undefined') { -%>
9
+ <%_ if (Array.isArray(input.default)) { -%>
10
+ default: <%- JSON.stringify(input.default) %>,
11
+ <%_ } else if (typeof input.default !== 'undefined') { -%>
10
12
  default: `<%- input.default %>`,
11
13
  <%_ } else { -%>
12
14
  default: undefined,
@@ -211,15 +211,16 @@ const convertComponentReference = (componentReference, componentRegistry, refere
211
211
  };
212
212
  const inputs = Object.entries(manifestEntry.inputs).reduce((result, [key, manifestEntryInput]) => {
213
213
  var _a, _b, _c;
214
+ const isCollection = Boolean(manifestEntryInput.collection);
214
215
  // Retrieve the input value or default to the manifest's default value
215
216
  const value = (_b = (_a = componentReference.values) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : {
216
- value: (_c = manifestEntryInput.default) !== null && _c !== void 0 ? _c : "",
217
+ value: isCollection
218
+ ? manifestEntryInput.default === ""
219
+ ? []
220
+ : manifestEntryInput.default
221
+ : (_c = manifestEntryInput.default) !== null && _c !== void 0 ? _c : "",
217
222
  };
218
- const type = manifestEntryInput.collection
219
- ? "complex"
220
- : "value" in value
221
- ? "value"
222
- : "configVar";
223
+ const type = isCollection ? "complex" : "value" in value ? "value" : "configVar";
223
224
  if ("value" in value) {
224
225
  const valueExpr = manifestEntryInput.collection === "keyvaluelist" && value.value instanceof Object
225
226
  ? Object.entries(value.value).map(([k, v]) => ({
@@ -139,7 +139,6 @@ type BaseDataSourceConfigVar<TDataSourceType extends DataSourceType = DataSource
139
139
  collectionType?: CollectionType | undefined;
140
140
  } & BaseConfigVar : TDataSourceType extends Exclude<DataSourceType, CollectionDataSourceType> ? TDataSourceType extends Extract<DataSourceType, "jsonForm"> ? BaseConfigVar & {
141
141
  dataSourceType: Extract<DataSourceType, "jsonForm">;
142
- dataSource?: never;
143
142
  collectionType?: undefined;
144
143
  validationMode?: ValidationMode;
145
144
  } : BaseConfigVar & {
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.11.0",
3
+ "version": "10.11.2",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "homepage": "https://prismatic.io",
9
9
  "bin": {
10
- "component-manifest": "./bin/component-manifest.js",
11
- "cni-component-manifest": "./bin/cni-component-manifest.js"
10
+ "component-manifest": "bin/component-manifest.js",
11
+ "cni-component-manifest": "bin/cni-component-manifest.js"
12
12
  },
13
13
  "bugs": {
14
14
  "url": "https://github.com/prismatic-io/spectral"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/prismatic-io/spectral.git"
18
+ "url": "git+https://github.com/prismatic-io/spectral.git"
19
19
  },
20
20
  "publishConfig": {
21
21
  "access": "public",