Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createType = (env, name, typeName, deserialize) => {
return new yaml.Type(name, {
kind: 'scalar', // Takes a string as input
resolve: (data) => {
return typeof data === 'string' && /^[A-Z0-9_]+$/.test(data);
},
// Deserialize the data, in the case we read the environment variable
construct: (data) => {
let value = env[data];
if (value === undefined) {
return value;
}
assert(typeof value === 'string', `${name} key env vars must be strings: ${data} is ${typeof value}`);
return deserialize(value);
},
});
};
function tagToType(yamlTag) {
let { tag, kind, handler } = yamlTag;
let tagType = getTagType(tag);
if (tagType === TAG_TYPES.UNKNOWN) {
throw new Error(`plugin ${tag} type is invalid`);
}
return new yaml.Type(tag, { kind, construct: createTypeConstructor(tagType, handler) });
}
const includeYamlType = (embeddingFilePath, sourcePaths) =>
new yaml.Type('!include', {
kind: 'scalar',
construct (includePath) {
let basedir
if (isAbsolute(includePath)) {
basedir = sourcePaths.base
} else {
basedir = dirname(resolve(embeddingFilePath))
}
assert(basedir, `YAML Include Schema requires an absolute path (root is ${basedir})`)
const filePath = join(basedir, includePath)
return fromExternalFile(embeddingFilePath, sourcePaths, filePath)
}
})
return { "Fn::Select": data };
}
}),
new yaml.Type("!FindInMap", {
kind: "sequence",
construct: function(data) {
return { "Fn::FindInMap": data };
}
}),
new yaml.Type("!GetAtt", {
kind: "sequence",
construct: function(data) {
return { "Fn::GetAtt": data };
}
}),
new yaml.Type("!GetAZs", {
kind: "scalar",
construct: function(data) {
return { "Fn::GetAZs": data };
}
}),
new yaml.Type("!Base64", {
kind: "mapping",
construct: function(data) {
return { "Fn::Base64": data };
}
})
]);
function ConvertibleProject(data) {
Object.assign(this, data)
this[typeProperty] = 'ConvertibleProject'
}
let ConvertibleProjectYamlType = new jsyaml.Type('!com.amazonaws.mobilehub.ConvertibleProject', {
kind: 'mapping',
construct: data => new ConvertibleProject(data),
instanceOf: ConvertibleProject
})
function FeatureFactory(data) {
Object.assign(this, data)
this[typeProperty] = 'FeatureFactory'
}
let FeatureFactoryYamlType = new jsyaml.Type('!com.amazonaws.mobilehub.FeatureFactory', {
kind: 'mapping',
construct: data => new FeatureFactory(data),
instanceOf: FeatureFactory
})
function FileUploader(data) {
Object.assign(this, data)
this[typeProperty] = 'FileUploader'
}
let FileUploaderYamlType = new jsyaml.Type('!com.amazonaws.mobilehub.FileUploader', {
kind: 'mapping',
construct: data => new FileUploader(data),
instanceOf: FileUploader
})
function SharedComponentFactory(data) {
kind: 'scalar',
construct (includePath) {
let basedir
if (isAbsolute(includePath)) {
basedir = sourcePaths.base
} else {
basedir = dirname(resolve(embeddingFilePath))
}
assert(basedir, `YAML Include Schema requires an absolute path (root is ${basedir})`)
const filePath = join(basedir, includePath)
return fromExternalFile(embeddingFilePath, sourcePaths, filePath)
}
})
const MarkdownYamlType = new yaml.Type('!markdown', {
kind: 'scalar',
resolve (data) {
return typeof data === 'string'
},
construct (string) {
return renderMarkdown(string)
}
})
const parseString = (string, filename, sourcePaths) => {
try {
const IncludeYamlType = includeYamlType(filename, sourcePaths)
const DataYamlType = dataYamlType(filename, sourcePaths)
const schema = yaml.Schema.create([IncludeYamlType, DataYamlType, MarkdownYamlType])
import util from 'util';
import connectComponent from '../../../redux/store/connectComponent';
import DiffComponent from './DiffComponent';
import './style.less';
export const PAGE_ROUTE = '/base-information/global-config/+add/:profile';
const Option = Select.Option;
const FormItem = Form.Item;
const inspect = util.inspect;
let source,
result,
permalink,
default_text;
const SexyYamlType = new jsyaml.Type('!sexy', {
kind: 'sequence',
construct: function (data) {
return data.map(function (string) {
return 'sexy ' + string;
});
}
});
const SEXY_SCHEMA = jsyaml.Schema.create([SexyYamlType]);
class GlobalConfigAddEdit extends Component {
state = {
title: '新增配置',
isEdit: false,
globalConfig: [],
saveAndUpdataLoading: false,
profile: [],
kind: 'mapping',
construct: function (data) {
return new PinpointMessaging(data.attributes);
},
instanceOf: PinpointMessaging
});
var BotsType = new yaml.Type('!com.amazonaws.mobilehub.v0.Bots', {
kind: 'mapping',
construct: function (data) {
return new Bots(data);
},
instanceOf: Bots
});
var BotType = new yaml.Type('!com.amazonaws.mobilehub.v0.Bot', {
kind: 'mapping',
construct: function (data) {
return new Bot(data.attributes);
},
instanceOf: Bot
});
var UserSettingsType = new yaml.Type('!com.amazonaws.mobilehub.v0.UserSettings', {
kind: 'mapping',
construct: function (data) {
return new UserSettings(data.attributes);
},
instanceOf: UserSettings
});
var UserFilesType = new yaml.Type('!com.amazonaws.mobilehub.v0.UserFiles', {
import yaml from 'js-yaml';
import moment from 'moment';
import AssetProxy from 'ValueObjects/AssetProxy';
import { sortKeys } from './helpers';
const MomentType = new yaml.Type('date', {
kind: 'scalar',
predicate(value) {
return moment.isMoment(value);
},
represent(value) {
return value.format(value._f);
},
resolve(value) {
return moment.isMoment(value) && value._f;
},
});
const ImageType = new yaml.Type('image', {
kind: 'scalar',
instanceOf: AssetProxy,
represent(value) {
kind: 'mapping',
construct: function (data) {
return new Bot(data.attributes);
},
instanceOf: Bot
});
var UserSettingsType = new yaml.Type('!com.amazonaws.mobilehub.v0.UserSettings', {
kind: 'mapping',
construct: function (data) {
return new UserSettings(data.attributes);
},
instanceOf: UserSettings
});
var UserFilesType = new yaml.Type('!com.amazonaws.mobilehub.v0.UserFiles', {
kind: 'mapping',
construct: function (data) {
return new UserFiles(data.attributes);
},
instanceOf: UserFiles
});
var DatabaseType = new yaml.Type('!com.amazonaws.mobilehub.v0.Database', {
kind: 'mapping',
construct: function (data) {
return new Database(data);
},
instanceOf: Database
});
var DatabaseNoSQLType = new yaml.Type('!com.amazonaws.mobilehub.v0.NoSQLDatabase', {