@prismatic-io/spectral 9.0.0-rc.8 → 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.
Files changed (38) hide show
  1. package/dist/generators/componentManifest/cli.js +2 -1
  2. package/dist/generators/componentManifest/createActions.js +0 -15
  3. package/dist/generators/componentManifest/createConnections.js +0 -25
  4. package/dist/generators/componentManifest/createDataSources.js +1 -15
  5. package/dist/generators/componentManifest/createTriggers.js +0 -15
  6. package/dist/generators/componentManifest/docBlock.d.ts +10 -0
  7. package/dist/generators/componentManifest/docBlock.js +40 -0
  8. package/dist/generators/componentManifest/getImports.js +6 -6
  9. package/dist/generators/componentManifest/getInputs.d.ts +9 -10
  10. package/dist/generators/componentManifest/getInputs.js +25 -46
  11. package/dist/generators/componentManifest/removeComponentManifest.js +4 -2
  12. package/dist/generators/componentManifest/templates/actions/action.ts.ejs +2 -2
  13. package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +2 -2
  14. package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +3 -2
  15. package/dist/generators/componentManifest/templates/index.ts.ejs +1 -1
  16. package/dist/generators/componentManifest/templates/partials/inputs.ejs +3 -3
  17. package/dist/generators/componentManifest/templates/partials/performArgs.ejs +2 -8
  18. package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +2 -2
  19. package/dist/generators/utils/createTemplate.js +9 -3
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +2 -2
  22. package/dist/serverTypes/convertIntegration.js +39 -28
  23. package/dist/serverTypes/integration.d.ts +2 -0
  24. package/dist/types/ComponentManifest.d.ts +15 -15
  25. package/dist/types/ComponentRegistry.d.ts +89 -0
  26. package/dist/types/ComponentRegistry.js +5 -0
  27. package/dist/types/ConfigPages.d.ts +46 -0
  28. package/dist/types/ConfigPages.js +2 -0
  29. package/dist/types/ConfigVars.d.ts +241 -0
  30. package/dist/types/ConfigVars.js +30 -0
  31. package/dist/types/Inputs.d.ts +13 -13
  32. package/dist/types/IntegrationDefinition.d.ts +1 -220
  33. package/dist/types/IntegrationDefinition.js +0 -17
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/index.js +3 -0
  36. package/package.json +3 -2
  37. /package/dist/serverTypes/{convert.d.ts → convertComponent.d.ts} +0 -0
  38. /package/dist/serverTypes/{convert.js → convertComponent.js} +0 -0
@@ -28,7 +28,7 @@ const yaml_1 = __importDefault(require("yaml"));
28
28
  const uuid_1 = require("uuid");
29
29
  const lodash_1 = require("lodash");
30
30
  const types_1 = require("../types");
31
- const convert_1 = require("./convert");
31
+ const convertComponent_1 = require("./convertComponent");
32
32
  const integration_1 = require("./integration");
33
33
  const convertIntegration = (definition) => {
34
34
  var _a, _b;
@@ -162,6 +162,9 @@ const convertConfigVarPermissionAndVisibility = ({ permissionAndVisibilityType,
162
162
  const convertComponentReference = (componentReference, componentRegistry) => {
163
163
  var _a, _b;
164
164
  const manifest = componentRegistry[componentReference.component];
165
+ if (!manifest) {
166
+ throw new Error(`Component with key "${componentReference.component}" not found in component registry.`);
167
+ }
165
168
  const ref = {
166
169
  component: {
167
170
  key: manifest.key,
@@ -282,6 +285,19 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
282
285
  result.supplementalComponents = convertComponentRegistry(componentRegistry);
283
286
  return result;
284
287
  };
288
+ /** Converts an input value to the expected server type by its collection type */
289
+ const convertInputValue = (value, collectionType) => {
290
+ if (collectionType !== "keyvaluelist") {
291
+ return value;
292
+ }
293
+ if (Array.isArray(value)) {
294
+ return value;
295
+ }
296
+ return Object.entries(value).map(([key, value]) => ({
297
+ key,
298
+ value,
299
+ }));
300
+ };
285
301
  /** Converts a Config Var into the structure necessary for YAML generation. */
286
302
  const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
287
303
  const { orgOnly, meta } = convertConfigVarPermissionAndVisibility((0, lodash_1.pick)(configVar, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
@@ -315,22 +331,30 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
315
331
  }
316
332
  if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
317
333
  const { ref, inputs } = convertComponentReference(configVar.connection, componentRegistry);
318
- const { stableKey = "", description, connection: { template }, } = (0, lodash_1.pick)(configVar, ["stableKey", "description", "connection"]);
334
+ const { stableKey = "", description, connection: { template, onPremiseConnectionConfig }, } = (0, lodash_1.pick)(configVar, ["stableKey", "description", "connection"]);
319
335
  return {
320
336
  stableKey,
321
337
  description,
322
338
  key,
323
339
  dataType: "connection",
324
- connection: Object.assign(Object.assign({}, ref), { template }),
340
+ connection: Object.assign(Object.assign({}, ref), { template,
341
+ onPremiseConnectionConfig }),
325
342
  inputs,
326
343
  orgOnly,
327
344
  meta,
328
345
  };
329
346
  }
330
- const result = (0, lodash_1.assign)({ orgOnly, meta, key }, (0, lodash_1.pick)(configVar, [
347
+ const rawDefaultValue = "defaultValue" in configVar
348
+ ? convertInputValue(configVar.defaultValue, configVar.collectionType)
349
+ : undefined;
350
+ const defaultValue = typeof rawDefaultValue !== "undefined"
351
+ ? typeof rawDefaultValue === "string"
352
+ ? rawDefaultValue
353
+ : JSON.stringify(rawDefaultValue)
354
+ : undefined;
355
+ const result = (0, lodash_1.assign)({ orgOnly, meta, key, defaultValue }, (0, lodash_1.pick)(configVar, [
331
356
  "stableKey",
332
357
  "description",
333
- "defaultValue",
334
358
  "dataType",
335
359
  "pickList",
336
360
  "timeZone",
@@ -349,7 +373,8 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
349
373
  }
350
374
  if ((0, types_1.isDataSourceReferenceConfigVar)(configVar)) {
351
375
  const { ref, inputs } = convertComponentReference(configVar.dataSource, componentRegistry);
352
- result.dataType = configVar.dataSourceType;
376
+ result.dataType =
377
+ componentRegistry[ref.component.key]["dataSources"][ref.key]["dataSourceType"];
353
378
  result.dataSource = ref;
354
379
  result.inputs = inputs;
355
380
  }
@@ -374,32 +399,20 @@ const flowFunctionKey = (flowName, functionName) => {
374
399
  return `${flowKey}_${functionName}`;
375
400
  };
376
401
  const convertOnExecution = (onExecution, componentRegistry) => (context, params) => {
402
+ const {
377
403
  // @ts-expect-error _components isn't part of the public API
378
- const { _components } = context, remainingContext = __rest(context, ["_components"]);
404
+ _components } = context, remainingContext = __rest(context, ["_components"]);
379
405
  const invoke = _components
380
406
  .invoke;
381
407
  // Construct the component methods from the component registry
382
408
  const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature },]) => {
383
- // Create an object to hold the methods for each action
384
- const methods = Object.keys(actions).reduce((methodsAccumulator, actionKey) => {
385
- const action = actions[actionKey];
409
+ const componentActions = Object.entries(actions).reduce((actionsAccumulator, [actionKey, action]) => {
386
410
  // Define the method to be called for the action
387
- methodsAccumulator[actionKey] = (values) => __awaiter(void 0, void 0, void 0, function* () {
411
+ const invokeAction = (values) => __awaiter(void 0, void 0, void 0, function* () {
388
412
  // Transform the input values based on the action's inputs
389
413
  const transformedValues = Object.entries(values).reduce((transformedAccumulator, [inputKey, inputValue]) => {
390
414
  const { collection } = action.inputs[inputKey];
391
- // Transform key-value list inputs
392
- if (collection === "keyvaluelist" &&
393
- Object.keys(inputValue).length) {
394
- transformedAccumulator[inputKey] = Object.entries(inputValue).map(([keyItem, valueItem]) => ({
395
- key: keyItem,
396
- value: valueItem,
397
- }));
398
- }
399
- else {
400
- transformedAccumulator[inputKey] = inputValue;
401
- }
402
- return transformedAccumulator;
415
+ return Object.assign(Object.assign({}, transformedAccumulator), { [inputKey]: convertInputValue(inputValue, collection) });
403
416
  }, {});
404
417
  // Invoke the action with the transformed values
405
418
  return invoke({
@@ -411,11 +424,9 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
411
424
  key: actionKey,
412
425
  }, context, transformedValues);
413
426
  });
414
- return methodsAccumulator;
427
+ return Object.assign(Object.assign({}, actionsAccumulator), { [actionKey]: invokeAction });
415
428
  }, {});
416
- // Add the methods to the accumulator under the registry component key
417
- accumulator[registryComponentKey] = methods;
418
- return accumulator;
429
+ return Object.assign(Object.assign({}, accumulator), { [registryComponentKey]: componentActions });
419
430
  }, {});
420
431
  return onExecution(Object.assign(Object.assign({}, remainingContext), { components: componentMethods }), params);
421
432
  };
@@ -470,7 +481,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
470
481
  if (!(0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
471
482
  return result;
472
483
  }
473
- const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convert_1.convertInput)(key, value));
484
+ const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convertComponent_1.convertInput)(key, value));
474
485
  const connection = (0, lodash_1.pick)(configVar, ["oauth2Type", "iconPath"]);
475
486
  return [
476
487
  ...result,
@@ -7,6 +7,7 @@ export declare type ComponentReference = {
7
7
  };
8
8
  key: string;
9
9
  template?: string;
10
+ onPremiseConnectionConfig?: string;
10
11
  } | {
11
12
  component: {
12
13
  key: string;
@@ -15,6 +16,7 @@ export declare type ComponentReference = {
15
16
  };
16
17
  key: string;
17
18
  template?: string;
19
+ onPremiseConnectionConfig?: string;
18
20
  };
19
21
  export declare type Input = {
20
22
  name?: string | Input;
@@ -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
- inputs: Record<string, {
27
- inputType: string;
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
- inputs: Record<string, {
34
- inputType: string;
35
- collection: "keyvaluelist" | "valuelist" | null;
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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;