@prismatic-io/spectral
Advanced tools
Comparing version 9.0.0-rc.9 to 9.0.0-rc.10
@@ -20,2 +20,3 @@ "use strict"; | ||
const fs_extra_1 = require("fs-extra"); | ||
const lodash_1 = require("lodash"); | ||
const index_1 = require("./index"); | ||
@@ -120,3 +121,3 @@ const createFlagHelpText_1 = require("../utils/createFlagHelpText"); | ||
skipSignatureVerify: flags.skip_signature_verify.value, | ||
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@component-manifests/${component.key}`, | ||
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@component-manifests/${(0, lodash_1.kebabCase)(component.key)}`, | ||
dependencies: { | ||
@@ -123,0 +124,0 @@ spectral: packageJson.version, |
@@ -5,2 +5,3 @@ import type { Input as InputBase } from "../../serverTypes"; | ||
onPremControlled?: boolean; | ||
shown?: boolean; | ||
}; | ||
@@ -7,0 +8,0 @@ export interface Input { |
@@ -5,18 +5,41 @@ "use strict"; | ||
const getInputs = ({ inputs, docBlock }) => { | ||
return inputs.map((input) => { | ||
return { | ||
key: input.key, | ||
label: input.label, | ||
inputType: input.type, | ||
valueType: getInputValueType(input), | ||
required: input.required, | ||
collection: input.collection, | ||
onPremControlled: input.onPremiseControlled || input.onPremControlled, | ||
properties: docBlock.reduce((acc, { propertyKey, inputKey, propertyValue, output }) => { | ||
if (inputKey && inputKey !== input.key) { | ||
return acc; | ||
} | ||
if (output && | ||
(input[propertyKey] === propertyValue || | ||
typeof propertyValue === "undefined")) { | ||
return inputs.reduce((acc, input) => { | ||
if ((typeof input.shown === "boolean" && input.shown === false) || | ||
input.type === "dynamicObjectSelection" || | ||
input.type === "dynamicFieldSelection") { | ||
return acc; | ||
} | ||
return [ | ||
...acc, | ||
{ | ||
key: input.key, | ||
label: input.label, | ||
inputType: input.type, | ||
valueType: getInputValueType(input), | ||
required: input.required && | ||
(input.default === undefined || input.default === ""), | ||
collection: input.collection, | ||
onPremControlled: input.onPremiseControlled || input.onPremControlled, | ||
properties: docBlock.reduce((acc, { propertyKey, inputKey, propertyValue, output }) => { | ||
if (inputKey && inputKey !== input.key) { | ||
return acc; | ||
} | ||
if (output && | ||
(input[propertyKey] === propertyValue || | ||
typeof propertyValue === "undefined")) { | ||
return [ | ||
...acc, | ||
{ | ||
key: propertyKey, | ||
value: output, | ||
}, | ||
]; | ||
} | ||
if (typeof input[propertyKey] === "undefined" || | ||
input[propertyKey] === null || | ||
input[propertyKey] === "" || | ||
(typeof propertyValue !== "undefined" && | ||
input[propertyKey] !== propertyValue)) { | ||
return acc; | ||
} | ||
return [ | ||
@@ -26,25 +49,11 @@ ...acc, | ||
key: propertyKey, | ||
value: output, | ||
value: JSON.stringify(input[propertyKey]) | ||
.replace(/(^"|"$)|(^'|'$)/g, "") | ||
.trim(), | ||
}, | ||
]; | ||
} | ||
if (typeof input[propertyKey] === "undefined" || | ||
input[propertyKey] === null || | ||
input[propertyKey] === "" || | ||
(typeof propertyValue !== "undefined" && | ||
input[propertyKey] !== propertyValue)) { | ||
return acc; | ||
} | ||
return [ | ||
...acc, | ||
{ | ||
key: propertyKey, | ||
value: JSON.stringify(input[propertyKey]) | ||
.replace(/(^"|"$)|(^'|'$)/g, "") | ||
.trim(), | ||
}, | ||
]; | ||
}, []), | ||
}; | ||
}); | ||
}, []), | ||
}, | ||
]; | ||
}, []); | ||
}; | ||
@@ -51,0 +60,0 @@ exports.getInputs = getInputs; |
@@ -6,4 +6,4 @@ /** | ||
*/ | ||
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ScheduleConfigVar, ComponentManifest } from "./types"; | ||
import { convertComponent } from "./serverTypes/convert"; | ||
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ComponentManifest } from "./types"; | ||
import { convertComponent } from "./serverTypes/convertComponent"; | ||
import { convertIntegration } from "./serverTypes/convertIntegration"; | ||
@@ -39,3 +39,3 @@ /** | ||
*/ | ||
export declare const configVar: <T extends StandardConfigVar | ScheduleConfigVar>(definition: T) => T; | ||
export declare const configVar: <T extends StandardConfigVar>(definition: T) => T; | ||
/** | ||
@@ -42,0 +42,0 @@ * For information on writing Code Native Integrations, see |
@@ -26,3 +26,3 @@ "use strict"; | ||
exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0; | ||
const convert_1 = require("./serverTypes/convert"); | ||
const convertComponent_1 = require("./serverTypes/convertComponent"); | ||
const convertIntegration_1 = require("./serverTypes/convertIntegration"); | ||
@@ -100,3 +100,3 @@ /** | ||
*/ | ||
const component = (definition) => (0, convert_1.convertComponent)(definition); | ||
const component = (definition) => (0, convertComponent_1.convertComponent)(definition); | ||
exports.component = component; | ||
@@ -103,0 +103,0 @@ /** |
@@ -31,3 +31,3 @@ "use strict"; | ||
const types_1 = require("../types"); | ||
const convert_1 = require("./convert"); | ||
const convertComponent_1 = require("./convertComponent"); | ||
const integration_1 = require("./integration"); | ||
@@ -166,2 +166,5 @@ const convertIntegration = (definition) => { | ||
const manifest = componentRegistry[componentReference.component]; | ||
if (!manifest) { | ||
throw new Error(`Component with key "${componentReference.component}" not found in component registry.`); | ||
} | ||
const ref = { | ||
@@ -287,2 +290,15 @@ component: { | ||
}; | ||
/** Converts an input value to the expected server type by its collection type */ | ||
const convertInputValue = (value, collectionType) => { | ||
if (collectionType !== "keyvaluelist") { | ||
return value; | ||
} | ||
if (Array.isArray(value)) { | ||
return value; | ||
} | ||
return Object.entries(value).map(([key, value]) => ({ | ||
key, | ||
value, | ||
})); | ||
}; | ||
/** Converts a Config Var into the structure necessary for YAML generation. */ | ||
@@ -333,6 +349,13 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => { | ||
} | ||
const result = (0, lodash_1.assign)({ orgOnly, meta, key }, (0, lodash_1.pick)(configVar, [ | ||
const rawDefaultValue = "defaultValue" in configVar | ||
? convertInputValue(configVar.defaultValue, configVar.collectionType) | ||
: undefined; | ||
const defaultValue = typeof rawDefaultValue !== "undefined" | ||
? typeof rawDefaultValue === "string" | ||
? rawDefaultValue | ||
: JSON.stringify(rawDefaultValue) | ||
: undefined; | ||
const result = (0, lodash_1.assign)({ orgOnly, meta, key, defaultValue }, (0, lodash_1.pick)(configVar, [ | ||
"stableKey", | ||
"description", | ||
"defaultValue", | ||
"dataType", | ||
@@ -381,4 +404,5 @@ "pickList", | ||
const convertOnExecution = (onExecution, componentRegistry) => (context, params) => { | ||
const { | ||
// @ts-expect-error _components isn't part of the public API | ||
const { _components } = context, remainingContext = __rest(context, ["_components"]); | ||
_components } = context, remainingContext = __rest(context, ["_components"]); | ||
const invoke = _components | ||
@@ -388,29 +412,9 @@ .invoke; | ||
const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature },]) => { | ||
// Create an object to hold the methods for each action | ||
const methods = Object.keys(actions).reduce((methodsAccumulator, actionKey) => { | ||
const action = actions[actionKey]; | ||
const componentActions = Object.entries(actions).reduce((actionsAccumulator, [actionKey, action]) => { | ||
// Define the method to be called for the action | ||
methodsAccumulator[actionKey] = (values) => __awaiter(void 0, void 0, void 0, function* () { | ||
const invokeAction = (values) => __awaiter(void 0, void 0, void 0, function* () { | ||
// Transform the input values based on the action's inputs | ||
const transformedValues = Object.entries(values).reduce((transformedAccumulator, [inputKey, inputValue]) => { | ||
const { collection } = action.inputs[inputKey]; | ||
if (collection === "keyvaluelist" && | ||
Array.isArray(inputValue)) { | ||
transformedAccumulator[inputKey] = inputValue.reduce((acc, { key, value }) => { | ||
return [...acc, { key, value }]; | ||
}, []); | ||
return transformedAccumulator; | ||
} | ||
// Transform key-value list inputs | ||
if (collection === "keyvaluelist" && | ||
Object.keys(inputValue).length) { | ||
transformedAccumulator[inputKey] = Object.entries(inputValue).map(([keyItem, valueItem]) => ({ | ||
key: keyItem, | ||
value: valueItem, | ||
})); | ||
} | ||
else { | ||
transformedAccumulator[inputKey] = inputValue; | ||
} | ||
return transformedAccumulator; | ||
return Object.assign(Object.assign({}, transformedAccumulator), { [inputKey]: convertInputValue(inputValue, collection) }); | ||
}, {}); | ||
@@ -427,7 +431,5 @@ // Invoke the action with the transformed values | ||
}); | ||
return methodsAccumulator; | ||
return Object.assign(Object.assign({}, actionsAccumulator), { [actionKey]: invokeAction }); | ||
}, {}); | ||
// Add the methods to the accumulator under the registry component key | ||
accumulator[registryComponentKey] = methods; | ||
return accumulator; | ||
return Object.assign(Object.assign({}, accumulator), { [registryComponentKey]: componentActions }); | ||
}, {}); | ||
@@ -487,3 +489,3 @@ return onExecution(Object.assign(Object.assign({}, remainingContext), { components: componentMethods }), params); | ||
} | ||
const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convert_1.convertInput)(key, value)); | ||
const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convertComponent_1.convertInput)(key, value)); | ||
const connection = (0, lodash_1.pick)(configVar, ["oauth2Type", "iconPath"]); | ||
@@ -490,0 +492,0 @@ return [ |
@@ -0,1 +1,2 @@ | ||
import { CollectionType, InputFieldType } from "."; | ||
export interface ComponentManifest { | ||
@@ -10,29 +11,27 @@ key: string; | ||
} | ||
interface BaseInput { | ||
inputType: InputFieldType; | ||
collection?: CollectionType | undefined; | ||
required?: boolean; | ||
default?: unknown; | ||
} | ||
export interface ComponentManifestAction { | ||
perform: (values: any) => Promise<unknown>; | ||
inputs: Record<string, { | ||
inputType: string; | ||
collection: "keyvaluelist" | "valuelist" | null; | ||
}>; | ||
inputs: Record<string, BaseInput>; | ||
} | ||
export interface ComponentManifestTrigger { | ||
perform: (values: any) => Promise<unknown>; | ||
inputs: Record<string, { | ||
inputType: string; | ||
collection: "keyvaluelist" | "valuelist" | null; | ||
}>; | ||
inputs: Record<string, BaseInput>; | ||
} | ||
export interface ComponentManifestDataSource { | ||
perform: (values: any) => Promise<unknown>; | ||
inputs: Record<string, { | ||
inputType: string; | ||
collection: "keyvaluelist" | "valuelist" | null; | ||
}>; | ||
inputs: Record<string, BaseInput>; | ||
} | ||
export interface ComponentManifestConnection { | ||
perform: (values: any) => Promise<unknown>; | ||
inputs: Record<string, { | ||
inputType: string; | ||
collection: "keyvaluelist" | "valuelist" | null; | ||
onPremAvailable?: boolean; | ||
inputs: Record<string, BaseInput & { | ||
onPremControlled?: boolean; | ||
}>; | ||
} | ||
export {}; |
@@ -7,2 +7,5 @@ /** | ||
export * from "./ComponentDefinition"; | ||
export * from "./ComponentRegistry"; | ||
export * from "./ConfigPages"; | ||
export * from "./ConfigVars"; | ||
export * from "./ConnectionDefinition"; | ||
@@ -9,0 +12,0 @@ export * from "./Inputs"; |
@@ -36,2 +36,5 @@ "use strict"; | ||
__exportStar(require("./ComponentDefinition"), exports); | ||
__exportStar(require("./ComponentRegistry"), exports); | ||
__exportStar(require("./ConfigPages"), exports); | ||
__exportStar(require("./ConfigVars"), exports); | ||
__exportStar(require("./ConnectionDefinition"), exports); | ||
@@ -38,0 +41,0 @@ __exportStar(require("./Inputs"), exports); |
@@ -259,3 +259,3 @@ import { ConditionalExpression } from "./conditional-logic"; | ||
/** Config variable result collection */ | ||
export declare type ConfigVarResultCollection = Record<string, string | Schedule | Connection | JSONForm | ObjectSelection | ObjectFieldMap>; | ||
export declare type ConfigVarResultCollection = Record<string, string | Schedule | Connection | unknown | ObjectSelection | ObjectFieldMap>; | ||
export {}; |
@@ -1,45 +0,2 @@ | ||
import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule, CollectionDataSourceType, ComponentManifest } from "."; | ||
import { Prettify, UnionToIntersection } from "./utils"; | ||
/** | ||
* Root ComponentRegistry type exposed for augmentation. | ||
* | ||
* The expected interface when augmenting is: | ||
* | ||
* ```ts | ||
* interface IntegrationDefinitionComponentRegistry { | ||
* [key: string]: ComponentManifest | ||
* } | ||
* ``` | ||
* | ||
*/ | ||
export interface IntegrationDefinitionComponentRegistry { | ||
} | ||
/** | ||
* Root ConfigPages type exposed for augmentation. | ||
* | ||
* The expected interface when augmenting is: | ||
* | ||
* ```ts | ||
* interface IntegrationDefinitionConfigPages { | ||
* [key: string]: ConfigPage | ||
* } | ||
* ``` | ||
* | ||
*/ | ||
export interface IntegrationDefinitionConfigPages { | ||
} | ||
/** | ||
* Root UserLevelConfigPages type exposed for augmentation. | ||
* | ||
* The expected interface when augmenting is: | ||
* | ||
* ```ts | ||
* interface IntegrationDefinitionUserLevelConfigPages { | ||
* [key: string]: ConfigPage | ||
* } | ||
* ``` | ||
* | ||
*/ | ||
export interface IntegrationDefinitionUserLevelConfigPages { | ||
} | ||
import { ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, TriggerPayload, ComponentRegistry, TriggerReference, ConfigVars, ConfigPages, UserLevelConfigPages, ValueExpression, ConfigVarExpression } from "."; | ||
/** Defines attributes of a Code-Native Integration. */ | ||
@@ -119,163 +76,2 @@ export declare type IntegrationDefinition = { | ||
} | ||
export declare type PermissionAndVisibilityType = "customer" | "embedded" | "organization"; | ||
/** Common attribute shared by all types of Config Vars. */ | ||
declare type BaseConfigVar = { | ||
/** A unique, unchanging value that is used to maintain identity for the Config Var even if the key changes. */ | ||
stableKey: string; | ||
/** Optional description for this Config Var. */ | ||
description?: string; | ||
/** | ||
* Optional value that sets the permission and visibility of the Config Var. @default "customer" | ||
* | ||
* "customer" - Customers can view and edit the Config Var. | ||
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically. | ||
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization. | ||
*/ | ||
permissionAndVisibilityType?: PermissionAndVisibilityType; | ||
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */ | ||
visibleToOrgDeployer?: boolean; | ||
/** Optional default value for the Config Var. */ | ||
defaultValue?: string; | ||
/** Optional list of picklist values if the Config Var is a multi-choice selection value. */ | ||
pickList?: string[]; | ||
/** Optional value to specify the type of collection if the Config Var is multi-value. */ | ||
collectionType?: CollectionType; | ||
}; | ||
/** Defines attributes of a standard Config Var. */ | ||
export declare type StandardConfigVar = BaseConfigVar & { | ||
/** The data type of the Config Var. */ | ||
dataType: Exclude<ConfigVarDataType, "schedule" | "code">; | ||
}; | ||
export declare type CodeConfigVar = BaseConfigVar & { | ||
/** The data type of the Config Var. */ | ||
dataType: "code"; | ||
/** Optional default value for the Config Var. */ | ||
defaultValue?: string; | ||
/** Optional value to specify the type of language if the Config Var is a code value. */ | ||
codeLanguage?: CodeLanguageType; | ||
}; | ||
export declare type ScheduleConfigVar = Omit<BaseConfigVar, "collectionType"> & { | ||
/** The data type of the Config Var. */ | ||
dataType: "schedule"; | ||
/** Optional default value for the Config Var. */ | ||
defaultValue?: string; | ||
/** Optional timezone for the schedule. */ | ||
timeZone?: string; | ||
}; | ||
export declare type ComponentRegistry = keyof IntegrationDefinitionComponentRegistry extends never ? { | ||
[key: string]: ComponentManifest; | ||
} : UnionToIntersection<keyof IntegrationDefinitionComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof IntegrationDefinitionComponentRegistry ? { | ||
[Key in TComponentKey]: IntegrationDefinitionComponentRegistry[TComponentKey]; | ||
} : never : never>; | ||
interface ConnectionInputPermissionAndVisibility { | ||
/** | ||
* Optional value that sets the permission and visibility of the Config Var. @default "customer" | ||
* | ||
* "customer" - Customers can view and edit the Config Var. | ||
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically. | ||
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization. | ||
*/ | ||
permissionAndVisibilityType?: PermissionAndVisibilityType; | ||
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */ | ||
visibleToOrgDeployer?: boolean; | ||
} | ||
declare type ComponentReferenceType = Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections">; | ||
declare type ComponentReferenceTypeValueMap<TValue, TMap extends Record<ComponentReferenceType, unknown> = { | ||
actions: ValueExpression<TValue>; | ||
triggers: ValueExpression<TValue> | ConfigVarExpression; | ||
dataSources: ValueExpression<TValue> | ConfigVarExpression; | ||
connections: (ValueExpression<TValue> | ConfigVarExpression) & ConnectionInputPermissionAndVisibility; | ||
}> = TMap; | ||
export declare type ComponentReference<TComponentReference extends { | ||
component: string; | ||
isPublic: boolean; | ||
key: string; | ||
values?: { | ||
[key: string]: ValueExpression | ConfigVarExpression; | ||
}; | ||
template?: string; | ||
} = { | ||
component: string; | ||
isPublic: boolean; | ||
key: string; | ||
values?: { | ||
[key: string]: ValueExpression | ConfigVarExpression; | ||
}; | ||
template?: string; | ||
}> = TComponentReference; | ||
export declare const isComponentReference: (ref: unknown) => ref is { | ||
component: string; | ||
isPublic: boolean; | ||
key: string; | ||
values?: { | ||
[key: string]: ConfigVarExpression | ValueExpression<unknown>; | ||
} | undefined; | ||
template?: string | undefined; | ||
}; | ||
declare type ComponentReferencesByType = UnionToIntersection<ComponentReferenceType extends infer TComponentReferenceType ? TComponentReferenceType extends Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections"> ? { | ||
[Key in TComponentReferenceType]: keyof ComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof ComponentRegistry ? TComponentKey extends string ? TComponentReferenceType extends keyof ComponentRegistry[TComponentKey] ? keyof ComponentRegistry[TComponentKey][TComponentReferenceType] extends infer TComponentPropertyKey ? TComponentPropertyKey extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType] ? TComponentPropertyKey extends string ? "perform" extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey] ? ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]["perform"] extends (...args: any[]) => any ? Parameters<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]["perform"]>[0] extends infer TInputs ? ComponentReference<{ | ||
component: TComponentKey; | ||
isPublic: ComponentRegistry[TComponentKey]["public"]; | ||
key: TComponentPropertyKey; | ||
values: { | ||
[Key in keyof TInputs]: ComponentReferenceTypeValueMap<TInputs[Key]>[TComponentReferenceType]; | ||
}; | ||
}> : never : never : never : never : never : never : never : never : never : never; | ||
} : never : never>; | ||
export declare type TriggerReference = ComponentReferencesByType["triggers"]; | ||
export declare type ActionReference = ComponentReferencesByType["actions"]; | ||
export declare type DataSourceReference = ComponentReferencesByType["dataSources"]; | ||
export declare type ConnectionReference = ComponentReferencesByType["connections"]; | ||
declare type BaseDataSourceConfigVar = ({ | ||
dataSourceType: CollectionDataSourceType; | ||
} & BaseConfigVar) | ({ | ||
dataSourceType: Exclude<DataSourceType, CollectionDataSourceType>; | ||
} & Omit<BaseConfigVar, "collectionType">); | ||
declare type DataSourceDefinitionConfigVar = BaseDataSourceConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload" | "dataSourceType" | "detailDataSource">; | ||
export declare type DataSourceReferenceConfigVar = BaseDataSourceConfigVar & { | ||
dataSource: DataSourceReference; | ||
}; | ||
/** Defines attributes of a data source Config Var. */ | ||
export declare type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar; | ||
declare type BaseConnectionConfigVar = Omit<BaseConfigVar, "collectionType"> & { | ||
dataType: "connection"; | ||
}; | ||
declare type ConnectionDefinitionConfigVar = BaseConnectionConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">; | ||
declare type ConnectionReferenceConfigVar = BaseConnectionConfigVar & { | ||
connection: ConnectionReference & { | ||
template?: string; | ||
}; | ||
}; | ||
/** Defines attributes of a Config Var that represents a Connection. */ | ||
export declare type ConnectionConfigVar = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar; | ||
export declare type ConfigVar = StandardConfigVar | CodeConfigVar | ScheduleConfigVar | DataSourceConfigVar | ConnectionConfigVar; | ||
export declare const isCodeConfigVar: (cv: ConfigVar) => cv is CodeConfigVar; | ||
export declare const isScheduleConfigVar: (cv: ConfigVar) => cv is ScheduleConfigVar; | ||
export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar) => cv is DataSourceDefinitionConfigVar; | ||
export declare const isDataSourceReferenceConfigVar: (cv: ConfigVar) => cv is DataSourceReferenceConfigVar; | ||
export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar) => cv is ConnectionDefinitionConfigVar; | ||
export declare const isConnectionReferenceConfigVar: (cv: ConfigVar) => cv is ConnectionReferenceConfigVar; | ||
export declare type ConfigPageElement = string | ConfigVar; | ||
declare type CreateConfigPages<TIntegrationDefinitionConfigPages> = keyof TIntegrationDefinitionConfigPages extends never ? { | ||
[key: string]: ConfigPage; | ||
} : UnionToIntersection<keyof TIntegrationDefinitionConfigPages extends infer TPageName ? TPageName extends keyof TIntegrationDefinitionConfigPages ? TIntegrationDefinitionConfigPages[TPageName] extends ConfigPage ? { | ||
[Key in TPageName]: TIntegrationDefinitionConfigPages[TPageName]; | ||
} : never : never : never>; | ||
export declare type ConfigPages = CreateConfigPages<IntegrationDefinitionConfigPages>; | ||
export declare type UserLevelConfigPages = CreateConfigPages<IntegrationDefinitionUserLevelConfigPages>; | ||
declare type ExtractConfigVars<TConfigPages extends { | ||
[key: string]: ConfigPage; | ||
}> = keyof TConfigPages extends infer TPageName ? TPageName extends keyof TConfigPages ? TConfigPages[TPageName] extends infer TConfigPage ? TConfigPage extends ConfigPage ? { | ||
[Key in keyof TConfigPage["elements"] as Key extends string ? TConfigPage["elements"][Key] extends ConfigVar ? Key : never : never]: ElementToRuntimeType<TConfigPage["elements"][Key]>; | ||
} : never : never : never : never; | ||
export declare type ConfigVars = Prettify<UnionToIntersection<ExtractConfigVars<ConfigPages> | ExtractConfigVars<UserLevelConfigPages>>>; | ||
export declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string; | ||
export declare type ElementToRuntimeType<TElement extends ConfigPageElement> = TElement extends ConnectionConfigVar ? Connection : TElement extends DataSourceConfigVar ? ToDataSourceRuntimeType<TElement["dataSourceType"]> : TElement extends ScheduleConfigVar ? Schedule : TElement extends StandardConfigVar ? string : never; | ||
/** Defines attributes of a Config Wizard Page used when deploying an Instance of an Integration. */ | ||
export interface ConfigPage { | ||
/** Elements included on this Config Page. */ | ||
elements: Record<string, ConfigPageElement>; | ||
/** Specifies an optional tagline for this Config Page. */ | ||
tagline?: string; | ||
} | ||
/** Defines attributes of a Preprocess Flow Configuration used by a Flow of an Integration. */ | ||
@@ -320,16 +116,1 @@ export declare type PreprocessFlowConfig = { | ||
export declare type StepErrorHandlerType = "fail" | "ignore" | "retry"; | ||
/** Supported data types for Config Vars. */ | ||
export declare type ConfigVarDataType = "string" | "date" | "timestamp" | "picklist" | "schedule" | "code" | "boolean" | "number"; | ||
/** Choices of programming languages that may be used for Config Var code values. */ | ||
export declare type CodeLanguageType = "json" | "xml" | "html"; | ||
/** Choices of collection types for multi-value Config Vars. */ | ||
export declare type CollectionType = "valuelist" | "keyvaluelist"; | ||
/** Choices of component reference types. */ | ||
export declare type ComponentSelectorType = "trigger" | "connection" | "dataSource"; | ||
export declare type ConfigVarExpression = { | ||
configVar: string; | ||
}; | ||
export declare type ValueExpression<TValueType = unknown> = { | ||
value: TValueType; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = exports.isCodeConfigVar = exports.isComponentReference = void 0; | ||
const isComponentReference = (ref) => typeof ref === "object" && ref !== null && "key" in ref && "component" in ref; | ||
exports.isComponentReference = isComponentReference; | ||
const isCodeConfigVar = (cv) => "dataType" in cv && cv.dataType === "code"; | ||
exports.isCodeConfigVar = isCodeConfigVar; | ||
const isScheduleConfigVar = (cv) => "dataType" in cv && cv.dataType === "schedule"; | ||
exports.isScheduleConfigVar = isScheduleConfigVar; | ||
const isDataSourceDefinitionConfigVar = (cv) => "dataSourceType" in cv && "perform" in cv && typeof cv.perform === "function"; | ||
exports.isDataSourceDefinitionConfigVar = isDataSourceDefinitionConfigVar; | ||
const isDataSourceReferenceConfigVar = (cv) => "dataSourceType" in cv && | ||
"dataSource" in cv && | ||
(0, exports.isComponentReference)(cv.dataSource); | ||
exports.isDataSourceReferenceConfigVar = isDataSourceReferenceConfigVar; | ||
const isConnectionDefinitionConfigVar = (cv) => "dataType" in cv && cv.dataType === "connection" && "inputs" in cv; | ||
exports.isConnectionDefinitionConfigVar = isConnectionDefinitionConfigVar; | ||
const isConnectionReferenceConfigVar = (cv) => "connection" in cv && (0, exports.isComponentReference)(cv.connection); | ||
exports.isConnectionReferenceConfigVar = isConnectionReferenceConfigVar; |
{ | ||
"name": "@prismatic-io/spectral", | ||
"version": "9.0.0-rc.9", | ||
"version": "9.0.0-rc.10", | ||
"description": "Utility library for building Prismatic components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
301872
150
6371