@prismatic-io/spectral 9.1.0 → 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.
@@ -7,10 +7,10 @@ const getImports = ({ inputs }) => {
7
7
  return acc;
8
8
  }
9
9
  return Object.assign(Object.assign({}, acc), { [input.valueType.module]: acc[input.valueType.module]
10
- ? !acc[input.valueType.module].includes(input.valueType.type)
11
- ? [...acc[input.valueType.module], input.valueType.type]
10
+ ? !acc[input.valueType.module].includes(input.valueType.import)
11
+ ? [...acc[input.valueType.module], input.valueType.import]
12
12
  : acc[input.valueType.module]
13
- : [input.valueType.type] });
13
+ : [input.valueType.import] });
14
14
  }, {});
15
15
  };
16
16
  exports.getImports = getImports;
@@ -4,6 +4,11 @@ export type ServerTypeInput = InputBase & {
4
4
  onPremControlled?: boolean;
5
5
  shown?: boolean;
6
6
  };
7
+ type ValueType = string | {
8
+ type: string;
9
+ import: string;
10
+ module: string;
11
+ };
7
12
  export interface Input {
8
13
  key: string;
9
14
  label: string;
@@ -13,20 +18,14 @@ export interface Input {
13
18
  required: boolean | undefined;
14
19
  default: ServerTypeInput["default"];
15
20
  }
16
- export type ValueType = string | {
17
- type: string;
18
- module: string;
19
- };
20
- export type DocBlock = {
21
- inputKey?: string;
22
- propertyKey: keyof ServerTypeInput;
23
- propertyValue?: unknown;
24
- output?: string;
25
- }[];
26
21
  interface GetInputsProps {
27
22
  inputs: ServerTypeInput[];
28
23
  docBlock?: (input: ServerTypeInput) => string;
29
24
  }
30
25
  export declare const getInputs: ({ inputs, docBlock }: GetInputsProps) => Input[];
31
- export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], ValueType>;
26
+ type InputType = string | {
27
+ type: string;
28
+ module: string;
29
+ };
30
+ export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], InputType>;
32
31
  export {};
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INPUT_TYPE_MAP = exports.getInputs = void 0;
4
4
  const docBlock_1 = require("./docBlock");
5
5
  const getDefaultValue = (value) => {
6
- if (value === undefined || value === "") {
7
- return value;
8
- }
9
- if (typeof value === "string") {
6
+ if (value === undefined || value === "" || typeof value === "string") {
10
7
  return value;
11
8
  }
12
9
  return JSON.stringify(value);
@@ -43,41 +40,50 @@ exports.INPUT_TYPE_MAP = {
43
40
  boolean: "boolean",
44
41
  code: "string",
45
42
  conditional: {
46
- type: "ConditionalExpression",
47
43
  module: "@prismatic-io/spectral",
44
+ type: "ConditionalExpression",
48
45
  },
49
46
  connection: {
50
- type: "Connection",
51
47
  module: "@prismatic-io/spectral",
48
+ type: "Connection",
52
49
  },
53
50
  objectSelection: {
54
- type: "ObjectSelection",
55
51
  module: "@prismatic-io/spectral",
52
+ type: "ObjectSelection",
56
53
  },
57
54
  objectFieldMap: {
58
- type: "ObjectFieldMap",
59
55
  module: "@prismatic-io/spectral",
56
+ type: "ObjectFieldMap",
60
57
  },
61
58
  jsonForm: {
62
- type: "JSONForm",
63
59
  module: "@prismatic-io/spectral",
60
+ type: "JSONForm",
64
61
  },
65
62
  dynamicObjectSelection: "string",
66
63
  dynamicFieldSelection: "string",
67
64
  };
68
65
  const getInputValueType = (input) => {
66
+ const inputType = exports.INPUT_TYPE_MAP[input.type];
69
67
  const valueType = input.model
70
68
  ? input.model
71
69
  .map((choice) => {
72
70
  return `\`${choice.value.replaceAll("\r", "\\r").replaceAll("\n", "\\n")}\``;
73
71
  })
74
72
  .join(" | ")
75
- : exports.INPUT_TYPE_MAP[input.type] || "never";
73
+ : inputType
74
+ ? typeof inputType === "string"
75
+ ? inputType
76
+ : Object.assign(Object.assign({}, inputType), { import: inputType.type })
77
+ : "never";
76
78
  if (input.collection === "keyvaluelist") {
77
- return `Record<string, ${valueType}> | Array<{key: string, value: ${valueType}}>`;
79
+ return typeof valueType === "string"
80
+ ? `Record<string, ${valueType}> | Array<{key: string, value: ${valueType}}>`
81
+ : Object.assign(Object.assign({}, valueType), { type: `Record<string, ${valueType.type}> | Array<{key: string, value: ${valueType.type}}>` });
78
82
  }
79
83
  if (input.collection === "valuelist") {
80
- return `${valueType}[]`;
84
+ return typeof valueType === "string"
85
+ ? `${valueType}[]`
86
+ : Object.assign(Object.assign({}, valueType), { type: `${valueType.type}[]` });
81
87
  }
82
88
  return valueType;
83
89
  };
@@ -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
  };
@@ -410,7 +417,7 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
410
417
  // Construct the component methods from the component registry
411
418
  const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature }]) => {
412
419
  const componentActions = Object.entries(actions).reduce((actionsAccumulator, [registryActionKey, action]) => {
413
- const manifestActions = componentRegistry[componentKey].actions[registryActionKey];
420
+ const manifestActions = componentRegistry[registryComponentKey].actions[registryActionKey];
414
421
  // Define the method to be called for the action
415
422
  const invokeAction = (values) => __awaiter(void 0, void 0, void 0, function* () {
416
423
  var _a;
@@ -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;
@@ -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 = (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "9.1.0",
3
+ "version": "9.1.2",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "files": ["dist/"],
40
40
  "dependencies": {
41
41
  "@jsonforms/core": "3.0.0",
42
- "axios": "1.6.2",
42
+ "axios": "1.7.4",
43
43
  "axios-retry": "3.9.1",
44
44
  "date-fns": "2.30.0",
45
45
  "ejs": "^3.1.10",