@prismatic-io/spectral 7.0.9-pre → 7.0.10-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/index.d.ts +18 -2
- package/dist/serverTypes/index.d.ts +2 -2
- package/dist/testing.d.ts +35 -3
- package/dist/types/DataSourceDefinition.d.ts +6 -6
- package/dist/types/DataSourcePerformFunction.d.ts +2 -2
- package/dist/types/DataSourceResult.d.ts +24 -7
- package/dist/types/Inputs.d.ts +22 -19
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* authors create inputs, actions, and components that can
|
|
4
4
|
* be processed by the Prismatic API.
|
|
5
5
|
*/
|
|
6
|
-
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition } from "./types";
|
|
7
7
|
import { convertComponent } from "./serverTypes/convert";
|
|
8
8
|
/**
|
|
9
9
|
* This function creates a component object that can be
|
|
@@ -43,7 +43,23 @@ export declare const trigger: <TInputs extends Inputs, TAllowsBranching extends
|
|
|
43
43
|
* @param definition A DataSourceDefinition type object that includes UI display information, a function to perform when the data source is invoked, and a an object containing inputs for the perform function.
|
|
44
44
|
* @returns This function validates the shape of the `definition` object provided, and returns the same data source object.
|
|
45
45
|
*/
|
|
46
|
-
export declare const dataSource: <TInputs extends Inputs,
|
|
46
|
+
export declare const dataSource: <TInputs extends Inputs, TDataSourceType extends keyof {
|
|
47
|
+
string: string;
|
|
48
|
+
date: string;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
picklist: import("./types").PickList;
|
|
51
|
+
schedule: {
|
|
52
|
+
value: string;
|
|
53
|
+
};
|
|
54
|
+
code: string;
|
|
55
|
+
credential: unknown;
|
|
56
|
+
boolean: boolean;
|
|
57
|
+
number: number;
|
|
58
|
+
connection: import("./types").ConnectionDefinition;
|
|
59
|
+
objectSelection: import("./types").ObjectSelection;
|
|
60
|
+
objectFieldMap: import("./types").ObjectFieldMap;
|
|
61
|
+
jsonForm: import("./types").JSONForm;
|
|
62
|
+
}>(definition: DataSourceDefinition<TInputs, TDataSourceType>) => DataSourceDefinition<TInputs, TDataSourceType>;
|
|
47
63
|
/**
|
|
48
64
|
* For information and examples on how to write inputs
|
|
49
65
|
* for custom component actions and triggers, see
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { Instance, Customer, DataSourceType, DataSourceResultType } from "../types";
|
|
3
3
|
interface DisplayDefinition {
|
|
4
4
|
label: string;
|
|
5
5
|
description: string;
|
|
@@ -131,7 +131,7 @@ export interface DataSource {
|
|
|
131
131
|
};
|
|
132
132
|
inputs: Input[];
|
|
133
133
|
perform: DataSourcePerformFunction;
|
|
134
|
-
|
|
134
|
+
dataSourceType: DataSourceType;
|
|
135
135
|
examplePayload?: unknown;
|
|
136
136
|
}
|
|
137
137
|
export declare enum OAuth2Type {
|
package/dist/testing.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
|
|
6
6
|
*/
|
|
7
7
|
import { TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn, DataSourceResult } from "./serverTypes";
|
|
8
|
-
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult } from "./types";
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult } from "./types";
|
|
9
9
|
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>) => ConnectionValue;
|
|
10
10
|
/**
|
|
11
11
|
* Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
|
|
@@ -39,7 +39,23 @@ export declare const invokeTrigger: <TInputs extends Inputs, TAllowsBranching ex
|
|
|
39
39
|
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
40
40
|
* casting within test methods. Returns a DataSourceResult.
|
|
41
41
|
*/
|
|
42
|
-
export declare const invokeDataSource: <TInputs extends Inputs,
|
|
42
|
+
export declare const invokeDataSource: <TInputs extends Inputs, TDataSourceType extends keyof {
|
|
43
|
+
string: string;
|
|
44
|
+
date: string;
|
|
45
|
+
timestamp: string;
|
|
46
|
+
picklist: import("./types").PickList;
|
|
47
|
+
schedule: {
|
|
48
|
+
value: string;
|
|
49
|
+
};
|
|
50
|
+
code: string;
|
|
51
|
+
credential: unknown;
|
|
52
|
+
boolean: boolean;
|
|
53
|
+
number: number;
|
|
54
|
+
connection: ConnectionDefinition;
|
|
55
|
+
objectSelection: import("./types").ObjectSelection;
|
|
56
|
+
objectFieldMap: import("./types").ObjectFieldMap;
|
|
57
|
+
jsonForm: import("./types").JSONForm;
|
|
58
|
+
}>({ perform }: DataSourceDefinition<TInputs, TDataSourceType>, params: ActionInputParameters<TInputs>) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
43
59
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
44
60
|
component: TComponent;
|
|
45
61
|
constructor(component: TComponent);
|
|
@@ -54,6 +70,22 @@ declare const _default: {
|
|
|
54
70
|
invoke: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform }: ActionDefinition<TInputs, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
55
71
|
invokeTrigger: <TInputs_1 extends Inputs, TAllowsBranching_1 extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching_1>>({ perform }: TriggerDefinition<TInputs_1, TAllowsBranching_1, TResult>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs_1> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
56
72
|
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
57
|
-
invokeDataSource: <TInputs_2 extends Inputs,
|
|
73
|
+
invokeDataSource: <TInputs_2 extends Inputs, TDataSourceType extends keyof {
|
|
74
|
+
string: string;
|
|
75
|
+
date: string;
|
|
76
|
+
timestamp: string;
|
|
77
|
+
picklist: import("./types").PickList;
|
|
78
|
+
schedule: {
|
|
79
|
+
value: string;
|
|
80
|
+
};
|
|
81
|
+
code: string;
|
|
82
|
+
credential: unknown;
|
|
83
|
+
boolean: boolean;
|
|
84
|
+
number: number;
|
|
85
|
+
connection: ConnectionDefinition;
|
|
86
|
+
objectSelection: import("./types").ObjectSelection;
|
|
87
|
+
objectFieldMap: import("./types").ObjectFieldMap;
|
|
88
|
+
jsonForm: import("./types").JSONForm;
|
|
89
|
+
}>({ perform }: DataSourceDefinition<TInputs_2, TDataSourceType>, params: ActionInputParameters<TInputs_2>) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
58
90
|
};
|
|
59
91
|
export default _default;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ActionDisplayDefinition, DataSourcePerformFunction, Inputs,
|
|
1
|
+
import { ActionDisplayDefinition, DataSourcePerformFunction, Inputs, DataSourceType } from ".";
|
|
2
2
|
/**
|
|
3
3
|
* DataSourceDefinition is the type of the object that is passed in to `dataSource` function to
|
|
4
4
|
* define a component Data Source.
|
|
5
5
|
*/
|
|
6
|
-
export interface DataSourceDefinition<TInputs extends Inputs,
|
|
6
|
+
export interface DataSourceDefinition<TInputs extends Inputs, TDataSourceType extends DataSourceType> {
|
|
7
7
|
/** Defines how the Data Source is displayed in the Prismatic interface. */
|
|
8
8
|
display: ActionDisplayDefinition;
|
|
9
|
-
/** Function to perform when this Data Source is invoked. */
|
|
10
|
-
perform: DataSourcePerformFunction<TInputs,
|
|
11
|
-
/**
|
|
12
|
-
|
|
9
|
+
/** Function to perform when this Data Source is invoked; fetches data from the data source. */
|
|
10
|
+
perform: DataSourcePerformFunction<TInputs, TDataSourceType>;
|
|
11
|
+
/** The type of data that this Data Source represents. */
|
|
12
|
+
dataSourceType: TDataSourceType;
|
|
13
13
|
/** InputFields to present in the Prismatic interface for configuration of this Data Source. */
|
|
14
14
|
inputs: TInputs;
|
|
15
15
|
/** An example of the payload outputted by this Data Source. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Inputs, DataSourceResult,
|
|
1
|
+
import { Inputs, DataSourceResult, DataSourceType, ActionInputParameters } from ".";
|
|
2
2
|
/** Definition of the function to perform when a Data Source is invoked. */
|
|
3
|
-
export declare type DataSourcePerformFunction<
|
|
3
|
+
export declare type DataSourcePerformFunction<TInputs extends Inputs, TDataSourceType extends DataSourceType> = (params: ActionInputParameters<TInputs>) => Promise<DataSourceResult<TDataSourceType>>;
|
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import { ObjectSelection, ObjectFieldMap, JSONForm } from "./Inputs";
|
|
1
|
+
import { ConnectionDefinition } from "./ConnectionDefinition";
|
|
2
|
+
import { ObjectSelection, ObjectFieldMap, JSONForm, PickList } from "./Inputs";
|
|
3
3
|
/** The type of field that is appropriate for rendering the data that is the result of the data source perform function. */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
declare type DataSourceTypeMap = {
|
|
5
|
+
string: string;
|
|
6
|
+
date: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
picklist: PickList;
|
|
9
|
+
schedule: {
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
code: string;
|
|
13
|
+
credential: unknown;
|
|
14
|
+
boolean: boolean;
|
|
15
|
+
number: number;
|
|
16
|
+
connection: ConnectionDefinition;
|
|
17
|
+
objectSelection: ObjectSelection;
|
|
18
|
+
objectFieldMap: ObjectFieldMap;
|
|
19
|
+
jsonForm: JSONForm;
|
|
20
|
+
};
|
|
21
|
+
export declare type DataSourceType = keyof DataSourceTypeMap;
|
|
22
|
+
export declare type DataSourceResultType = DataSourceTypeMap[DataSourceType];
|
|
7
23
|
/** Represents the result of a Data Source action. */
|
|
8
|
-
export declare type DataSourceResult<
|
|
24
|
+
export declare type DataSourceResult<TDataSourceType extends DataSourceType> = {
|
|
9
25
|
/** The resulting data that is returned from the data source. */
|
|
10
|
-
result:
|
|
26
|
+
result: DataSourceTypeMap[TDataSourceType];
|
|
11
27
|
/** Additional data that may be useful for out-of-band processing at a later time.
|
|
12
28
|
* NOTE: This is only available when the Data Source is called as part of fetching
|
|
13
29
|
* contents for a Configuration Wizard Page. */
|
|
@@ -16,3 +32,4 @@ export declare type DataSourceResult<TDataSourceResultType> = {
|
|
|
16
32
|
contentType: string;
|
|
17
33
|
};
|
|
18
34
|
};
|
|
35
|
+
export {};
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { ConditionalExpression } from "./conditional-logic";
|
|
2
|
-
export declare type
|
|
2
|
+
export declare type Element = {
|
|
3
3
|
key: string;
|
|
4
4
|
label?: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
};
|
|
6
|
+
export declare type ObjectSelection = {
|
|
7
|
+
object: Element;
|
|
8
|
+
fields?: Element[];
|
|
9
|
+
defaultSelected?: boolean;
|
|
10
10
|
}[];
|
|
11
11
|
export declare type ObjectFieldMap = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}[];
|
|
12
|
+
fields: {
|
|
13
|
+
field: Element;
|
|
14
|
+
mappedObject?: Element;
|
|
15
|
+
mappedField?: Element;
|
|
16
|
+
defaultObject?: Element;
|
|
17
|
+
defaultField?: Element;
|
|
18
|
+
}[];
|
|
19
|
+
options: {
|
|
20
|
+
object: Element;
|
|
21
|
+
fields: Element[];
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
25
24
|
export declare type JSONForm = {
|
|
26
25
|
schema: Record<string, unknown>;
|
|
27
26
|
uiSchema: Record<string, unknown>;
|
|
28
27
|
data: unknown;
|
|
29
28
|
};
|
|
29
|
+
export declare type PickList = {
|
|
30
|
+
options?: string[];
|
|
31
|
+
selectedValue?: string;
|
|
32
|
+
};
|
|
30
33
|
/** InputField type enumeration. */
|
|
31
34
|
export declare type InputFieldType = InputFieldDefinition["type"];
|
|
32
35
|
export declare const InputFieldDefaultMap: Record<InputFieldType, string | undefined>;
|