prismatic-io / spectral

Prismatic's typescript library for custom components
https://prismatic.io/docs/spectral/custom-component-library
35 stars 2 forks source link

CNI - Hoist OnPremConnectionConfig on Required Config Var #251

Closed jasoncomes closed 2 months ago

jasoncomes commented 2 months ago

To define a valid YAML configuration, we need to hoist the onPremiseConnectionConfig on the required configuration variable. in CNI, to satisfy the types correctly we need to be part of the connection variable used for type discrimination.

CNI:

export const configPages = {
  Connections: configPage({
    elements: {
      test: connectionConfigVar({
        stableKey: "b2b377ee-27ce-4f59-b248-b4dafdea93f3",
        dataType: "connection",
        connection: {
          component: "smtp",
          key: "smtpConnection",
          onPremiseConnectionConfig: "required",
          values: {
            host: {
              value: "eeee",
            },
            port: {
              value: "bbbb",
            },
            password: {
              value: "test",
            },
            username: {
              value: "asdf",
            },
          },
        },
      }),
     ...

YAML Definition:

definitionVersion: 7
isCodeNative: true
name: integration
description: Prism-generated Integration
requiredConfigVars:
  - stableKey: b2b377ee-27ce-4f59-b248-b4dafdea93f3
    key: test
    dataType: connection
    onPremiseConnectionConfig: required
    connection:
      component:
        key: smtp
        signature: 8fa897c05ed7612f9b6090f542c01f2f2581b976
        isPublic: true
      key: smtpConnection
    inputs:
      host:
        type: value
        value: eeee
        meta:
          orgOnly: false
          visibleToOrgDeployer: true
          visibleToCustomerDeployer: true
      port:
        type: value
        value: bbbb
        meta:
          orgOnly: false
          visibleToOrgDeployer: true
          visibleToCustomerDeployer: true
      password:
        type: value
        value: test
        meta:
          orgOnly: false
          visibleToOrgDeployer: true
          visibleToCustomerDeployer: true
...