MCPcopy Create free account
hub / github.com/parse-community/parse-server / inject

Function inject

resources/buildConfigDefinitions.js:260–345  ·  view source on GitHub ↗
(t, list)

Source from the content-addressed store, hash-verified

258}
259
260function inject(t, list) {
261 let comments = '';
262 const results = list
263 .map(elt => {
264 if (!elt.name) {
265 return;
266 }
267 const props = ['env', 'help']
268 .map(key => {
269 if (elt[key]) {
270 return t.objectProperty(t.stringLiteral(key), t.stringLiteral(elt[key]));
271 }
272 })
273 .filter(e => e !== undefined);
274 if (elt.required) {
275 props.push(t.objectProperty(t.stringLiteral('required'), t.booleanLiteral(true)));
276 }
277 const action = mapperFor(elt, t);
278 if (action) {
279 props.push(t.objectProperty(t.stringLiteral('action'), action));
280 }
281
282 if (t.isGenericTypeAnnotation(elt)) {
283 if (elt.typeAnnotation.id.name in nestedOptionEnvPrefix) {
284 props.push(
285 t.objectProperty(t.stringLiteral('type'), t.stringLiteral(elt.typeAnnotation.id.name))
286 );
287 }
288 } else if (t.isArrayTypeAnnotation(elt)) {
289 const elementType = elt.typeAnnotation.elementType;
290 if (t.isGenericTypeAnnotation(elementType)) {
291 if (elementType.id.name in nestedOptionEnvPrefix) {
292 props.push(
293 t.objectProperty(t.stringLiteral('type'), t.stringLiteral(elementType.id.name + '[]'))
294 );
295 }
296 }
297 }
298 if (elt.defaultValue) {
299 let parsedValue = parseDefaultValue(elt, elt.defaultValue, t);
300 if (!parsedValue) {
301 for (const type of elt.typeAnnotation.types) {
302 elt.type = type.type;
303 parsedValue = parseDefaultValue(elt, elt.defaultValue, t);
304 if (parsedValue) {
305 break;
306 }
307 }
308 }
309 if (parsedValue) {
310 props.push(t.objectProperty(t.stringLiteral('default'), parsedValue));
311 } else {
312 throw new Error(`Unable to parse value for ${elt.name} `);
313 }
314 }
315 let type = elt.type.replace('TypeAnnotation', '');
316 if (type === 'Generic') {
317 type = elt.typeAnnotation.id.name;

Callers 1

pluginFunction · 0.85

Calls 3

mapperForFunction · 0.85
parseDefaultValueFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…