Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Easy way to set mappings (aka settings, aka options) on a Connector #531

Open
seancrowe opened this issue Nov 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@seancrowe
Copy link

seancrowe commented Nov 7, 2024

Is your feature request related to a problem? Please describe.
You can retrieve the available configuration options using:

SDK.mediaConnector.getConfigurationOptions(connectorId)

And you can get the currently applied values with:

SDK.connector.getMappings(connectorId)

However, setting mappings on a connector via the SDK is unnecessarily complex. This creates friction for integrators who need to:

  • Build custom connector UI
  • Programmatically set default values (e.g., user paths) for specific platform users or workflow paths

The current process requires deep understanding of the internal workings and often needs support team intervention. I doubt anyone will come to the conclusions that you must do the following to update a mapping:

  1. Use the configure method to get the ConnectorConfigurator object
  2. Gets existing mappings
  3. Filters out ConnectorToEngine mappings
  4. Merges new settings with existing ones
  5. Updates the connector via the ConnectorConfigurator object

Describe the solution you'd like
Add a new method to the ConnectorController with the following signature:

setMappings(connectorId: string, mappings: Record<string, string|boolean>): Promise<EditorResponse<void>>

This method would have properly error handling like all other SDK methods.

This would provide a straightforward, single-method approach to update connector mappings, focusing specifically on EngineToConnectorMapping.

I don't believe there is a use-case to support also ConnectorToEngineMapping, but welcome to push back

Describe alternatives you've considered
Until such a method is provided, you can utilize this helper function:

async function setConnectorMappings(connectorId, settingsUpdate, SDK) {
  SDK.connector.configure(connectorId, async (config) => {
    const { parsedData: currentMappingsResult } = await SDK.connector.getMappings(connectorId);

    const settingsUpdateNames = Object.keys(settingsUpdate);

    const updates = settingsUpdateNames.map(name => ({
      name,
      value: settingsUpdate[name],
      direction: "engineToConnector"
    }))

    const mapping = currentMappingsResult.filter(c =>
      c.direction !== "connectorToEngine" && !settingsUpdateNames.includes(c.name)
    );

    await config.setMappings([...mapping, ...updates]);

  })
}

Usage example:

setConnectorMappings(
  "02982fc2-2dd7-428f-8563-28cfa8729914", 
  {
    "tag": "dog", 
    "folderView": true
  }, 
  SDK
)

Additional context

  • This feature would significantly simplify setting mappings on connector by making it a simple function
  • The focus on EngineToConnector mappings covers the majority (maybe all) of use cases
  • Related internal ticket: MAIN-916 (contains additional context and real-world use cases)
  • Error handling right now appears (maybe I did something wrong) that the configuration method always returns a success if something goes wrong and then throws an error in the console that is uncatchable by the integrator.
@seancrowe seancrowe added the enhancement New feature or request label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant