Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return analyticsPrompt().then(({ analyticsResponse }) => {
setSync(CFG_ANALYTICS_REPORTING_KEY, yn(analyticsResponse));
if (!yn(analyticsResponse)) {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
return errorReportingPrompt().then(({ errResponse }) => {
return setSync(CFG_ANALYTICS_ERROR_REPORTS_KEY, yn(errResponse));
});
}
return null;
});
}
const getContextToEnrich = () => {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
if (!enrichContextFromGlobal.context) {
const username = globalConfig.getSync(CFG_USER_NAME_KEY);
const email = globalConfig.getSync(CFG_USER_EMAIL_KEY);
const sshKeyFile = globalConfig.getSync(CFG_SSH_KEY_FILE_KEY);
const token = globalConfig.getSync(CFG_USER_TOKEN_KEY);
const pubSshKeyFile = sshKeyFile ? `${sshKeyFile}.pub` : undefined;
const pubSshKey = _getSshPubKey(pubSshKeyFile);
const repo = yn(globalConfig.getSync(CFG_REPOSITORY_REPORTING_KEY), { default: true })
? gitconfig.getUrl()
: undefined;
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
enrichContextFromGlobal.context = { username, email, pubSshKey, token, repo };
}
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
return enrichContextFromGlobal.context;
};
const contextToEnrich = getContextToEnrich();
export const structDimensionReducer = (cubeItem, dimension, index, dimensions) => {
const uri = dimension.toString();
const dmAnn = dimension.annotations || {};
const dimensionType = dimension.dimensionType;
const timeDimHeuristic = dimensions.some(dim => dim.dimensionType === DimType.Time)
? dimensionType === DimType.Time
: yn(dmAnn.default_year) || (/date|year/i).test(dimension.name);
const geoDimHeuristic =
dimensionType === DimType.Geographic || (/geography/i).test(dimension.name);
const defaultHierarchy = dimension.defaultHierarchy;
/** @type {DimensionItem} */
const dimensionItem = {
caption: dimension.caption,
cube: cubeItem.name,
defaultHierarchy: defaultHierarchy ? defaultHierarchy.name : undefined,
defaultYear: Number.parseInt(`${dmAnn.default_year}`, 10) || undefined,
hash: unique(uri),
hideInMap: dmAnn.hide_in_map
? yn(dmAnn.hide_in_map) || false
: !geoDimHeuristic || cubeItem.hideInMap,
hideInUi: dmAnn.hide_in_ui ? yn(dmAnn.hide_in_ui) || false : cubeItem.hideInUi,
const handleSubmit = useCallback(newValue => {
onSubmit(yn(newValue, {default: isChecked}));
}, [isChecked, onSubmit]);
namespace NodeJS {
interface Process {
[REGISTER_INSTANCE]?: Register
}
}
}
/**
* @internal
*/
export const INSPECT_CUSTOM = util.inspect.custom || 'inspect'
/**
* Debugging `ts-node`.
*/
const shouldDebug = yn(process.env.TS_NODE_DEBUG)
const debug = shouldDebug ? console.log.bind(console, 'ts-node') : () => undefined
const debugFn = shouldDebug ?
(key: string, fn: (arg: T) => U) => {
let i = 0
return (x: T) => {
debug(key, x, ++i)
return fn(x)
}
} :
(_: string, fn: (arg: T) => U) => fn
/**
* Common TypeScript interfaces between versions.
*/
export interface TSCommon {
version: typeof _ts.version
* Information retrieved from type info check.
*/
export interface TypeInfo {
name: string
comment: string
}
/**
* Default register options.
*/
export const DEFAULTS: RegisterOptions = {
dir: process.env.TS_NODE_DIR,
emit: yn(process.env.TS_NODE_EMIT),
scope: yn(process.env.TS_NODE_SCOPE),
files: yn(process.env.TS_NODE_FILES),
pretty: yn(process.env.TS_NODE_PRETTY),
compiler: process.env.TS_NODE_COMPILER,
compilerOptions: parse(process.env.TS_NODE_COMPILER_OPTIONS),
ignore: split(process.env.TS_NODE_IGNORE),
project: process.env.TS_NODE_PROJECT,
skipProject: yn(process.env.TS_NODE_SKIP_PROJECT),
skipIgnore: yn(process.env.TS_NODE_SKIP_IGNORE),
preferTsExts: yn(process.env.TS_NODE_PREFER_TS_EXTS),
ignoreDiagnostics: split(process.env.TS_NODE_IGNORE_DIAGNOSTICS),
transpileOnly: yn(process.env.TS_NODE_TRANSPILE_ONLY),
logError: yn(process.env.TS_NODE_LOG_ERROR)
}
/**
* Default TypeScript compiler options required by `ts-node`.
*/
const TS_NODE_COMPILER_OPTIONS = {
static init(command: string, flags: Record, args: string[], version) {
this.anonymous = yn(getSync(CFG_ANALYTICS_ANONYMOUS_KEY), { default: true });
this.command = command;
this.flags = this._hashFlags(flags);
this.release = version;
this.args = this._hashArgs(args);
this.nodeVersion = process.version;
this.os = process.platform;
this.level = LEVEL.INFO;
this.username = !this.anonymous
? getSync(CFG_USER_EMAIL_KEY) || getSync(CFG_USER_NAME_KEY) || os.hostname() || this.getID()
: this.getID();
this.analytics_usage = yn(getSync(CFG_ANALYTICS_REPORTING_KEY), { default: false });
this.error_usage = this.analytics_usage ? true : yn(getSync(CFG_ANALYTICS_ERROR_REPORTS_KEY), { default: false });
this.environment = getSync(CFG_ANALYTICS_ENVIRONMENT_KEY) || DEFAULT_BIT_ENV;
}
{
case "string":
if (typeof value !== "string") {
throw new Error("Invalid config value for type string!")
}
return String(value)
case "number":
parsed = parseFloat(value, 10)
if (isNaN(parsed)) {
throw new Error("Invalid config value for type number!")
}
return parsed
case "boolean":
return toBool(value)
case "path":
if (typeof value !== "string") {
throw new Error("Invalid config value for type path (string required)!")
}
return resolve(ROOT, value)
case "url":
if (typeof value !== "string") {
throw new Error("Invalid config value for type url (string required)!")
}
return value
case "array":
if (!(value instanceof Array)) {
throw new Error("Invalid config value for type array!")
export function isValidDimension(dimension) {
return !isTimeDimension(dimension) && !yn(dimension.annotations.hide_in_ui);
}
const defaultHierarchy = dimension.defaultHierarchy;
/** @type {DimensionItem} */
const dimensionItem = {
caption: dimension.caption,
cube: cubeItem.name,
defaultHierarchy: defaultHierarchy ? defaultHierarchy.name : undefined,
defaultYear: Number.parseInt(`${dmAnn.default_year}`, 10) || undefined,
hash: unique(uri),
hideInMap: dmAnn.hide_in_map
? yn(dmAnn.hide_in_map) || false
: !geoDimHeuristic || cubeItem.hideInMap,
hideInUi: dmAnn.hide_in_ui ? yn(dmAnn.hide_in_ui) || false : cubeItem.hideInUi,
hierarchies: [],
isRequired: yn(dmAnn.is_required) || false,
levelCount: 0,
name: dimension.name,
server: cubeItem.server,
type: timeDimHeuristic
? "TIME"
: geoDimHeuristic ? "GEOGRAPHY" : dmAnn.dim_type ? dmAnn.dim_type : "GENERIC",
uri
};
dimension.hierarchies.reduce(structHierarchyReducer, dimensionItem);
cubeItem.dimensions.push(dimensionItem);
return cubeItem;
};