Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getBackwardCompatibleEnv(type: EnvType): ?Compilers | ?Testers | ?string {
const envObj = this.getEnvsByType(type);
if (!envObj) return undefined;
if (Object.keys(envObj).length !== 1) return envObj; // it has more than one id, it's >= v13
const envId = Object.keys(envObj)[0];
if (
RA.isNilOrEmpty(envObj[envId].rawConfig) &&
RA.isNilOrEmpty(envObj[envId].options) &&
RA.isNilOrEmpty(envObj[envId].files)
) {
return envId;
}
return envObj;
}
static convertEnvToStringIfPossible(envObj: Envs | null | undefined): string | null | undefined | Envs {
if (!envObj) return undefined;
if (Object.keys(envObj).length !== 1) return envObj; // it has more than one id
const envId = Object.keys(envObj)[0];
if (
RA.isNilOrEmpty(envObj[envId].rawConfig) &&
RA.isNilOrEmpty(envObj[envId].options) &&
RA.isNilOrEmpty(envObj[envId].files)
) {
return envId;
}
return envObj;
}
() => pubsub.asyncIterator(SubsTypes.NewComment), (payload, variables = {}, context) => {
// TODO: can't add context in playground and test subscription without frontend
// disable auth for dev env?
if (isNilOrEmpty(context.user)) {
return false
}
const globalReportId = variables.input && variables.input.reportId
const reportId = Number(fromGlobalId(globalReportId).id)
return payload.report_id === reportId
}
),
getBackwardCompatibleEnv(type: EnvType): ?Compilers | ?Testers | ?string {
const envObj = this.getEnvsByType(type);
if (!envObj) return undefined;
if (Object.keys(envObj).length !== 1) return envObj; // it has more than one id, it's >= v13
const envId = Object.keys(envObj)[0];
if (
RA.isNilOrEmpty(envObj[envId].rawConfig) &&
RA.isNilOrEmpty(envObj[envId].options) &&
RA.isNilOrEmpty(envObj[envId].files)
) {
return envId;
}
return envObj;
}
async _populateEnvFilesIfNeeded() {
[this.component.compiler, this.component.tester].forEach(env => {
if (!env) return;
env.populateDataToPersist({
configDir: this.writeToPath,
consumer: this.consumer,
deleteOldFiles: false,
verbose: false,
envType: env.envType
});
this.component.dataToPersist.merge(env.dataToPersist);
});
const areThereEnvFiles =
(this.component.compiler && !RA.isNilOrEmpty(this.component.compiler.files)) ||
(this.component.tester && !RA.isNilOrEmpty(this.component.tester.files));
if (areThereEnvFiles && !this.writeConfig && !this.configDir && this.component.componentMap) {
this.configDir = DEFAULT_EJECTED_ENVS_DIR_PATH;
this.component.componentMap.setConfigDir(this.configDir);
}
}
async _populateEnvFilesIfNeeded() {
[this.component.compiler, this.component.tester].forEach(env => {
if (!env) return;
env.populateDataToPersist({
configDir: this.writeToPath,
consumer: this.consumer,
deleteOldFiles: false,
verbose: false,
envType: env.envType
});
this.component.dataToPersist.merge(env.dataToPersist);
});
const areThereEnvFiles =
(this.component.compiler && !RA.isNilOrEmpty(this.component.compiler.files)) ||
(this.component.tester && !RA.isNilOrEmpty(this.component.tester.files));
if (areThereEnvFiles && !this.writeConfig && !this.configDir && this.component.componentMap) {
this.configDir = DEFAULT_EJECTED_ENVS_DIR_PATH;
this.component.componentMap.setConfigDir(this.configDir);
}
}
resolve: (parentValues, args, { req: { user } }) => {
if (isNilOrEmpty(user)) {
return null
} else {
return user
}
},
},
resolve: async (parent, { id }) => {
const { id: convertedId } = fromGlobalId(id)
const post = await models.Post.findOne({
where: {
id: convertedId
}
})
return isNilOrEmpty(post) ? null : post
},
}
const nDefinitions = nodeDefinitions(async (globalId, { req: { user }}) => {
const { type, id: unparsedId } = fromGlobalId(globalId)
const id = Number(unparsedId)
if (isNilOrEmpty(type) || isNilOrEmpty(id) || isNaN(id)) {
throw new InvalidNodeIdError()
}
let foundNode = null
switch (type) {
case NodeGqlImplement.Post: {
foundNode = await models.Post.findById(id)
break
}
case NodeGqlImplement.Comment: {
foundNode = await models.Comment.findById(id)
break
}
case NodeGqlImplement.User: {
checkPermissions({ onlyLogged: true }, user)
foundNode = await models.User.findById(id)