@prismatic-io/spectral 8.1.6 → 9.0.0-rc.1

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.
Files changed (76) hide show
  1. package/bin/component-manifest.js +2 -0
  2. package/dist/generators/componentManifest/cli.d.ts +2 -0
  3. package/dist/generators/componentManifest/cli.js +134 -0
  4. package/dist/generators/componentManifest/createActions.d.ts +13 -0
  5. package/dist/generators/componentManifest/createActions.js +95 -0
  6. package/dist/generators/componentManifest/createConnections.d.ts +13 -0
  7. package/dist/generators/componentManifest/createConnections.js +95 -0
  8. package/dist/generators/componentManifest/createDataSources.d.ts +13 -0
  9. package/dist/generators/componentManifest/createDataSources.js +95 -0
  10. package/dist/generators/componentManifest/createStaticFiles.d.ts +80 -0
  11. package/dist/generators/componentManifest/createStaticFiles.js +145 -0
  12. package/dist/generators/componentManifest/createTriggers.d.ts +13 -0
  13. package/dist/generators/componentManifest/createTriggers.js +95 -0
  14. package/dist/generators/componentManifest/getImports.d.ts +7 -0
  15. package/dist/generators/componentManifest/getImports.js +16 -0
  16. package/dist/generators/componentManifest/getInputs.d.ts +23 -0
  17. package/dist/generators/componentManifest/getInputs.js +66 -0
  18. package/dist/generators/componentManifest/helpers.d.ts +5 -0
  19. package/dist/generators/componentManifest/helpers.js +11 -0
  20. package/dist/generators/componentManifest/index.d.ts +15 -0
  21. package/dist/generators/componentManifest/index.js +78 -0
  22. package/dist/generators/componentManifest/removeComponentManifest.d.ts +6 -0
  23. package/dist/generators/componentManifest/removeComponentManifest.js +19 -0
  24. package/dist/generators/componentManifest/templates/README.md.ejs +186 -0
  25. package/dist/generators/componentManifest/templates/actions/action.ts.ejs +14 -0
  26. package/dist/generators/componentManifest/templates/actions/index.ts.ejs +1 -0
  27. package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +14 -0
  28. package/dist/generators/componentManifest/templates/connections/index.ts.ejs +1 -0
  29. package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +14 -0
  30. package/dist/generators/componentManifest/templates/dataSources/index.ts.ejs +1 -0
  31. package/dist/generators/componentManifest/templates/index.ts.ejs +20 -0
  32. package/dist/generators/componentManifest/templates/package.json.ejs +23 -0
  33. package/dist/generators/componentManifest/templates/partials/importBarrel.ejs +9 -0
  34. package/dist/generators/componentManifest/templates/partials/imports.ejs +1 -0
  35. package/dist/generators/componentManifest/templates/partials/inputTypes.ejs +10 -0
  36. package/dist/generators/componentManifest/templates/triggers/index.ts.ejs +1 -0
  37. package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +14 -0
  38. package/dist/generators/componentManifest/templates/tsconfig.json.ejs +15 -0
  39. package/dist/generators/utils/capitalizeFirstLetter.d.ts +1 -0
  40. package/dist/generators/utils/capitalizeFirstLetter.js +5 -0
  41. package/dist/generators/utils/createDependencyImports.d.ts +5 -0
  42. package/dist/generators/utils/createDependencyImports.js +9 -0
  43. package/dist/generators/utils/createFlagHelpText.d.ts +12 -0
  44. package/dist/generators/utils/createFlagHelpText.js +19 -0
  45. package/dist/generators/utils/createTemplate.d.ts +9 -0
  46. package/dist/generators/utils/createTemplate.js +59 -0
  47. package/dist/generators/utils/generatePackageJsonVersion.d.ts +1 -0
  48. package/dist/generators/utils/generatePackageJsonVersion.js +14 -0
  49. package/dist/generators/utils/getComponentSignatureWithPrism.d.ts +1 -0
  50. package/dist/generators/utils/getComponentSignatureWithPrism.js +39 -0
  51. package/dist/generators/utils/getFlagBooleanValue.d.ts +11 -0
  52. package/dist/generators/utils/getFlagBooleanValue.js +17 -0
  53. package/dist/generators/utils/getFlagStringValue.d.ts +11 -0
  54. package/dist/generators/utils/getFlagStringValue.js +25 -0
  55. package/dist/generators/utils/truncatePathByFolder.d.ts +1 -0
  56. package/dist/generators/utils/truncatePathByFolder.js +5 -0
  57. package/dist/index.d.ts +14 -15
  58. package/dist/index.js +9 -9
  59. package/dist/serverTypes/convertIntegration.d.ts +2 -2
  60. package/dist/serverTypes/convertIntegration.js +97 -43
  61. package/dist/serverTypes/index.d.ts +3 -2
  62. package/dist/serverTypes/integration.d.ts +12 -4
  63. package/dist/testing.d.ts +7 -7
  64. package/dist/testing.js +1 -1
  65. package/dist/types/ActionDefinition.d.ts +2 -1
  66. package/dist/types/ActionPerformFunction.d.ts +5 -3
  67. package/dist/types/ComponentManifest.d.ts +13 -0
  68. package/dist/types/ComponentManifest.js +2 -0
  69. package/dist/types/DataSourceResult.d.ts +1 -0
  70. package/dist/types/IntegrationDefinition.d.ts +148 -77
  71. package/dist/types/IntegrationDefinition.js +9 -5
  72. package/dist/types/index.d.ts +1 -0
  73. package/dist/types/index.js +1 -0
  74. package/dist/util.d.ts +2 -0
  75. package/dist/util.js +17 -10
  76. package/package.json +12 -6
@@ -1,13 +1,35 @@
1
- import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule } from ".";
2
- import { Prettify, UnionToIntersection, ValueOf } from "./utils";
3
- export declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string;
4
- export declare type ElementToRuntimeType<TElement extends ConfigPageElement<any>> = TElement extends ConnectionConfigVar<any> ? Connection : TElement extends DataSourceConfigVar<any> ? ToDataSourceRuntimeType<TElement["dataSourceType"]> : TElement extends ScheduleConfigVar ? Schedule : TElement extends StandardConfigVar ? string : never;
5
- export declare type GetElements<TConfigPages extends ConfigPages<any>> = TConfigPages extends ConfigPages<any> ? UnionToIntersection<ValueOf<TConfigPages>["elements"]> : never;
6
- export declare type ExtractConfigVars<TConfigPages extends ConfigPages<any>, TElements extends ConfigPage<any>["elements"] = GetElements<TConfigPages>> = Prettify<{
7
- [Key in keyof TElements as Key extends string ? Key : never]: ElementToRuntimeType<TElements[Key]>;
8
- }>;
1
+ import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule, CollectionDataSourceType, ComponentManifest } 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
+ /**
18
+ * Root ConfigPages type exposed for augmentation.
19
+ *
20
+ * The expected interface when augmenting is:
21
+ *
22
+ * ```ts
23
+ * interface IntegrationDefinitionConfigPages {
24
+ * [key: string]: ConfigPage
25
+ * }
26
+ * ```
27
+ *
28
+ */
29
+ export interface IntegrationDefinitionConfigPages {
30
+ }
9
31
  /** Defines attributes of a Code-Native Integration. */
10
- export declare type IntegrationDefinition<TConfigPages extends ConfigPages<TComponents>, TComponents extends ComponentSelector<any>> = {
32
+ export declare type IntegrationDefinition = {
11
33
  /** The unique name for this Integration. */
12
34
  name: string;
13
35
  /** Optional description for this Integration. */
@@ -30,12 +52,13 @@ export declare type IntegrationDefinition<TConfigPages extends ConfigPages<TComp
30
52
  * Cannot specify this if a Preprocess Flow is also configured. */
31
53
  triggerPreprocessFlowConfig?: PreprocessFlowConfig;
32
54
  /** Flows for this Integration. */
33
- flows: Flow<TConfigPages, TComponents>[];
55
+ flows: Flow[];
34
56
  /** Config Wizard Pages for this Integration. */
35
- configPages?: TConfigPages;
57
+ configPages?: ConfigPages;
58
+ componentRegistry?: ComponentRegistry;
36
59
  };
37
60
  /** Defines attributes of a Flow of a Code-Native Integration. */
38
- export interface Flow<TConfigPages extends ConfigPages<TComponents>, TComponents extends ComponentSelector<any>, TTriggerPayload extends TriggerPayload = TriggerPayload> {
61
+ export interface Flow<TTriggerPayload extends TriggerPayload = TriggerPayload> {
39
62
  /** The unique name for this Flow. */
40
63
  name: string;
41
64
  /** A unique, unchanging value that is used to maintain identity for the Flow even if the name changes. */
@@ -53,17 +76,17 @@ export interface Flow<TConfigPages extends ConfigPages<TComponents>, TComponents
53
76
  /** Optional list of API key(s) to use for the endpoint of this Flow when the endpoint security type is EndpointSecurityType.Organization. */
54
77
  organizationApiKeys?: string[];
55
78
  /** Optional schedule configuration that defines the frequency with which this Flow will be automatically executed. */
56
- schedule?: ValueReference<string, TConfigPages> & {
79
+ schedule?: (ValueExpression<string> | ConfigVarExpression) & {
57
80
  timezone?: string;
58
81
  };
59
82
  /** Optional error handling configuration. */
60
83
  errorConfig?: StepErrorConfig;
61
84
  /** Specifies the trigger function for this Flow, which returns a payload and optional HTTP response. */
62
- onTrigger?: ToComponentReferences<"trigger", TComponents, TConfigPages> | TriggerPerformFunction<Inputs, ExtractConfigVars<TConfigPages>, false, TriggerResult<false, TTriggerPayload>>;
85
+ onTrigger?: TriggerReference | TriggerPerformFunction<Inputs, ConfigVars, false, TriggerResult<false, TTriggerPayload>>;
63
86
  /** Specifies the function to execute when an Instance of this Integration is deployed. */
64
- onInstanceDeploy?: TriggerEventFunction<Inputs, ExtractConfigVars<TConfigPages>>;
87
+ onInstanceDeploy?: TriggerEventFunction<Inputs, ConfigVars>;
65
88
  /** Specifies the function to execute when an Instance of an Integration is deleted. */
66
- onInstanceDelete?: TriggerEventFunction<Inputs, ExtractConfigVars<TConfigPages>>;
89
+ onInstanceDelete?: TriggerEventFunction<Inputs, ConfigVars>;
67
90
  /** Specifies the main function for this Flow */
68
91
  onExecution: ActionPerformFunction<{
69
92
  onTrigger: {
@@ -73,7 +96,9 @@ export interface Flow<TConfigPages extends ConfigPages<TComponents>, TComponents
73
96
  results: TTriggerPayload;
74
97
  };
75
98
  };
76
- }, ExtractConfigVars<TConfigPages>, false, ActionPerformReturn<false, unknown>>;
99
+ }, ConfigVars, {
100
+ [Key in keyof ComponentRegistry]: ComponentRegistry[Key]["actions"];
101
+ }, false, ActionPerformReturn<false, unknown>>;
77
102
  }
78
103
  /** Common attribute shared by all types of Config Vars. */
79
104
  declare type BaseConfigVar = {
@@ -87,21 +112,27 @@ declare type BaseConfigVar = {
87
112
  visibleToOrgDeployer?: boolean;
88
113
  /** Optional value that specifies whether this Config Var is visible to a Customer deployer. @default true */
89
114
  visibleToCustomerDeployer?: boolean;
115
+ /** Optional default value for the Config Var. */
116
+ defaultValue?: string;
117
+ /** Optional list of picklist values if the Config Var is a multi-choice selection value. */
118
+ pickList?: string[];
119
+ /** Optional value to specify the type of collection if the Config Var is multi-value. */
120
+ collectionType?: CollectionType;
90
121
  };
91
122
  /** Defines attributes of a standard Config Var. */
92
123
  export declare type StandardConfigVar = BaseConfigVar & {
93
124
  /** The data type of the Config Var. */
94
- dataType: Exclude<ConfigVarDataType, "schedule">;
125
+ dataType: Exclude<ConfigVarDataType, "schedule" | "code">;
126
+ };
127
+ export declare type CodeConfigVar = BaseConfigVar & {
128
+ /** The data type of the Config Var. */
129
+ dataType: "code";
95
130
  /** Optional default value for the Config Var. */
96
131
  defaultValue?: string;
97
- /** Optional list of picklist values if the Config Var is a multi-choice selection value. */
98
- pickList?: string[];
99
132
  /** Optional value to specify the type of language if the Config Var is a code value. */
100
133
  codeLanguage?: CodeLanguageType;
101
- /** Optional value to specify the type of collection if the Config Var is multi-value. */
102
- collectionType?: CollectionType;
103
134
  };
104
- export declare type ScheduleConfigVar = BaseConfigVar & {
135
+ export declare type ScheduleConfigVar = Omit<BaseConfigVar, "collectionType"> & {
105
136
  /** The data type of the Config Var. */
106
137
  dataType: "schedule";
107
138
  /** Optional default value for the Config Var. */
@@ -109,36 +140,105 @@ export declare type ScheduleConfigVar = BaseConfigVar & {
109
140
  /** Optional timezone for the schedule. */
110
141
  timeZone?: string;
111
142
  };
112
- declare type DataSourceDefinitionConfigVar = BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload">;
113
- declare type DataSourceReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
114
- dataSourceType: DataSourceType;
115
- dataSource: ToComponentReferences<"dataSource", TComponents, ConfigPages<TComponents>>;
143
+ export declare type ComponentRegistry = keyof IntegrationDefinitionComponentRegistry extends never ? {
144
+ [key: string]: ComponentManifest;
145
+ } : UnionToIntersection<keyof IntegrationDefinitionComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof IntegrationDefinitionComponentRegistry ? {
146
+ [Key in TComponentKey]: IntegrationDefinitionComponentRegistry[TComponentKey];
147
+ } : never : never>;
148
+ declare type ComponentReferenceType = Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections">;
149
+ declare type ComponentReferenceTypeValueMap<TValue, TMap extends Record<ComponentReferenceType, unknown> = {
150
+ actions: ValueExpression<TValue>;
151
+ triggers: ValueExpression<TValue> | ConfigVarExpression;
152
+ dataSources: ValueExpression<TValue> | ConfigVarExpression;
153
+ connections: ValueExpression<TValue> | ConfigVarExpression;
154
+ }> = TMap;
155
+ export declare type ComponentReference<TComponentReference extends {
156
+ component: string;
157
+ isPublic: boolean;
158
+ key: string;
159
+ values?: {
160
+ [key: string]: ValueExpression | ConfigVarExpression;
161
+ };
162
+ template?: string;
163
+ } = {
164
+ component: string;
165
+ isPublic: boolean;
166
+ key: string;
167
+ values?: {
168
+ [key: string]: ValueExpression | ConfigVarExpression;
169
+ };
170
+ template?: string;
171
+ }> = TComponentReference;
172
+ export declare const isComponentReference: (ref: unknown) => ref is {
173
+ component: string;
174
+ isPublic: boolean;
175
+ key: string;
176
+ values?: {
177
+ [key: string]: ConfigVarExpression | ValueExpression<unknown>;
178
+ } | undefined;
179
+ template?: string | undefined;
180
+ };
181
+ declare type ComponentReferencesByType = UnionToIntersection<ComponentReferenceType extends infer TComponentReferenceType ? TComponentReferenceType extends Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections"> ? {
182
+ [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 ? ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey] extends (...args: any[]) => any ? Parameters<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]>[0] extends infer TInputs ? ComponentReference<{
183
+ component: TComponentKey;
184
+ isPublic: ComponentRegistry[TComponentKey]["public"];
185
+ key: TComponentPropertyKey;
186
+ values: {
187
+ [Key in keyof TInputs]: ComponentReferenceTypeValueMap<TInputs[Key]>[TComponentReferenceType];
188
+ };
189
+ }> : never : never : never : never : never : never : never : never : never;
190
+ } : never : never>;
191
+ export declare type TriggerReference = ComponentReferencesByType["triggers"];
192
+ export declare type ActionReference = ComponentReferencesByType["actions"];
193
+ export declare type DataSourceReference = ComponentReferencesByType["dataSources"];
194
+ export declare type ConnectionReference = ComponentReferencesByType["connections"];
195
+ declare type BaseDataSourceConfigVar = ({
196
+ dataSourceType: CollectionDataSourceType;
197
+ } & BaseConfigVar) | ({
198
+ dataSourceType: Exclude<DataSourceType, CollectionDataSourceType>;
199
+ } & Omit<BaseConfigVar, "collectionType">);
200
+ declare type DataSourceDefinitionConfigVar = BaseDataSourceConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload" | "dataSourceType" | "detailDataSource">;
201
+ export declare type DataSourceReferenceConfigVar = BaseDataSourceConfigVar & {
202
+ dataSource: DataSourceReference;
116
203
  };
117
204
  /** Defines attributes of a data source Config Var. */
118
- export declare type DataSourceConfigVar<TComponents extends ComponentSelector<any>> = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar<TComponents>;
119
- declare type ConnectionDefinitionConfigVar = BaseConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
120
- declare type ConnectionReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
121
- connection: ToComponentReferences<"connection", TComponents> & {
205
+ export declare type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar;
206
+ declare type BaseConnectionConfigVar = Omit<BaseConfigVar, "collectionType"> & {
207
+ dataType: "connection";
208
+ };
209
+ declare type ConnectionDefinitionConfigVar = BaseConnectionConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
210
+ declare type ConnectionReferenceConfigVar = BaseConnectionConfigVar & {
211
+ connection: ConnectionReference & {
122
212
  template?: string;
123
213
  };
124
214
  };
125
215
  /** Defines attributes of a Config Var that represents a Connection. */
126
- export declare type ConnectionConfigVar<TComponents extends ComponentSelector<any>> = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar<TComponents>;
127
- export declare type ConfigVar<TComponents extends ComponentSelector<any>> = StandardConfigVar | ScheduleConfigVar | DataSourceConfigVar<TComponents> | ConnectionConfigVar<TComponents>;
128
- export declare const isScheduleConfigVar: (cv: ConfigVar<any>) => cv is ScheduleConfigVar;
129
- export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar<any>) => cv is DataSourceDefinitionConfigVar;
130
- export declare const isDataSourceReferenceConfigVar: <TComponents extends ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is DataSourceReferenceConfigVar<TComponents>;
131
- export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar<any>) => cv is ConnectionDefinitionConfigVar;
132
- export declare const isConnectionReferenceConfigVar: <TComponents extends ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is ConnectionReferenceConfigVar<TComponents>;
133
- export declare type ConfigPageElement<TComponents extends ComponentSelector<any>> = string | ConfigVar<TComponents>;
134
- export declare type ConfigPages<TComponents extends ComponentSelector<any>> = Record<string, ConfigPage<TComponents>>;
216
+ export declare type ConnectionConfigVar = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar;
217
+ export declare type ConfigVar = StandardConfigVar | CodeConfigVar | ScheduleConfigVar | DataSourceConfigVar | ConnectionConfigVar;
218
+ export declare const isCodeConfigVar: (cv: ConfigVar) => cv is CodeConfigVar;
219
+ export declare const isScheduleConfigVar: (cv: ConfigVar) => cv is ScheduleConfigVar;
220
+ export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar) => cv is DataSourceDefinitionConfigVar;
221
+ export declare const isDataSourceReferenceConfigVar: (cv: ConfigVar) => cv is DataSourceReferenceConfigVar;
222
+ export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar) => cv is ConnectionDefinitionConfigVar;
223
+ export declare const isConnectionReferenceConfigVar: (cv: ConfigVar) => cv is ConnectionReferenceConfigVar;
224
+ export declare type ConfigPageElement = string | ConfigVar;
225
+ export declare type ConfigPages = keyof IntegrationDefinitionConfigPages extends never ? {
226
+ [key: string]: ConfigPage;
227
+ } : UnionToIntersection<keyof IntegrationDefinitionConfigPages extends infer TPageName ? TPageName extends keyof IntegrationDefinitionConfigPages ? IntegrationDefinitionConfigPages[TPageName] extends ConfigPage ? {
228
+ [Key in TPageName]: IntegrationDefinitionConfigPages[TPageName];
229
+ } : never : never : never>;
230
+ export declare type ConfigVars = Prettify<UnionToIntersection<keyof ConfigPages extends infer TPageName ? TPageName extends keyof ConfigPages ? ConfigPages[TPageName] extends infer TConfigPage ? TConfigPage extends ConfigPage ? {
231
+ [Key in keyof TConfigPage["elements"] as Key extends string ? TConfigPage["elements"][Key] extends ConfigVar ? Key : never : never]: ElementToRuntimeType<TConfigPage["elements"][Key]>;
232
+ } : never : never : never : never>>;
233
+ export declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string;
234
+ 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;
135
235
  /** Defines attributes of a Config Wizard Page used when deploying an Instance of an Integration. */
136
- export declare type ConfigPage<TComponents extends ComponentSelector<any>> = {
236
+ export interface ConfigPage {
137
237
  /** Elements included on this Config Page. */
138
- elements: Record<string, ConfigPageElement<TComponents>>;
238
+ elements: Record<string, ConfigPageElement>;
139
239
  /** Specifies an optional tagline for this Config Page. */
140
240
  tagline?: string;
141
- };
241
+ }
142
242
  /** Defines attributes of a Preprocess Flow Configuration used by a Flow of an Integration. */
143
243
  export declare type PreprocessFlowConfig = {
144
244
  /** Name of the field in the data payload returned by the Preprocess Flow to use for a Flow Name. */
@@ -186,39 +286,10 @@ export declare type CodeLanguageType = "json" | "xml" | "html";
186
286
  export declare type CollectionType = "valuelist" | "keyvaluelist";
187
287
  /** Choices of component reference types. */
188
288
  export declare type ComponentSelectorType = "trigger" | "connection" | "dataSource";
189
- export declare type ValueReference<TValueType, TConfigPages extends ConfigPages<any>, TConfigVarKeys = keyof ExtractConfigVars<TConfigPages>> = {
289
+ export declare type ConfigVarExpression = {
290
+ configVar: string;
291
+ };
292
+ export declare type ValueExpression<TValueType = unknown> = {
190
293
  value: TValueType;
191
- } | (TConfigPages extends ConfigPages<any> ? {
192
- configVar: TConfigVarKeys;
193
- } : never);
194
- export interface ComponentSelector<TValueType> {
195
- type: ComponentSelectorType;
196
- component: string | {
197
- key: string;
198
- isPublic: boolean;
199
- };
200
- key: string;
201
- values?: {
202
- [key: string]: TValueType;
203
- };
204
- }
205
- export declare type ToComponentReferences<TReferenceType extends ComponentSelectorType, TComponents extends ComponentSelector<any>, TConfigPages extends ConfigPages<TComponents> = never> = TComponents extends ComponentSelector<infer TValueType> ? TComponents["type"] extends TReferenceType ? {
206
- component: TComponents["component"];
207
- key: TComponents["key"];
208
- values: {
209
- [K in keyof TComponents["values"]]: ValueReference<TValueType, TConfigPages>;
210
- };
211
- } : never : never;
212
- export interface ComponentReference<TValueType, TConfigPages extends ConfigPages<any>> {
213
- component: string | {
214
- key: string;
215
- isPublic: boolean;
216
- };
217
- key: string;
218
- values?: {
219
- [key: string]: ValueReference<TValueType, TConfigPages>;
220
- };
221
- template?: string;
222
- }
223
- export declare const isComponentReference: (ref: unknown) => ref is ComponentReference<any, ConfigPages<any>>;
294
+ };
224
295
  export {};
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isComponentReference = exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = void 0;
3
+ exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = exports.isCodeConfigVar = exports.isComponentReference = void 0;
4
+ const isComponentReference = (ref) => typeof ref === "object" && ref !== null && "key" in ref && "component" in ref;
5
+ exports.isComponentReference = isComponentReference;
6
+ const isCodeConfigVar = (cv) => "dataType" in cv && cv.dataType === "code";
7
+ exports.isCodeConfigVar = isCodeConfigVar;
4
8
  const isScheduleConfigVar = (cv) => "dataType" in cv && cv.dataType === "schedule";
5
9
  exports.isScheduleConfigVar = isScheduleConfigVar;
6
10
  const isDataSourceDefinitionConfigVar = (cv) => "dataSourceType" in cv && "perform" in cv && typeof cv.perform === "function";
7
11
  exports.isDataSourceDefinitionConfigVar = isDataSourceDefinitionConfigVar;
8
- const isDataSourceReferenceConfigVar = (cv) => "dataSource" in cv && (0, exports.isComponentReference)(cv.dataSource);
12
+ const isDataSourceReferenceConfigVar = (cv) => "dataSourceType" in cv &&
13
+ "dataSource" in cv &&
14
+ (0, exports.isComponentReference)(cv.dataSource);
9
15
  exports.isDataSourceReferenceConfigVar = isDataSourceReferenceConfigVar;
10
- const isConnectionDefinitionConfigVar = (cv) => "inputs" in cv;
16
+ const isConnectionDefinitionConfigVar = (cv) => "dataType" in cv && cv.dataType === "connection" && "inputs" in cv;
11
17
  exports.isConnectionDefinitionConfigVar = isConnectionDefinitionConfigVar;
12
18
  const isConnectionReferenceConfigVar = (cv) => "connection" in cv && (0, exports.isComponentReference)(cv.connection);
13
19
  exports.isConnectionReferenceConfigVar = isConnectionReferenceConfigVar;
14
- const isComponentReference = (ref) => typeof ref === "object" && ref !== null && "key" in ref && "component" in ref;
15
- exports.isComponentReference = isComponentReference;
@@ -28,4 +28,5 @@ export * from "./UserAttributes";
28
28
  export * from "./IntegrationAttributes";
29
29
  export * from "./FlowAttributes";
30
30
  export * from "./IntegrationDefinition";
31
+ export * from "./ComponentManifest";
31
32
  export * as serverTypes from "../serverTypes";
@@ -57,4 +57,5 @@ __exportStar(require("./UserAttributes"), exports);
57
57
  __exportStar(require("./IntegrationAttributes"), exports);
58
58
  __exportStar(require("./FlowAttributes"), exports);
59
59
  __exportStar(require("./IntegrationDefinition"), exports);
60
+ __exportStar(require("./ComponentManifest"), exports);
60
61
  exports.serverTypes = __importStar(require("../serverTypes"));
package/dist/util.d.ts CHANGED
@@ -4,6 +4,8 @@
4
4
  * For example, `util.types.toInt("5.5")` will return an integer, `5`.
5
5
  */
6
6
  import { KeyValuePair, DataPayload, ObjectSelection, ObjectFieldMap, JSONForm, ConnectionDefinition, Element } from "./types";
7
+ export declare const isObjectWithOneTruthyKey: (value: unknown, keys: string[]) => boolean;
8
+ export declare const isObjectWithTruthyKeys: (value: unknown, keys: string[]) => boolean;
7
9
  /**
8
10
  * This function returns a lower cased version of the headers passed to it.
9
11
  *
package/dist/util.js CHANGED
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.toObject = exports.lowerCaseHeaders = void 0;
11
+ exports.toObject = exports.lowerCaseHeaders = exports.isObjectWithTruthyKeys = exports.isObjectWithOneTruthyKey = void 0;
12
12
  /** */
13
13
  const parseISO_1 = __importDefault(require("date-fns/parseISO"));
14
14
  const isValid_1 = __importDefault(require("date-fns/isValid"));
@@ -17,18 +17,25 @@ const fromUnixTime_1 = __importDefault(require("date-fns/fromUnixTime"));
17
17
  const lodash_1 = require("lodash");
18
18
  const safe_stable_stringify_1 = require("safe-stable-stringify");
19
19
  const valid_url_1 = require("valid-url");
20
+ const isObjectWithOneTruthyKey = (value, keys) => {
21
+ return (value !== null &&
22
+ typeof value === "object" &&
23
+ keys.some((key) => key in value && Boolean(value === null || value === void 0 ? void 0 : value[key])));
24
+ };
25
+ exports.isObjectWithOneTruthyKey = isObjectWithOneTruthyKey;
20
26
  const isObjectWithTruthyKeys = (value, keys) => {
21
27
  return (value !== null &&
22
28
  typeof value === "object" &&
23
29
  keys.every((key) => key in value && Boolean(value === null || value === void 0 ? void 0 : value[key])));
24
30
  };
31
+ exports.isObjectWithTruthyKeys = isObjectWithTruthyKeys;
25
32
  /**
26
33
  * This function checks if value is an Element.
27
34
  * `util.types.isElement({key: "foo"})` and `util.types.isElement({key: "foo", label: "Foo"})` return true.
28
35
  * @param value The variable to test.
29
36
  * @returns This function returns true or false, depending on if `value` is an Element.
30
37
  */
31
- const isElement = (value) => isObjectWithTruthyKeys(value, ["key"]);
38
+ const isElement = (value) => (0, exports.isObjectWithTruthyKeys)(value, ["key"]);
32
39
  /**
33
40
  * @param value The value to test
34
41
  * @returns This function returns true if the type of `value` is an ObjectSelection, or false otherwise.
@@ -38,7 +45,7 @@ const isObjectSelection = (value) => {
38
45
  return isObjectSelection(JSON.parse(value));
39
46
  }
40
47
  return (Array.isArray(value) &&
41
- value.every((item) => isObjectWithTruthyKeys(item, ["object"])));
48
+ value.every((item) => (0, exports.isObjectWithTruthyKeys)(item, ["object"])));
42
49
  };
43
50
  /**
44
51
  * This function coerces a provided value into an ObjectSelection if possible.
@@ -65,7 +72,7 @@ const isObjectFieldMap = (value) => {
65
72
  if (Boolean(value) && typeof value === "object") {
66
73
  const { fields } = value;
67
74
  return (Array.isArray(fields) &&
68
- fields.every((item) => isObjectWithTruthyKeys(item, ["field"]) &&
75
+ fields.every((item) => (0, exports.isObjectWithTruthyKeys)(item, ["field"]) &&
69
76
  isElement(item === null || item === void 0 ? void 0 : item.field)));
70
77
  }
71
78
  return false;
@@ -92,7 +99,7 @@ const isJSONForm = (value) => {
92
99
  if (typeof value === "string" && isJSON(value)) {
93
100
  return isJSONForm(JSON.parse(value));
94
101
  }
95
- return isObjectWithTruthyKeys(value, ["schema", "uiSchema", "data"]);
102
+ return (0, exports.isObjectWithTruthyKeys)(value, ["schema", "uiSchema", "data"]);
96
103
  };
97
104
  /**
98
105
  * This function coerces a provided value into a JSONForm if possible.
@@ -303,7 +310,7 @@ const isPicklist = (value) => Array.isArray(value) && (value.every(isString) ||
303
310
  * @param value The variable to test.
304
311
  * @returns This function returns true if `value` is a valid schedule.
305
312
  */
306
- const isSchedule = (value) => isObjectWithTruthyKeys(value, ["value"]);
313
+ const isSchedule = (value) => (0, exports.isObjectWithTruthyKeys)(value, ["value"]);
307
314
  /**
308
315
  * This function helps to transform key-value lists to objects.
309
316
  * This is useful for transforming inputs that are key-value collections into objects.
@@ -420,16 +427,16 @@ const isConnection = (value) => {
420
427
  }
421
428
  if (Boolean(value) && typeof value === "object") {
422
429
  const { inputs } = value;
423
- if (isObjectWithTruthyKeys(value, ["key", "label", "oauth2Type"])) {
424
- return (isObjectWithTruthyKeys(inputs, [
430
+ if ((0, exports.isObjectWithTruthyKeys)(value, ["key", "label", "oauth2Type"])) {
431
+ return ((0, exports.isObjectWithTruthyKeys)(inputs, [
425
432
  "authorizeUrl",
426
433
  "tokenUrl",
427
434
  "clientId",
428
435
  "clientSecret",
429
436
  ]) ||
430
- isObjectWithTruthyKeys(inputs, ["tokenUrl", "clientId", "clientSecret"]));
437
+ (0, exports.isObjectWithTruthyKeys)(inputs, ["tokenUrl", "clientId", "clientSecret"]));
431
438
  }
432
- return (isObjectWithTruthyKeys(value, ["key", "label"]) &&
439
+ return ((0, exports.isObjectWithTruthyKeys)(value, ["key", "label"]) &&
433
440
  typeof inputs === "object");
434
441
  }
435
442
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "8.1.6",
3
+ "version": "9.0.0-rc.1",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"
@@ -8,6 +8,9 @@
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "homepage": "https://prismatic.io",
11
+ "bin": {
12
+ "component-manifest": "./bin/component-manifest.js"
13
+ },
11
14
  "bugs": {
12
15
  "url": "https://github.com/prismatic-io/spectral"
13
16
  },
@@ -23,6 +26,9 @@
23
26
  "scripts": {
24
27
  "clean": "rm -rf dist",
25
28
  "build": "yarn run format && yarn run lint && yarn run clean && tsc",
29
+ "build:templates": "copyfiles --error -u 1 src/**/templates/**/*.ejs dist",
30
+ "dev": "tsc -w",
31
+ "postbuild": "yarn run build:templates",
26
32
  "prepack": "yarn run build",
27
33
  "format": "yarn run lint-fix && prettier --loglevel error --write 'src/**/*.ts' '*.{ts,js,json}' '!sidebars.{js,jse}'",
28
34
  "check-format": "prettier --check 'src/**/*.ts' '*.{ts,js,json}' '!sidebars.{js,jse}'",
@@ -30,7 +36,6 @@
30
36
  "lint": "eslint --ext .ts .",
31
37
  "lint-fix": "eslint --fix --ext .ts .",
32
38
  "test": "jest",
33
- "tsd": "tsd",
34
39
  "docs": "rm -f sidebars.{js,jse} && typedoc"
35
40
  },
36
41
  "files": [
@@ -41,7 +46,9 @@
41
46
  "axios": "1.6.2",
42
47
  "axios-retry": "3.9.1",
43
48
  "date-fns": "2.30.0",
49
+ "ejs": "^3.1.10",
44
50
  "form-data": "4.0.0",
51
+ "fs-extra": "^11.2.0",
45
52
  "jest-mock": "29.7.0",
46
53
  "lodash": "4.17.21",
47
54
  "object-sizeof": "^2.6.4",
@@ -53,6 +60,8 @@
53
60
  "yaml": "2.3.4"
54
61
  },
55
62
  "devDependencies": {
63
+ "@types/ejs": "3.1.5",
64
+ "@types/fs-extra": "11.0.4",
56
65
  "@types/jest": "29.5.12",
57
66
  "@types/lodash": "4.17.0",
58
67
  "@types/node": "14.14.35",
@@ -62,6 +71,7 @@
62
71
  "@types/valid-url": "1.0.3",
63
72
  "@typescript-eslint/eslint-plugin": "5.18.0",
64
73
  "@typescript-eslint/parser": "5.18.0",
74
+ "copyfiles": "2.4.1",
65
75
  "eslint": "8.12.0",
66
76
  "eslint-config-prettier": "8.5.0",
67
77
  "eslint-plugin-jest": "27.9.0",
@@ -70,13 +80,9 @@
70
80
  "jest": "29.7.0",
71
81
  "prettier": "2.6.2",
72
82
  "ts-jest": "29.1.2",
73
- "tsd": "0.31.0",
74
83
  "typedoc": "0.17.7",
75
84
  "typedoc-plugin-markdown": "2.4.2",
76
85
  "typedoc-plugin-remove-references": "0.0.5",
77
86
  "typescript": "4.6.3"
78
- },
79
- "tsd": {
80
- "directory": "./src/types-tests"
81
87
  }
82
88
  }