@prismatic-io/spectral 9.0.0-rc.9 → 9.0.0
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/generators/componentManifest/cli.js +2 -1
- package/dist/generators/componentManifest/createActions.js +0 -15
- package/dist/generators/componentManifest/createConnections.js +0 -25
- package/dist/generators/componentManifest/createDataSources.js +1 -15
- package/dist/generators/componentManifest/createTriggers.js +0 -15
- package/dist/generators/componentManifest/docBlock.d.ts +10 -0
- package/dist/generators/componentManifest/docBlock.js +40 -0
- package/dist/generators/componentManifest/getInputs.d.ts +5 -7
- package/dist/generators/componentManifest/getInputs.js +23 -44
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +2 -2
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +2 -2
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +3 -2
- package/dist/generators/componentManifest/templates/index.ts.ejs +1 -1
- package/dist/generators/componentManifest/templates/partials/inputs.ejs +2 -3
- package/dist/generators/componentManifest/templates/partials/performArgs.ejs +1 -7
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +2 -2
- package/dist/generators/utils/createTemplate.js +9 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/serverTypes/convertIntegration.js +39 -35
- package/dist/serverTypes/integration.d.ts +2 -0
- package/dist/types/ComponentManifest.d.ts +15 -15
- package/dist/types/ComponentRegistry.d.ts +89 -0
- package/dist/types/ComponentRegistry.js +5 -0
- package/dist/types/ConfigPages.d.ts +46 -0
- package/dist/types/ConfigPages.js +2 -0
- package/dist/types/ConfigVars.d.ts +241 -0
- package/dist/types/ConfigVars.js +30 -0
- package/dist/types/Inputs.d.ts +13 -13
- package/dist/types/IntegrationDefinition.d.ts +1 -220
- package/dist/types/IntegrationDefinition.js +0 -17
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/package.json +3 -2
- /package/dist/serverTypes/{convert.d.ts → convertComponent.d.ts} +0 -0
- /package/dist/serverTypes/{convert.js → convertComponent.js} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CollectionType, DataSourceType, InputFieldType } from ".";
|
|
1
2
|
export interface ComponentManifest {
|
|
2
3
|
key: string;
|
|
3
4
|
public: boolean;
|
|
@@ -7,31 +8,30 @@ export interface ComponentManifest {
|
|
|
7
8
|
dataSources: Record<string, ComponentManifestDataSource>;
|
|
8
9
|
connections: Record<string, ComponentManifestConnection>;
|
|
9
10
|
}
|
|
11
|
+
interface BaseInput {
|
|
12
|
+
inputType: InputFieldType;
|
|
13
|
+
collection?: CollectionType | undefined;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
default?: unknown;
|
|
16
|
+
}
|
|
10
17
|
export interface ComponentManifestAction {
|
|
11
18
|
perform: (values: any) => Promise<unknown>;
|
|
12
|
-
inputs: Record<string,
|
|
13
|
-
inputType: string;
|
|
14
|
-
collection: "keyvaluelist" | "valuelist" | null;
|
|
15
|
-
}>;
|
|
19
|
+
inputs: Record<string, BaseInput>;
|
|
16
20
|
}
|
|
17
21
|
export interface ComponentManifestTrigger {
|
|
18
22
|
perform: (values: any) => Promise<unknown>;
|
|
19
|
-
inputs: Record<string,
|
|
20
|
-
inputType: string;
|
|
21
|
-
collection: "keyvaluelist" | "valuelist" | null;
|
|
22
|
-
}>;
|
|
23
|
+
inputs: Record<string, BaseInput>;
|
|
23
24
|
}
|
|
24
25
|
export interface ComponentManifestDataSource {
|
|
25
26
|
perform: (values: any) => Promise<unknown>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
collection: "keyvaluelist" | "valuelist" | null;
|
|
29
|
-
}>;
|
|
27
|
+
dataSourceType: DataSourceType;
|
|
28
|
+
inputs: Record<string, BaseInput>;
|
|
30
29
|
}
|
|
31
30
|
export interface ComponentManifestConnection {
|
|
32
31
|
perform: (values: any) => Promise<unknown>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
onPremAvailable?: boolean;
|
|
33
|
+
inputs: Record<string, BaseInput & {
|
|
34
|
+
onPremControlled?: boolean;
|
|
36
35
|
}>;
|
|
37
36
|
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ComponentManifest, PermissionAndVisibilityType } from ".";
|
|
2
|
+
import { Prettify, UnionToIntersection } from "./utils";
|
|
3
|
+
/**
|
|
4
|
+
* Root ComponentRegistry type exposed for augmentation.
|
|
5
|
+
*
|
|
6
|
+
* The expected interface when augmenting is:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* interface IntegrationDefinitionComponentRegistry {
|
|
10
|
+
* [key: string]: ComponentManifest
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export interface IntegrationDefinitionComponentRegistry {
|
|
16
|
+
}
|
|
17
|
+
export declare type ComponentRegistry = keyof IntegrationDefinitionComponentRegistry extends never ? {
|
|
18
|
+
[key: string]: ComponentManifest;
|
|
19
|
+
} : UnionToIntersection<keyof IntegrationDefinitionComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof IntegrationDefinitionComponentRegistry ? {
|
|
20
|
+
[Key in TComponentKey]: IntegrationDefinitionComponentRegistry[TComponentKey];
|
|
21
|
+
} : never : never>;
|
|
22
|
+
export interface ConnectionInputPermissionAndVisibility {
|
|
23
|
+
/**
|
|
24
|
+
* Optional value that sets the permission and visibility of the Config Var. @default "customer"
|
|
25
|
+
*
|
|
26
|
+
* "customer" - Customers can view and edit the Config Var.
|
|
27
|
+
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically.
|
|
28
|
+
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization.
|
|
29
|
+
*/
|
|
30
|
+
permissionAndVisibilityType?: PermissionAndVisibilityType;
|
|
31
|
+
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */
|
|
32
|
+
visibleToOrgDeployer?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare type ConfigVarExpression = {
|
|
35
|
+
configVar: string;
|
|
36
|
+
};
|
|
37
|
+
export declare type ValueExpression<TValueType = unknown> = {
|
|
38
|
+
value: TValueType;
|
|
39
|
+
};
|
|
40
|
+
declare type ComponentReferenceType = Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections">;
|
|
41
|
+
declare type ComponentReferenceTypeValueMap<TValue, TMap extends Record<ComponentReferenceType, unknown> = {
|
|
42
|
+
actions: ValueExpression<TValue>;
|
|
43
|
+
triggers: ValueExpression<TValue> | ConfigVarExpression;
|
|
44
|
+
dataSources: ValueExpression<TValue> | ConfigVarExpression;
|
|
45
|
+
connections: (ValueExpression<TValue> | ConfigVarExpression) & ConnectionInputPermissionAndVisibility;
|
|
46
|
+
}> = TMap;
|
|
47
|
+
export declare type ComponentReference<TComponentReference extends {
|
|
48
|
+
component: string;
|
|
49
|
+
key: string;
|
|
50
|
+
values?: {
|
|
51
|
+
[key: string]: ValueExpression | ConfigVarExpression;
|
|
52
|
+
};
|
|
53
|
+
template?: string;
|
|
54
|
+
} = {
|
|
55
|
+
component: string;
|
|
56
|
+
key: string;
|
|
57
|
+
values?: {
|
|
58
|
+
[key: string]: ValueExpression | ConfigVarExpression;
|
|
59
|
+
};
|
|
60
|
+
template?: string;
|
|
61
|
+
}> = TComponentReference;
|
|
62
|
+
export declare const isComponentReference: (ref: unknown) => ref is {
|
|
63
|
+
component: string;
|
|
64
|
+
key: string;
|
|
65
|
+
values?: {
|
|
66
|
+
[key: string]: ConfigVarExpression | ValueExpression<unknown>;
|
|
67
|
+
} | undefined;
|
|
68
|
+
template?: string | undefined;
|
|
69
|
+
};
|
|
70
|
+
declare type ComponentRegistryFunctionsByType = UnionToIntersection<ComponentReferenceType extends infer TComponentReferenceType ? TComponentReferenceType extends Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections"> ? {
|
|
71
|
+
[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 ? Prettify<Omit<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey], "perform"> & {
|
|
72
|
+
reference: ComponentReference<{
|
|
73
|
+
component: TComponentKey;
|
|
74
|
+
key: TComponentPropertyKey;
|
|
75
|
+
values: {
|
|
76
|
+
[Key in keyof TInputs]: ComponentReferenceTypeValueMap<TInputs[Key]>[TComponentReferenceType];
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
79
|
+
}> : never : never : never : never : never : never : never : never : never : never;
|
|
80
|
+
} : never : never>;
|
|
81
|
+
export declare type ComponentRegistryTrigger = ComponentRegistryFunctionsByType["triggers"];
|
|
82
|
+
export declare type TriggerReference = ComponentRegistryTrigger["reference"];
|
|
83
|
+
export declare type ComponentRegistryAction = ComponentRegistryFunctionsByType["actions"];
|
|
84
|
+
export declare type ActionReference = ComponentRegistryAction["reference"];
|
|
85
|
+
export declare type ComponentRegistryDataSource = ComponentRegistryFunctionsByType["dataSources"];
|
|
86
|
+
export declare type DataSourceReference = ComponentRegistryDataSource["reference"];
|
|
87
|
+
export declare type ComponentRegistryConnection = ComponentRegistryFunctionsByType["connections"];
|
|
88
|
+
export declare type ConnectionReference = ComponentRegistryConnection["reference"];
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isComponentReference = void 0;
|
|
4
|
+
const isComponentReference = (ref) => typeof ref === "object" && ref !== null && "key" in ref && "component" in ref;
|
|
5
|
+
exports.isComponentReference = isComponentReference;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ConfigVar } from ".";
|
|
2
|
+
import { UnionToIntersection } from "./utils";
|
|
3
|
+
/**
|
|
4
|
+
* Root ConfigPages type exposed for augmentation.
|
|
5
|
+
*
|
|
6
|
+
* The expected interface when augmenting is:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* interface IntegrationDefinitionConfigPages {
|
|
10
|
+
* [key: string]: ConfigPage
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export interface IntegrationDefinitionConfigPages {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Root UserLevelConfigPages type exposed for augmentation.
|
|
19
|
+
*
|
|
20
|
+
* The expected interface when augmenting is:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* interface IntegrationDefinitionUserLevelConfigPages {
|
|
24
|
+
* [key: string]: ConfigPage
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export interface IntegrationDefinitionUserLevelConfigPages {
|
|
30
|
+
}
|
|
31
|
+
export declare type ConfigPageElement = string | ConfigVar;
|
|
32
|
+
declare type CreateConfigPages<TIntegrationDefinitionConfigPages> = keyof TIntegrationDefinitionConfigPages extends never ? {
|
|
33
|
+
[key: string]: ConfigPage;
|
|
34
|
+
} : UnionToIntersection<keyof TIntegrationDefinitionConfigPages extends infer TPageName ? TPageName extends keyof TIntegrationDefinitionConfigPages ? TIntegrationDefinitionConfigPages[TPageName] extends ConfigPage ? {
|
|
35
|
+
[Key in TPageName]: TIntegrationDefinitionConfigPages[TPageName];
|
|
36
|
+
} : never : never : never>;
|
|
37
|
+
export declare type ConfigPages = CreateConfigPages<IntegrationDefinitionConfigPages>;
|
|
38
|
+
export declare type UserLevelConfigPages = CreateConfigPages<IntegrationDefinitionUserLevelConfigPages>;
|
|
39
|
+
/** Defines attributes of a Config Wizard Page used when deploying an Instance of an Integration. */
|
|
40
|
+
export interface ConfigPage {
|
|
41
|
+
/** Elements included on this Config Page. */
|
|
42
|
+
elements: Record<string, ConfigPageElement>;
|
|
43
|
+
/** Specifies an optional tagline for this Config Page. */
|
|
44
|
+
tagline?: string;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { DataSourceDefinition, ConnectionDefinition, Inputs, DataSourceType, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule, CollectionDataSourceType, DataSourceReference, ConfigPage, ConfigPages, UserLevelConfigPages, ConfigPageElement, ComponentRegistryDataSource, ComponentRegistryConnection } from ".";
|
|
2
|
+
import { Prettify, UnionToIntersection } from "./utils";
|
|
3
|
+
/** Supported data types for Config Vars. */
|
|
4
|
+
export declare type ConfigVarDataType = "string" | "date" | "timestamp" | "picklist" | "code" | "boolean" | "number" | "schedule" | "objectSelection" | "objectFieldMap" | "jsonForm";
|
|
5
|
+
declare type ConfigVarDataTypeDefaultValueMap<TMap extends Record<ConfigVarDataType, unknown> = {
|
|
6
|
+
string: string;
|
|
7
|
+
date: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
picklist: string;
|
|
10
|
+
code: string;
|
|
11
|
+
boolean: boolean;
|
|
12
|
+
number: number;
|
|
13
|
+
schedule: string;
|
|
14
|
+
objectSelection: ObjectSelection;
|
|
15
|
+
objectFieldMap: ObjectFieldMap;
|
|
16
|
+
jsonForm: JSONForm;
|
|
17
|
+
}> = TMap;
|
|
18
|
+
declare type ConfigVarDataTypeRuntimeValueMap<TMap extends Record<ConfigVarDataType, unknown> = {
|
|
19
|
+
string: string;
|
|
20
|
+
date: string;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
picklist: string;
|
|
23
|
+
code: string;
|
|
24
|
+
boolean: boolean;
|
|
25
|
+
number: number;
|
|
26
|
+
schedule: Schedule;
|
|
27
|
+
objectSelection: ObjectSelection;
|
|
28
|
+
objectFieldMap: ObjectFieldMap;
|
|
29
|
+
jsonForm: unknown;
|
|
30
|
+
}> = TMap;
|
|
31
|
+
/** Choices of collection types for multi-value Config Vars. */
|
|
32
|
+
export declare type CollectionType = "valuelist" | "keyvaluelist";
|
|
33
|
+
export declare type PermissionAndVisibilityType = "customer" | "embedded" | "organization";
|
|
34
|
+
declare type ConfigVarSingleDataType = Extract<ConfigVarDataType, "schedule" | "objectSelection" | "objectFieldMap" | "jsonForm">;
|
|
35
|
+
/** Common attribute shared by all types of Config Vars. */
|
|
36
|
+
declare type BaseConfigVar = {
|
|
37
|
+
/** A unique, unchanging value that is used to maintain identity for the Config Var even if the key changes. */
|
|
38
|
+
stableKey: string;
|
|
39
|
+
/** Optional description for this Config Var. */
|
|
40
|
+
description?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Optional value that sets the permission and visibility of the Config Var. @default "customer"
|
|
43
|
+
*
|
|
44
|
+
* "customer" - Customers can view and edit the Config Var.
|
|
45
|
+
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically.
|
|
46
|
+
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization.
|
|
47
|
+
*/
|
|
48
|
+
permissionAndVisibilityType?: PermissionAndVisibilityType;
|
|
49
|
+
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */
|
|
50
|
+
visibleToOrgDeployer?: boolean;
|
|
51
|
+
};
|
|
52
|
+
declare type GetDynamicProperties<TValue, TCollectionType extends CollectionType | undefined> = TCollectionType extends undefined ? {
|
|
53
|
+
defaultValue?: TValue;
|
|
54
|
+
/** Optional value to specify the type of collection if the Config Var is multi-value. */
|
|
55
|
+
collectionType?: undefined;
|
|
56
|
+
} : TCollectionType extends "valuelist" ? {
|
|
57
|
+
defaultValue?: TValue[];
|
|
58
|
+
/** Optional value to specify the type of collection if the Config Var is multi-value. */
|
|
59
|
+
collectionType: "valuelist";
|
|
60
|
+
} : {
|
|
61
|
+
defaultValue?: Record<string, TValue> | Array<{
|
|
62
|
+
key: string;
|
|
63
|
+
value: TValue;
|
|
64
|
+
}>;
|
|
65
|
+
/** Optional value to specify the type of collection if the Config Var is multi-value. */
|
|
66
|
+
collectionType: "keyvaluelist";
|
|
67
|
+
};
|
|
68
|
+
declare type StandardConfigVarDynamicProperties<TDataType extends ConfigVarDataType> = CollectionType | undefined extends infer TCollectionType ? TCollectionType extends CollectionType | undefined ? TDataType extends ConfigVarSingleDataType ? TCollectionType extends undefined ? GetDynamicProperties<ConfigVarDataTypeDefaultValueMap[TDataType], undefined> : never : GetDynamicProperties<ConfigVarDataTypeDefaultValueMap[TDataType], TCollectionType> : never : never;
|
|
69
|
+
declare type CreateStandardConfigVar<TDataType extends ConfigVarDataType> = BaseConfigVar & StandardConfigVarDynamicProperties<TDataType> & {
|
|
70
|
+
/** The data type of the Config Var. */
|
|
71
|
+
dataType: TDataType;
|
|
72
|
+
};
|
|
73
|
+
declare type StringConfigVar = CreateStandardConfigVar<"string">;
|
|
74
|
+
declare type DateConfigVar = CreateStandardConfigVar<"date">;
|
|
75
|
+
declare type TimestampConfigVar = CreateStandardConfigVar<"timestamp">;
|
|
76
|
+
declare type PicklistConfigVar = CreateStandardConfigVar<"picklist"> & {
|
|
77
|
+
/** List of picklist values. */
|
|
78
|
+
pickList: string[];
|
|
79
|
+
};
|
|
80
|
+
/** Choices of programming languages that may be used for Config Var code values. */
|
|
81
|
+
export declare type CodeLanguageType = "json" | "xml" | "html";
|
|
82
|
+
declare type CodeConfigVar = CreateStandardConfigVar<"code"> & {
|
|
83
|
+
/** Value to specify the type of language of a code Config Var. */
|
|
84
|
+
codeLanguage: CodeLanguageType;
|
|
85
|
+
};
|
|
86
|
+
declare type BooleanConfigVar = CreateStandardConfigVar<"boolean">;
|
|
87
|
+
declare type NumberConfigVar = CreateStandardConfigVar<"number">;
|
|
88
|
+
declare type ScheduleConfigVar = CreateStandardConfigVar<"schedule"> & {
|
|
89
|
+
/** Optional timezone for the schedule. */
|
|
90
|
+
timeZone?: string;
|
|
91
|
+
};
|
|
92
|
+
declare type ObjectSelectionConfigVar = CreateStandardConfigVar<"objectSelection">;
|
|
93
|
+
declare type ObjectFieldMapConfigVar = CreateStandardConfigVar<"objectFieldMap">;
|
|
94
|
+
declare type JsonFormConfigVar = CreateStandardConfigVar<"jsonForm">;
|
|
95
|
+
export declare type StandardConfigVar = StringConfigVar | DateConfigVar | TimestampConfigVar | PicklistConfigVar | CodeConfigVar | BooleanConfigVar | NumberConfigVar | ScheduleConfigVar | ObjectSelectionConfigVar | ObjectFieldMapConfigVar | JsonFormConfigVar;
|
|
96
|
+
declare type BaseDataSourceConfigVar<TDataSourceType extends DataSourceType = DataSourceType> = TDataSourceType extends CollectionDataSourceType ? {
|
|
97
|
+
dataSourceType: TDataSourceType;
|
|
98
|
+
collectionType?: CollectionType | undefined;
|
|
99
|
+
} & BaseConfigVar : TDataSourceType extends Exclude<DataSourceType, CollectionDataSourceType> ? BaseConfigVar & {
|
|
100
|
+
dataSourceType: TDataSourceType;
|
|
101
|
+
collectionType?: undefined;
|
|
102
|
+
} : ({
|
|
103
|
+
dataSourceType: Extract<CollectionDataSourceType, TDataSourceType>;
|
|
104
|
+
collectionType: CollectionType;
|
|
105
|
+
} & BaseConfigVar) | (BaseConfigVar & {
|
|
106
|
+
dataSourceType: Extract<Exclude<DataSourceType, CollectionDataSourceType>, TDataSourceType>;
|
|
107
|
+
collectionType?: undefined;
|
|
108
|
+
});
|
|
109
|
+
declare type DataSourceDefinitionConfigVar = DataSourceType extends infer TDataSourceType ? TDataSourceType extends DataSourceType ? BaseDataSourceConfigVar<TDataSourceType> & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, TDataSourceType>, "display" | "inputs" | "examplePayload" | "detailDataSource"> : never : never;
|
|
110
|
+
declare type DataSourceReferenceConfigVar = ComponentRegistryDataSource extends infer TDataSourceReference ? TDataSourceReference extends ComponentRegistryDataSource ? Omit<BaseDataSourceConfigVar<TDataSourceReference["dataSourceType"]>, "dataSourceType"> & {
|
|
111
|
+
dataSource: TDataSourceReference["reference"];
|
|
112
|
+
} : never : never;
|
|
113
|
+
/** Defines attributes of a data source Config Var. */
|
|
114
|
+
export declare type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar;
|
|
115
|
+
declare type BaseConnectionConfigVar = BaseConfigVar & {
|
|
116
|
+
dataType: "connection";
|
|
117
|
+
};
|
|
118
|
+
declare type ConnectionDefinitionConfigVar = BaseConnectionConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
|
|
119
|
+
declare type OnPremiseConnectionConfigTypeEnum = "allowed" | "disallowed" | "required";
|
|
120
|
+
declare type ConnectionReferenceConfigVar = ComponentRegistryConnection extends infer TConnectionReference ? TConnectionReference extends ComponentRegistryConnection ? BaseConnectionConfigVar & {
|
|
121
|
+
connection: TConnectionReference["reference"] & ("onPremAvailable" extends keyof TConnectionReference ? TConnectionReference["onPremAvailable"] extends true ? {
|
|
122
|
+
template?: string;
|
|
123
|
+
onPremiseConnectionConfig?: OnPremiseConnectionConfigTypeEnum;
|
|
124
|
+
} : {
|
|
125
|
+
template?: string;
|
|
126
|
+
onPremiseConnectionConfig?: undefined;
|
|
127
|
+
} : {
|
|
128
|
+
template?: string;
|
|
129
|
+
onPremiseConnectionConfig?: undefined;
|
|
130
|
+
});
|
|
131
|
+
} : never : never;
|
|
132
|
+
/** Defines attributes of a Config Var that represents a Connection. */
|
|
133
|
+
export declare type ConnectionConfigVar = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar;
|
|
134
|
+
export declare type ConfigVar = StandardConfigVar | DataSourceConfigVar | ConnectionConfigVar;
|
|
135
|
+
declare type WithCollectionType<TValue, TCollectionType extends CollectionType | undefined> = undefined | unknown extends TCollectionType ? TValue : TCollectionType extends "valuelist" ? TValue[] : Array<{
|
|
136
|
+
key: string;
|
|
137
|
+
value: TValue;
|
|
138
|
+
}>;
|
|
139
|
+
declare type GetDataSourceReference<TComponent extends DataSourceReference["component"], TKey extends DataSourceReference["key"]> = ComponentRegistryDataSource extends infer TDataSourceReference ? TDataSourceReference extends ComponentRegistryDataSource ? TComponent extends TDataSourceReference["reference"]["component"] ? TKey extends TDataSourceReference["reference"]["key"] ? TDataSourceReference : never : never : never : never;
|
|
140
|
+
declare type DataSourceToRuntimeType<TElement extends ConfigPageElement> = TElement extends DataSourceDefinitionConfigVar ? TElement["dataSourceType"] extends infer TType ? TType extends DataSourceType ? ConfigVarDataTypeRuntimeValueMap[TType] : never : never : TElement extends DataSourceReferenceConfigVar ? GetDataSourceReference<TElement["dataSource"]["component"], TElement["dataSource"]["key"]>["dataSourceType"] extends infer TType ? TType extends DataSourceType ? ConfigVarDataTypeRuntimeValueMap[TType] : never : never : never;
|
|
141
|
+
declare type ElementToRuntimeType<TElement extends ConfigPageElement> = TElement extends ConfigVar ? TElement extends ConnectionConfigVar ? Connection : TElement extends StandardConfigVar ? WithCollectionType<ConfigVarDataTypeRuntimeValueMap[TElement["dataType"]], TElement["collectionType"]> : TElement extends DataSourceConfigVar ? WithCollectionType<DataSourceToRuntimeType<TElement>, TElement["collectionType"]> : never : never;
|
|
142
|
+
declare type ExtractConfigVars<TConfigPages extends {
|
|
143
|
+
[key: string]: ConfigPage;
|
|
144
|
+
}> = keyof TConfigPages extends infer TPageName ? TPageName extends keyof TConfigPages ? TConfigPages[TPageName] extends infer TConfigPage ? TConfigPage extends ConfigPage ? {
|
|
145
|
+
[Key in keyof TConfigPage["elements"] as Key extends string ? TConfigPage["elements"][Key] extends ConfigVar ? Key : never : never]: ElementToRuntimeType<TConfigPage["elements"][Key]>;
|
|
146
|
+
} : never : never : never : never;
|
|
147
|
+
export declare type ConfigVars = Prettify<UnionToIntersection<ExtractConfigVars<ConfigPages> | ExtractConfigVars<UserLevelConfigPages>>>;
|
|
148
|
+
export declare const isCodeConfigVar: (cv: ConfigVar) => cv is CodeConfigVar;
|
|
149
|
+
export declare const isScheduleConfigVar: (cv: ConfigVar) => cv is ScheduleConfigVar;
|
|
150
|
+
export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar) => cv is ({
|
|
151
|
+
dataSourceType: "string";
|
|
152
|
+
collectionType?: CollectionType | undefined;
|
|
153
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "string">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
154
|
+
dataSourceType: "number";
|
|
155
|
+
collectionType?: CollectionType | undefined;
|
|
156
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "number">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
157
|
+
dataSourceType: "boolean";
|
|
158
|
+
collectionType?: CollectionType | undefined;
|
|
159
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "boolean">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
160
|
+
dataSourceType: "code";
|
|
161
|
+
collectionType?: CollectionType | undefined;
|
|
162
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "code">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | (BaseConfigVar & {
|
|
163
|
+
dataSourceType: "objectSelection";
|
|
164
|
+
collectionType?: undefined;
|
|
165
|
+
} & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "objectSelection">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | (BaseConfigVar & {
|
|
166
|
+
dataSourceType: "objectFieldMap";
|
|
167
|
+
collectionType?: undefined;
|
|
168
|
+
} & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "objectFieldMap">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | (BaseConfigVar & {
|
|
169
|
+
dataSourceType: "jsonForm";
|
|
170
|
+
collectionType?: undefined;
|
|
171
|
+
} & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "jsonForm">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
172
|
+
dataSourceType: "date";
|
|
173
|
+
collectionType?: CollectionType | undefined;
|
|
174
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "date">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
175
|
+
dataSourceType: "timestamp";
|
|
176
|
+
collectionType?: CollectionType | undefined;
|
|
177
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "timestamp">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
178
|
+
dataSourceType: "picklist";
|
|
179
|
+
collectionType?: CollectionType | undefined;
|
|
180
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "picklist">, "display" | "inputs" | "examplePayload" | "detailDataSource">) | ({
|
|
181
|
+
dataSourceType: "schedule";
|
|
182
|
+
collectionType?: CollectionType | undefined;
|
|
183
|
+
} & BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, "schedule">, "display" | "inputs" | "examplePayload" | "detailDataSource">);
|
|
184
|
+
export declare const isDataSourceReferenceConfigVar: (cv: unknown) => cv is Omit<({
|
|
185
|
+
dataSourceType: "string";
|
|
186
|
+
collectionType?: CollectionType | undefined;
|
|
187
|
+
} & BaseConfigVar) | ({
|
|
188
|
+
dataSourceType: "number";
|
|
189
|
+
collectionType?: CollectionType | undefined;
|
|
190
|
+
} & BaseConfigVar) | ({
|
|
191
|
+
dataSourceType: "boolean";
|
|
192
|
+
collectionType?: CollectionType | undefined;
|
|
193
|
+
} & BaseConfigVar) | ({
|
|
194
|
+
dataSourceType: "code";
|
|
195
|
+
collectionType?: CollectionType | undefined;
|
|
196
|
+
} & BaseConfigVar) | (BaseConfigVar & {
|
|
197
|
+
dataSourceType: "objectSelection";
|
|
198
|
+
collectionType?: undefined;
|
|
199
|
+
}) | (BaseConfigVar & {
|
|
200
|
+
dataSourceType: "objectFieldMap";
|
|
201
|
+
collectionType?: undefined;
|
|
202
|
+
}) | (BaseConfigVar & {
|
|
203
|
+
dataSourceType: "jsonForm";
|
|
204
|
+
collectionType?: undefined;
|
|
205
|
+
}) | ({
|
|
206
|
+
dataSourceType: "date";
|
|
207
|
+
collectionType?: CollectionType | undefined;
|
|
208
|
+
} & BaseConfigVar) | ({
|
|
209
|
+
dataSourceType: "timestamp";
|
|
210
|
+
collectionType?: CollectionType | undefined;
|
|
211
|
+
} & BaseConfigVar) | ({
|
|
212
|
+
dataSourceType: "picklist";
|
|
213
|
+
collectionType?: CollectionType | undefined;
|
|
214
|
+
} & BaseConfigVar) | ({
|
|
215
|
+
dataSourceType: "schedule";
|
|
216
|
+
collectionType?: CollectionType | undefined;
|
|
217
|
+
} & BaseConfigVar), "dataSourceType"> & {
|
|
218
|
+
dataSource: {
|
|
219
|
+
component: string;
|
|
220
|
+
key: string;
|
|
221
|
+
values: {
|
|
222
|
+
[x: string]: import("./ComponentRegistry").ConfigVarExpression | import("./ComponentRegistry").ValueExpression<any>;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar) => cv is ConnectionDefinitionConfigVar;
|
|
227
|
+
export declare const isConnectionReferenceConfigVar: (cv: unknown) => cv is BaseConfigVar & {
|
|
228
|
+
dataType: "connection";
|
|
229
|
+
} & {
|
|
230
|
+
connection: {
|
|
231
|
+
component: string;
|
|
232
|
+
key: string;
|
|
233
|
+
values: {
|
|
234
|
+
[x: string]: (import("./ComponentRegistry").ConfigVarExpression | import("./ComponentRegistry").ValueExpression<any>) & import("./ComponentRegistry").ConnectionInputPermissionAndVisibility;
|
|
235
|
+
};
|
|
236
|
+
} & {
|
|
237
|
+
template?: string | undefined;
|
|
238
|
+
onPremiseConnectionConfig?: undefined;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = exports.isCodeConfigVar = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const isCodeConfigVar = (cv) => "dataType" in cv && cv.dataType === "code";
|
|
6
|
+
exports.isCodeConfigVar = isCodeConfigVar;
|
|
7
|
+
const isScheduleConfigVar = (cv) => "dataType" in cv && cv.dataType === "schedule";
|
|
8
|
+
exports.isScheduleConfigVar = isScheduleConfigVar;
|
|
9
|
+
const isDataSourceDefinitionConfigVar = (cv) => "dataSourceType" in cv && "perform" in cv && typeof cv.perform === "function";
|
|
10
|
+
exports.isDataSourceDefinitionConfigVar = isDataSourceDefinitionConfigVar;
|
|
11
|
+
const isDataSourceReferenceConfigVar = (
|
|
12
|
+
// FIXME: Module augmetation causes this to produce a compile error while
|
|
13
|
+
// running `tsd`. I'm pretty uncertain how this happens but leaving as
|
|
14
|
+
// `unkonwn` is fine for now.
|
|
15
|
+
cv) => typeof cv === "object" &&
|
|
16
|
+
cv !== null &&
|
|
17
|
+
"dataSource" in cv &&
|
|
18
|
+
(0, _1.isComponentReference)(cv.dataSource);
|
|
19
|
+
exports.isDataSourceReferenceConfigVar = isDataSourceReferenceConfigVar;
|
|
20
|
+
const isConnectionDefinitionConfigVar = (cv) => "dataType" in cv && cv.dataType === "connection" && "inputs" in cv;
|
|
21
|
+
exports.isConnectionDefinitionConfigVar = isConnectionDefinitionConfigVar;
|
|
22
|
+
const isConnectionReferenceConfigVar = (
|
|
23
|
+
// FIXME: Module augmetation causes this to produce a compile error while
|
|
24
|
+
// running `tsd`. I'm pretty uncertain how this happens but leaving as
|
|
25
|
+
// `unkonwn` is fine for now.
|
|
26
|
+
cv) => typeof cv === "object" &&
|
|
27
|
+
cv !== null &&
|
|
28
|
+
"connection" in cv &&
|
|
29
|
+
(0, _1.isComponentReference)(cv.connection);
|
|
30
|
+
exports.isConnectionReferenceConfigVar = isConnectionReferenceConfigVar;
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -106,48 +106,48 @@ interface KeyValueListCollection<T> {
|
|
|
106
106
|
/** Default value for this field. */
|
|
107
107
|
default?: KeyValuePair<T>[];
|
|
108
108
|
}
|
|
109
|
-
export declare type StringInputField = BaseInputField &
|
|
109
|
+
export declare type StringInputField = BaseInputField & {
|
|
110
110
|
/** Data type the InputField will collect. */
|
|
111
111
|
type: "string";
|
|
112
112
|
/** Dictates possible choices for the input. */
|
|
113
113
|
model?: InputFieldChoice[];
|
|
114
114
|
/** Clean function */
|
|
115
115
|
clean?: InputCleanFunction<unknown>;
|
|
116
|
-
}
|
|
117
|
-
export declare type DataInputField = BaseInputField &
|
|
116
|
+
} & CollectionOptions<string>;
|
|
117
|
+
export declare type DataInputField = BaseInputField & {
|
|
118
118
|
/** Data type the InputField will collect. */
|
|
119
119
|
type: "data";
|
|
120
120
|
/** Dictates possible choices for the input. */
|
|
121
121
|
model?: InputFieldChoice[];
|
|
122
122
|
/** Clean function */
|
|
123
123
|
clean?: InputCleanFunction<unknown>;
|
|
124
|
-
}
|
|
125
|
-
export declare type TextInputField = BaseInputField &
|
|
124
|
+
} & CollectionOptions<string>;
|
|
125
|
+
export declare type TextInputField = BaseInputField & {
|
|
126
126
|
/** Data type the InputField will collect. */
|
|
127
127
|
type: "text";
|
|
128
128
|
/** Dictates possible choices for the input. */
|
|
129
129
|
model?: InputFieldChoice[];
|
|
130
130
|
/** Clean function */
|
|
131
131
|
clean?: InputCleanFunction<unknown>;
|
|
132
|
-
}
|
|
133
|
-
export declare type PasswordInputField = BaseInputField &
|
|
132
|
+
} & CollectionOptions<string>;
|
|
133
|
+
export declare type PasswordInputField = BaseInputField & {
|
|
134
134
|
/** Data type the InputField will collect. */
|
|
135
135
|
type: "password";
|
|
136
136
|
/** Dictates possible choices for the input. */
|
|
137
137
|
model?: InputFieldChoice[];
|
|
138
138
|
/** Clean function */
|
|
139
139
|
clean?: InputCleanFunction<unknown>;
|
|
140
|
-
}
|
|
141
|
-
export declare type BooleanInputField = BaseInputField &
|
|
140
|
+
} & CollectionOptions<string>;
|
|
141
|
+
export declare type BooleanInputField = BaseInputField & {
|
|
142
142
|
/** Data type the InputField will collect. */
|
|
143
143
|
type: "boolean";
|
|
144
144
|
/** Dictates possible choices for the input. */
|
|
145
145
|
model?: InputFieldChoice[];
|
|
146
146
|
/** Clean function */
|
|
147
147
|
clean?: InputCleanFunction<unknown>;
|
|
148
|
-
}
|
|
148
|
+
} & CollectionOptions<string>;
|
|
149
149
|
/** Defines attributes of a CodeInputField. */
|
|
150
|
-
export declare type CodeInputField = BaseInputField &
|
|
150
|
+
export declare type CodeInputField = BaseInputField & {
|
|
151
151
|
/** Data type the InputField will collect. */
|
|
152
152
|
type: "code";
|
|
153
153
|
/** Code language for syntax highlighting. For no syntax highlighting, choose "plaintext" */
|
|
@@ -156,7 +156,7 @@ export declare type CodeInputField = BaseInputField & CollectionOptions<string>
|
|
|
156
156
|
model?: InputFieldChoice[];
|
|
157
157
|
/** Clean function */
|
|
158
158
|
clean?: InputCleanFunction<unknown>;
|
|
159
|
-
}
|
|
159
|
+
} & CollectionOptions<string>;
|
|
160
160
|
/** Defines attributes of a ConditionalInputField. */
|
|
161
161
|
export interface ConditionalInputField extends BaseInputField {
|
|
162
162
|
/** Data type the InputField will collect. */
|
|
@@ -256,5 +256,5 @@ export interface InputFieldChoice {
|
|
|
256
256
|
/** InputField collection enumeration */
|
|
257
257
|
export declare type InputFieldCollection = "valuelist" | "keyvaluelist";
|
|
258
258
|
/** Config variable result collection */
|
|
259
|
-
export declare type ConfigVarResultCollection = Record<string, string | Schedule | Connection |
|
|
259
|
+
export declare type ConfigVarResultCollection = Record<string, string | Schedule | Connection | unknown | ObjectSelection | ObjectFieldMap>;
|
|
260
260
|
export {};
|