Expand description
Library for cargo-indicate
, providing a way to query dependencies across
different sources of information such as crates.io metadata, GitHub etc.
Queries are written using trustfall
, a query engine for writing queries
across data sources. Currently only GraphQL-like schemas are available. The
following is the schema used that can be used to construct queries. Note
that only the directives provided here can be used.
Schema
The following code is automatically included from the
src/schema.trustfall.graphql
file
# This is not truly a GraphQL file; Instead it is a GraphQL representation of
# the types provided by `indicate`.
# _This is the single source of truth for `indicate`. Any deviation from it is
# to be considered a bug._
# This is the currently supported Trustfall directives. They are handled by the
# Trustfall engine.
schema {
query: RootQuery
}
directive @filter(
"""
Name of the filter operation to perform.
"""
op: String!
"""
List of string operands for the operator.
"""
value: [String!]
) on FIELD | INLINE_FRAGMENT
directive @tag(
"""
Name to apply to the given property field.
"""
name: String
) on FIELD
directive @output(
"""
What to designate the output field generated from this property field.
"""
name: String
) on FIELD
directive @optional on FIELD
directive @recurse(
"""
Recurse up to this many times on this edge. A depth of 1 produces the
current vertex and its immediate neighbors along the given edge.
"""
depth: Int!
) on FIELD
directive @fold on FIELD
directive @transform(
"""
Name of the transformation operation to perform.
"""
op: String!
) on FIELD
"""
This is the actual types that can be used to create queries.
"""
type RootQuery {
RootPackage: Package!
Dependencies(includeRoot: Boolean!): [Package!]!
"""
Dependencies that are indirect dependencies of the root package;
excluding direct dependencies that are _only_ direct dependencies, and
appear nowhere else in the dependency tree
"""
TransitiveDependencies: [Package!]!
}
# See `cargo_metadata::Package`
type Package {
id: ID!,
name: String!,
version: String!,
license: String
keywords: [String!]!
categories: [String!]!
manifestPath: String!
sourcePath: String!
# This is expensive, due to crates.io crawler policy
cratesIo: CratesIoStats!
repository: Webpage
# All parameters except `ignorePaths` is exactly the same as `tokei::Config`
codeStats(
# If any patterns should be ignored, defaults to an empty list.
ignoredPaths: [String!],
# To target only some patterns. Defaults to all. If used,
# `ignoredPaths` is still applied
includedPaths: [String!],
hidden: Boolean,
noIgnore: Boolean,
noIgnoreParent: Boolean,
noIgnoreDot: Boolean,
noIgnoreVcs: Boolean,
treatDocStringsAsComments: Boolean,
types: [String!] # Types of languages to be included in report
): [LanguageCodeStats!]!
dependencies: [Package!]!
# For arch and OS, see `platforms::target`
# For severity, see `rustsec::advisory::Severity`
advisoryHistory(
includeWithdrawn: Boolean!,
arch: String,
os: String,
minSeverity: String
): [Advisory!]!
geiger: GeigerUnsafety
}
type CratesIoStats {
totalDownloads: Int
recentDownloads: Int
versionDownloads: Int
versionsCount: Int
yanked: Boolean # If this version is yanked from crates.io
yankedVersions: [String!]
yankedVersionsCount: Int
yankedRatio: Float # yanked versions count / versions count
}
# Data from tokei, shared between `Language` and `CodeStats`
interface CodeStats {
# Name of the language
language: String!
# Total number of files
files: Int!
# Total number of lines
lines: Int!
# Total number of blank lines
blanks: Int!
# Total number of lines of code
code: Int!
# Number of lines of comments
comments: Int!
# Lines of comments / lines of code
commentsToCode: Float!
}
# `tokei::Language`
type LanguageCodeStats implements CodeStats {
# From CodeStats
language: String!
files: Int!
lines: Int!
blanks: Int!
code: Int!
comments: Int!
commentsToCode: Float!
# From `tokei::Languge::summarize()`
summary: LanguageCodeStats!
# If this language had problem with parsing
inaccurate: Boolean!
# Code contained in this
children: [LanguageBlob!]!
}
# `tokei::CodeStats.blobs`
type LanguageBlob implements CodeStats {
# From CodeStats
language: String!
files: Int!
lines: Int!
blanks: Int!
code: Int!
comments: Int!
commentsToCode: Float!
# Merge this with all child blobs to create new `CodeStats`
# (`tokei::CodeStats::summarize()`)
summary: LanguageBlob!
# Blobs of code contained within this one
blobs: [LanguageBlob!]!
}
type GeigerUnsafety {
# `used` refers to code used by the `RootPackage`
used: GeigerCategories!
unused: GeigerCategories!
# used + unused
total: GeigerCategories!
forbidsUnsafe: Boolean!
}
type GeigerCategories {
functions: GeigerCount!
exprs: GeigerCount!
item_impls: GeigerCount!
item_traits: GeigerCount!
methods: GeigerCount!
# (functions.safe + exprs.safe + ...), (functions.unsafe + ...)
total: GeigerCount!
}
type GeigerCount {
safe: Int!
unsafe: Int!
# safe + unsafe
total: Int!
percentageUnsafe: Float!
}
interface Webpage {
url: String!
}
interface Repository implements Webpage {
url: String!
}
type GitHubRepository implements Repository & Webpage {
# From Repository and Webpage
url: String!
owner: GitHubUser
name: String!
starsCount: Int!
forksCount: Int!
# This is the sum of open issues and open PRs
openIssuesCount: Int!
watchersCount: Int!
# If the issues page is available for this repository
hasIssues: Boolean!
archived: Boolean!
# If this is a fork
fork: Boolean!
}
type GitHubUser {
username: String!
email: String!
unixCreatedAt: Int
followersCount: Int!
}
# Partly flattened `rustsec::advisory::Advisory`
type Advisory {
# These fields are flattened out of `rustsec::advisory::Metadata`
id: String!
title: String!
description: String!
unixDateReported: Int!
severity: String
# These are provided by `rustsec::advisory::Affected`
# They may be empty, so a `None` means that we do not know
affectedArch: [String!]
affectedOs: [String!]
affectedFunctions: [AffectedFunctionVersions!]
# These are provided by `rustsec::advisory::Versions`
patchedVersions: [String!]!
unaffectedVersions: [String!]!
# If it was reported in error, this will indicate when it was withdrawn
unixDateWithdrawn: Int
#cvss: CvssBase # TODO: Add when Trustfall supports enums
}
# `Map<FunctionPath, Vec<VersionReq>>` from `rustsec::advisory::Affected`
type AffectedFunctionVersions {
functionPath: String!
versions: [String!]!
}
Re-exports
pub use crate::adapter::adapter_builder::IndicateAdapterBuilder;
pub use crate::adapter::IndicateAdapter;
pub use crate::manifest::ManifestPath;
pub use rustsec::platforms;
pub use tokei;
Modules
- Client used to retrieve stats such as number of lines etc. for different Rust packages
- Client and methods for retrieving information from the crates.io API
- Module to parse the output of
cargo-geiger
- These are signals related to repositories, such as GitHub or GitLab.
Structs
Enums
- Features to create metadata with Cargo features flags
- Qualitative Severity Rating Scale
Constants
Functions
- Executes a Trustfall query at a defined path, using the schema provided by
indicate
- Executes a Trustfall query with a dedicated
IndicateAdapter
, that may be reused