@prismatic-io/spectral 7.0.6-pre → 7.0.9-pre
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.
- package/dist/types/Inputs.d.ts +5 -5
- package/dist/types/Inputs.js +3 -3
- package/dist/util.d.ts +3 -0
- package/dist/util.js +32 -3
- package/package.json +1 -1
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare type ObjectSelection = {
|
|
|
3
3
|
key: string;
|
|
4
4
|
label?: string;
|
|
5
5
|
selected?: boolean;
|
|
6
|
-
fields
|
|
6
|
+
fields?: {
|
|
7
7
|
key: string;
|
|
8
8
|
label?: string;
|
|
9
9
|
}[];
|
|
@@ -163,7 +163,7 @@ export interface Connection {
|
|
|
163
163
|
/** Defines attributes of an ObjectSelectionInputField. */
|
|
164
164
|
export interface ObjectSelectionInputField extends BaseInputField {
|
|
165
165
|
/** Data type the InputField will collect. */
|
|
166
|
-
type: "
|
|
166
|
+
type: "objectSelection";
|
|
167
167
|
/** Collection type of the InputField */
|
|
168
168
|
collection?: InputFieldCollection;
|
|
169
169
|
/** Default value for this field. */
|
|
@@ -174,7 +174,7 @@ export interface ObjectSelectionInputField extends BaseInputField {
|
|
|
174
174
|
/** Defines attributes of an ObjectFieldMapInputField. */
|
|
175
175
|
export interface ObjectFieldMapInputField extends BaseInputField {
|
|
176
176
|
/** Data type the InputField will collect. */
|
|
177
|
-
type: "
|
|
177
|
+
type: "objectFieldMap";
|
|
178
178
|
/** Collection type of the InputField */
|
|
179
179
|
collection?: InputFieldCollection;
|
|
180
180
|
/** Default value for this field. */
|
|
@@ -182,10 +182,10 @@ export interface ObjectFieldMapInputField extends BaseInputField {
|
|
|
182
182
|
/** Clean function */
|
|
183
183
|
clean?: InputCleanFunction<NonNullable<this["default"]>>;
|
|
184
184
|
}
|
|
185
|
-
/** Defines attributes of a
|
|
185
|
+
/** Defines attributes of a JSONFormInputField. */
|
|
186
186
|
export interface JSONFormInputField extends BaseInputField {
|
|
187
187
|
/** Data type the InputField will collect. */
|
|
188
|
-
type: "
|
|
188
|
+
type: "jsonForm";
|
|
189
189
|
/** Collection type of the InputField */
|
|
190
190
|
collection?: InputFieldCollection;
|
|
191
191
|
/** Default value for this field. */
|
package/dist/types/Inputs.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.InputFieldDefaultMap = {
|
|
|
10
10
|
code: "",
|
|
11
11
|
conditional: undefined,
|
|
12
12
|
connection: undefined,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
objectSelection: undefined,
|
|
14
|
+
objectFieldMap: undefined,
|
|
15
|
+
jsonForm: undefined,
|
|
16
16
|
};
|
package/dist/util.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ declare const _default: {
|
|
|
31
31
|
toBufferDataPayload: (value: unknown) => DataPayload;
|
|
32
32
|
isData: (value: unknown) => boolean;
|
|
33
33
|
toData: (value: unknown) => DataPayload;
|
|
34
|
+
isString: (value: unknown) => value is string;
|
|
34
35
|
toString: (value: unknown, defaultValue?: string) => string;
|
|
35
36
|
keyValPairListToObject: <TValue = unknown>(kvpList: KeyValuePair<unknown>[], valueConverter?: ((value: unknown) => TValue) | undefined) => Record<string, TValue>;
|
|
36
37
|
isJSON: (value: string) => boolean;
|
|
@@ -42,6 +43,8 @@ declare const _default: {
|
|
|
42
43
|
toObjectFieldMap: (value: unknown) => ObjectFieldMap;
|
|
43
44
|
isJSONForm: (value: unknown) => value is JSONForm;
|
|
44
45
|
toJSONForm: (value: unknown) => JSONForm;
|
|
46
|
+
isPicklist: (value: unknown) => boolean;
|
|
47
|
+
isSchedule: (value: unknown) => boolean;
|
|
45
48
|
};
|
|
46
49
|
docs: {
|
|
47
50
|
formatJsonExample: (input: unknown) => string;
|
package/dist/util.js
CHANGED
|
@@ -27,10 +27,10 @@ const isObjectWithTruthyKeys = (value, keys) => {
|
|
|
27
27
|
const isObjectSelection = (value) => {
|
|
28
28
|
if (Array.isArray(value)) {
|
|
29
29
|
for (const selection of value) {
|
|
30
|
-
if (isObjectWithTruthyKeys(selection, ["key"
|
|
30
|
+
if (isObjectWithTruthyKeys(selection, ["key"])) {
|
|
31
31
|
const { fields } = selection;
|
|
32
|
-
if (
|
|
33
|
-
fields.length
|
|
32
|
+
if (Array.isArray(fields) &&
|
|
33
|
+
fields.length > 0 &&
|
|
34
34
|
!fields.every((field) => isObjectWithTruthyKeys(field, ["key"]))) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
@@ -280,6 +280,25 @@ const toDate = (value) => {
|
|
|
280
280
|
* @returns This function returns true if `value` is a valid URL, and false otherwise.
|
|
281
281
|
*/
|
|
282
282
|
const isUrl = (value) => (0, valid_url_1.isWebUri)(value) !== undefined;
|
|
283
|
+
/**
|
|
284
|
+
* This function checks if value is a valid picklist.
|
|
285
|
+
*
|
|
286
|
+
* - `util.types.isPicklist(["value", new String("value")])` will return `true`.
|
|
287
|
+
*
|
|
288
|
+
* @param value The variable to test.
|
|
289
|
+
* @returns This function returns true if `value` is a valid picklist.
|
|
290
|
+
*/
|
|
291
|
+
const isPicklist = (value) => Array.isArray(value) && value.every(isString);
|
|
292
|
+
/**
|
|
293
|
+
* This function checks if value is a valid schedule.
|
|
294
|
+
*
|
|
295
|
+
* - `util.types.isSchedule({value: "00 00 * * 2,3"})` will return `true`.
|
|
296
|
+
* - `util.types.isSchedule({value: "00 00 * * 2,3", scheduleType: "week", timeZone: "America/Chicago"})` will return `true`.
|
|
297
|
+
*
|
|
298
|
+
* @param value The variable to test.
|
|
299
|
+
* @returns This function returns true if `value` is a valid schedule.
|
|
300
|
+
*/
|
|
301
|
+
const isSchedule = (value) => isObjectWithTruthyKeys(value, ["value"]);
|
|
283
302
|
/**
|
|
284
303
|
* This function helps to transform key-value lists to objects.
|
|
285
304
|
* This is useful for transforming inputs that are key-value collections into objects.
|
|
@@ -373,6 +392,13 @@ const toData = (value) => toBufferDataPayload(value);
|
|
|
373
392
|
* @returns This function returns a code block that can be used for documentation.
|
|
374
393
|
*/
|
|
375
394
|
const formatJsonExample = (input) => ["```json", JSON.stringify(input, undefined, 2), "```"].join("\n");
|
|
395
|
+
/**
|
|
396
|
+
* This function checks if value is a string.
|
|
397
|
+
* `util.types.isString("value")` and `util.types.isString(new String("value"))` return true.
|
|
398
|
+
* @param value The variable to test.
|
|
399
|
+
* @returns This function returns true or false, depending on if `value` is a string.
|
|
400
|
+
*/
|
|
401
|
+
const isString = (value) => typeof value === "string" || value instanceof String;
|
|
376
402
|
/**
|
|
377
403
|
* This function converts a `value` to a string.
|
|
378
404
|
* If `value` is undefined or an empty string, an optional `defaultValue` can be returned.
|
|
@@ -445,6 +471,7 @@ exports.default = {
|
|
|
445
471
|
toBufferDataPayload,
|
|
446
472
|
isData,
|
|
447
473
|
toData,
|
|
474
|
+
isString,
|
|
448
475
|
toString,
|
|
449
476
|
keyValPairListToObject,
|
|
450
477
|
isJSON,
|
|
@@ -456,6 +483,8 @@ exports.default = {
|
|
|
456
483
|
toObjectFieldMap,
|
|
457
484
|
isJSONForm,
|
|
458
485
|
toJSONForm,
|
|
486
|
+
isPicklist,
|
|
487
|
+
isSchedule,
|
|
459
488
|
},
|
|
460
489
|
docs: {
|
|
461
490
|
formatJsonExample,
|