2023-08-30 10:17:44 +00:00
|
|
|
import { SettingsManager } from "@saleor/app-sdk/settings-manager";
|
|
|
|
import { AppConfigurationFields } from "./configuration";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Before single-key configuration was introduced, this was a shape of settings.
|
|
|
|
*/
|
|
|
|
export const fetchLegacyConfiguration = async (
|
|
|
|
settingsManager: SettingsManager,
|
|
|
|
domain: string,
|
2023-09-04 09:30:57 +00:00
|
|
|
): Promise<AppConfigurationFields | null> => {
|
|
|
|
const secretKey = await settingsManager.get("secretKey", domain);
|
|
|
|
const appId = await settingsManager.get("appId", domain);
|
|
|
|
const indexNamePrefix = await settingsManager.get("indexNamePrefix", domain);
|
2023-08-30 10:17:44 +00:00
|
|
|
|
2023-09-04 09:30:57 +00:00
|
|
|
if (secretKey && appId) {
|
|
|
|
return {
|
|
|
|
appId,
|
|
|
|
secretKey,
|
|
|
|
indexNamePrefix,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2023-08-30 10:17:44 +00:00
|
|
|
};
|