Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 784x 784x 5x 779x 808x 808x 1x 807x 740x 736x 735x | import { BaseIndex, Index } from "shared-types/opensearch";
/**
* Returns the `osDomain`
* @throws if env variables are not defined, `getDomain` throws error indicating if variable is missing
* @returns the value of `osDomain`
*/
export function getDomain(): string {
const domain = process.env.osDomain;
if (domain === undefined) {
throw new Error("process.env.osDomain must be defined");
}
return domain;
}
/**
* Returns the `indexNamespace` and `baseIndex` combined
* process.env.indexNamespace (THIS SHOULD BE THE BRANCH NAME & SHOULD ALWAYS BE DEFINED)
* @throws if process.env.indexNamespace not defined.
* @returns the value of `indexNamespace` and `baseIndex` combined
*/
export function getOsNamespace(baseIndex: BaseIndex): Index {
const indexNamespace = process.env.indexNamespace;
if (!indexNamespace) {
throw new Error("process.env.indexNamespace must be defined");
}
return `${indexNamespace}${baseIndex}`;
}
/**
* Gets both the OpenSearch domain and namespace combined with the base index
* @param baseIndex - The base index to combine with the namespace
* @throws {Error} If required environment variables are not defined
* @returns Object containing:
* - domain: The OpenSearch domain from environment variables
* - index: The namespace and base index combined
*/
export function getDomainAndNamespace(baseIndex: BaseIndex) {
const domain = getDomain();
const index = getOsNamespace(baseIndex);
return { index, domain };
}
|