Line data Source code
1 : import { ConnectorType, HYPER_CONNECTOR, SALESFORCE_DATA_CLOUD_CONNECTOR, SIDB_CONNECTOR, TRINO_CONNECTOR } from "./connector_info.js";
2 : import { VariantKind } from "../utils/variant.js";
3 : import type { HyperConnectionDetails } from "./hyper/hyper_connection_state.js";
4 : import type { SalesforceConnectionStateDetails } from "./salesforce/salesforce_connection_state.js";
5 : import type { TrinoConnectionStateDetails } from "./trino/trino_connection_state.js";
6 : import { CONNECTOR_DESCRIPTORS, connectionStateDetailsOf } from "./connector_descriptor.js";
7 :
8 : /// The connectors that share the Salesforce connection state, SIDB behaves like Salesforce Data Cloud for now
9 : export type SalesforceDetailsType = typeof SALESFORCE_DATA_CLOUD_CONNECTOR | typeof SIDB_CONNECTOR;
10 :
11 : export type ConnectionStateDetailsVariant =
12 : | VariantKind<SalesforceDetailsType, SalesforceConnectionStateDetails>
13 : | VariantKind<typeof HYPER_CONNECTOR, HyperConnectionDetails>
14 : | VariantKind<typeof TRINO_CONNECTOR, TrinoConnectionStateDetails>
15 : ;
16 :
17 : /// The details of a new connection of a connector
18 1 : export function createConnectionStateDetails(type: ConnectorType): ConnectionStateDetailsVariant {
19 1 : const connector = CONNECTOR_DESCRIPTORS[type];
20 1 : return connectionStateDetailsOf(connector, connector.defaultParams());
21 1 : }
22 :
23 : /// Do the details hold the Salesforce connection state?
24 1 : export function isSalesforceDetails(details: ConnectionStateDetailsVariant): details is VariantKind<SalesforceDetailsType, SalesforceConnectionStateDetails> {
25 1 : return details.type === SALESFORCE_DATA_CLOUD_CONNECTOR || details.type === SIDB_CONNECTOR;
26 1 : }
|