@prismatic-io/spectral 9.1.1 → 9.1.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.
|
@@ -310,6 +310,7 @@ const convertInputValue = (value, collectionType) => {
|
|
|
310
310
|
};
|
|
311
311
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
312
312
|
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
313
|
+
var _a;
|
|
313
314
|
const { orgOnly, meta } = convertConfigVarPermissionAndVisibility((0, lodash_1.pick)(configVar, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
|
|
314
315
|
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
315
316
|
const { stableKey, description } = (0, lodash_1.pick)(configVar, ["stableKey", "description"]);
|
|
@@ -373,6 +374,9 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
373
374
|
if ((0, types_1.isScheduleConfigVar)(configVar)) {
|
|
374
375
|
result.scheduleType = "custom";
|
|
375
376
|
}
|
|
377
|
+
if ((0, types_1.isJsonFormConfigVar)(configVar) || (0, types_1.isJsonFormDataSourceConfigVar)(configVar)) {
|
|
378
|
+
result.meta = Object.assign(Object.assign({}, result.meta), { validationMode: (_a = configVar === null || configVar === void 0 ? void 0 : configVar.validationMode) !== null && _a !== void 0 ? _a : "ValidateAndShow" });
|
|
379
|
+
}
|
|
376
380
|
if ((0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
|
|
377
381
|
result.dataType = configVar.dataSourceType;
|
|
378
382
|
result.dataSource = {
|
|
@@ -385,6 +389,9 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
385
389
|
result.dataType = componentRegistry[ref.component.key].dataSources[ref.key].dataSourceType;
|
|
386
390
|
result.dataSource = ref;
|
|
387
391
|
result.inputs = inputs;
|
|
392
|
+
if (configVar.validationMode) {
|
|
393
|
+
result.meta = Object.assign(Object.assign({}, result.meta), { validationMode: configVar.validationMode });
|
|
394
|
+
}
|
|
388
395
|
}
|
|
389
396
|
return result;
|
|
390
397
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidationMode } from "@jsonforms/core";
|
|
1
2
|
import { type DataSourceDefinition, type ConnectionDefinition, type Inputs, type DataSourceType, type Connection, type JSONForm, type ObjectFieldMap, type ObjectSelection, type ConfigVarResultCollection, type Schedule, type CollectionDataSourceType, type DataSourceReference, type ConfigPage, type ConfigPages, type ConfigPageElement, type ComponentRegistryDataSource, type ComponentRegistryConnection, type UserLevelConfigPages } from ".";
|
|
2
3
|
import type { Prettify, UnionToIntersection } from "./utils";
|
|
3
4
|
/** Supported data types for Config Vars. */
|
|
@@ -105,12 +106,22 @@ type ScheduleConfigVar = CreateStandardConfigVar<"schedule"> & {
|
|
|
105
106
|
};
|
|
106
107
|
type ObjectSelectionConfigVar = CreateStandardConfigVar<"objectSelection">;
|
|
107
108
|
type ObjectFieldMapConfigVar = CreateStandardConfigVar<"objectFieldMap">;
|
|
108
|
-
type JsonFormConfigVar = CreateStandardConfigVar<"jsonForm"
|
|
109
|
+
type JsonFormConfigVar = CreateStandardConfigVar<"jsonForm"> & {
|
|
110
|
+
validationMode?: ValidationMode;
|
|
111
|
+
};
|
|
112
|
+
type JsonFormDataSourceDefinitionConfigVar = DataSourceDefinitionConfigVar & {
|
|
113
|
+
validationMode?: ValidationMode;
|
|
114
|
+
};
|
|
109
115
|
export type StandardConfigVar = StringConfigVar | DateConfigVar | TimestampConfigVar | PicklistConfigVar | CodeConfigVar | BooleanConfigVar | NumberConfigVar | ScheduleConfigVar | ObjectSelectionConfigVar | ObjectFieldMapConfigVar | JsonFormConfigVar;
|
|
110
116
|
type BaseDataSourceConfigVar<TDataSourceType extends DataSourceType = DataSourceType> = TDataSourceType extends CollectionDataSourceType ? {
|
|
111
117
|
dataSourceType: TDataSourceType;
|
|
112
118
|
collectionType?: CollectionType | undefined;
|
|
113
|
-
} & BaseConfigVar : TDataSourceType extends Exclude<DataSourceType, CollectionDataSourceType> ? BaseConfigVar & {
|
|
119
|
+
} & BaseConfigVar : TDataSourceType extends Exclude<DataSourceType, CollectionDataSourceType> ? TDataSourceType extends Extract<DataSourceType, "jsonForm"> ? BaseConfigVar & {
|
|
120
|
+
dataSourceType: Extract<DataSourceType, "jsonForm">;
|
|
121
|
+
dataSource?: never;
|
|
122
|
+
collectionType?: undefined;
|
|
123
|
+
validationMode?: ValidationMode;
|
|
124
|
+
} : BaseConfigVar & {
|
|
114
125
|
dataSourceType: TDataSourceType;
|
|
115
126
|
collectionType?: undefined;
|
|
116
127
|
} : ({
|
|
@@ -123,6 +134,7 @@ type BaseDataSourceConfigVar<TDataSourceType extends DataSourceType = DataSource
|
|
|
123
134
|
type DataSourceDefinitionConfigVar = DataSourceType extends infer TDataSourceType ? TDataSourceType extends DataSourceType ? BaseDataSourceConfigVar<TDataSourceType> & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, TDataSourceType>, "display" | "inputs" | "examplePayload" | "detailDataSource"> : never : never;
|
|
124
135
|
type DataSourceReferenceConfigVar = ComponentRegistryDataSource extends infer TDataSourceReference extends ComponentRegistryDataSource ? Omit<BaseDataSourceConfigVar<TDataSourceReference["dataSourceType"]>, "dataSourceType"> & {
|
|
125
136
|
dataSource: TDataSourceReference["reference"];
|
|
137
|
+
validationMode?: ValidationMode;
|
|
126
138
|
} : never;
|
|
127
139
|
/** Defines attributes of a data source Config Var. */
|
|
128
140
|
export type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar;
|
|
@@ -165,6 +177,8 @@ type ExtractConfigVars<TConfigPages extends {
|
|
|
165
177
|
export type ConfigVars = Prettify<UnionToIntersection<ExtractConfigVars<ConfigPages>>> & Prettify<UnionToIntersection<ExtractConfigVars<UserLevelConfigPages>>>;
|
|
166
178
|
export declare const isCodeConfigVar: (cv: ConfigVar) => cv is CodeConfigVar;
|
|
167
179
|
export declare const isScheduleConfigVar: (cv: ConfigVar) => cv is ScheduleConfigVar;
|
|
180
|
+
export declare const isJsonFormConfigVar: (cv: ConfigVar) => cv is JsonFormConfigVar;
|
|
181
|
+
export declare const isJsonFormDataSourceConfigVar: (cv: ConfigVar) => cv is JsonFormDataSourceDefinitionConfigVar;
|
|
168
182
|
export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar) => cv is DataSourceDefinitionConfigVar;
|
|
169
183
|
export declare const isDataSourceReferenceConfigVar: (cv: unknown) => cv is DataSourceReferenceConfigVar;
|
|
170
184
|
export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar) => cv is ConnectionDefinitionConfigVar;
|
package/dist/types/ConfigVars.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = exports.isCodeConfigVar = void 0;
|
|
3
|
+
exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isJsonFormDataSourceConfigVar = exports.isJsonFormConfigVar = exports.isScheduleConfigVar = exports.isCodeConfigVar = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const isCodeConfigVar = (cv) => "dataType" in cv && cv.dataType === "code";
|
|
6
6
|
exports.isCodeConfigVar = isCodeConfigVar;
|
|
7
7
|
const isScheduleConfigVar = (cv) => "dataType" in cv && cv.dataType === "schedule";
|
|
8
8
|
exports.isScheduleConfigVar = isScheduleConfigVar;
|
|
9
|
+
const isJsonFormConfigVar = (cv) => "dataType" in cv && cv.dataType === "jsonForm";
|
|
10
|
+
exports.isJsonFormConfigVar = isJsonFormConfigVar;
|
|
11
|
+
const isJsonFormDataSourceConfigVar = (cv) => "dataSourceType" in cv && cv.dataSourceType === "jsonForm";
|
|
12
|
+
exports.isJsonFormDataSourceConfigVar = isJsonFormDataSourceConfigVar;
|
|
9
13
|
const isDataSourceDefinitionConfigVar = (cv) => "dataSourceType" in cv && "perform" in cv && typeof cv.perform === "function";
|
|
10
14
|
exports.isDataSourceDefinitionConfigVar = isDataSourceDefinitionConfigVar;
|
|
11
15
|
const isDataSourceReferenceConfigVar = (
|