export function ifParentIsObjectLiteral(this: DeclarationReflection, truthy: boolean, options: any) { const parentIsObjectLiteral = this.parent && this.parent.parent && this.parent.parent.kind === ReflectionKind.ObjectLiteral; if (parentIsObjectLiteral && truthy) { return options.fn(this); } return !parentIsObjectLiteral && !truthy ? options.fn(this) : options.inverse(this); }
parseLiteral(ast) { if (ast.kind !== Kind.STRING) { throw new TypeError(`Time cannot represent non string type`); } const value = ast.value; return parseType({ type: 'time', value }); }
const canEditContentType = (data, modifiedData) => { const kind = get(data, ['contentType', 'schema', 'kind'], ''); // if kind isn't modified or content type is a single type, there is no need to check attributes. if (kind === 'singleType' || kind === modifiedData.kind) { return true; } const contentTypeAttributes = get(data, ['contentType', 'schema', 'attributes'], ''); const relationAttributes = Object.values(contentTypeAttributes).filter( ({ nature }) => nature && !['oneWay', 'manyWay'].includes(nature) ); return relationAttributes.length === 0; }
private onResolve(context: Context, reflection: ContainerReflection) { reflection.kindString = CubejsGroupPlugin.getKindSingular(reflection.kind); if (reflection.children && reflection.children.length > 0) { this.populateOrder(reflection.children); reflection.children.sort(CubejsGroupPlugin.sortCallback); reflection.groups = CubejsGroupPlugin.getReflectionGroups(reflection.children); } }
/** * @see DefaultTheme.getMapping * Return the template mapping for the given reflection. * * @param reflection The reflection whose mapping should be resolved. * @returns The found mapping or undefined if no mapping could be found. */ static getMapping(reflection: DeclarationReflection): TemplateMapping | undefined { return MarkdownTheme.MAPPINGS.find((mapping) => reflection.kindOf(mapping.kind)); }
generateMarkDown( data() .get() .filter((d) => !d.undocumented && d.kind !== 'typedef') )
export function ifIsLiteralType(this: DeclarationReflection, truthy: boolean, options: any) { const isLiteralType = this.kind === ReflectionKind.ObjectLiteral || this.kind === ReflectionKind.TypeLiteral; if (isLiteralType && truthy) { return options.fn(this); } return !isLiteralType && !truthy ? options.fn(this) : options.inverse(this); }
const refToStrapiRef = obj => { const ref = obj.ref; let plainData = ref && typeof ref.toJSON === 'function' ? ref.toJSON() : ref; if (typeof plainData !== 'object') return ref; return { __contentType: obj.kind, ...ref, }; }
const getNamedAstType = node => { if (node && node.kind !== Kind.NAMED_TYPE) { return getNamedAstType(node.type) } return node }
export function ifParentIsModule(this: DeclarationReflection, truthy: boolean, options: any) { const parentIsModule = this.parent && this.parent.kind === ReflectionKind.Module; if (parentIsModule && truthy) { return options.fn(this); } return !parentIsModule && !truthy ? options.fn(this) : options.inverse(this); }
const getNamedAstType = node => { if (node && node.kind !== Kind.NAMED_TYPE) { return getNamedAstType(node.type) } return node }
const refToStrapiRef = obj => { const ref = obj.ref; let plainData = ref && typeof ref.toJSON === 'function' ? ref.toJSON() : ref; if (typeof plainData !== 'object') return ref; return { __contentType: obj.kind, ...ref, }; }
const canEditContentType = (data, modifiedData) => { const kind = get(data, ['contentType', 'schema', 'kind'], ''); // if kind isn't modified or content type is a single type, there is no need to check attributes. if (kind === 'singleType' || kind === modifiedData.kind) { return true; } const contentTypeAttributes = get(data, ['contentType', 'schema', 'attributes'], ''); const relationAttributes = Object.values(contentTypeAttributes).filter( ({ nature }) => nature && !['oneWay', 'manyWay'].includes(nature) ); return relationAttributes.length === 0; }