Socket
Socket
Sign inDemoInstall

@rdfjs/types

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0-next.1 to 1.1.0

rdf-js-query-tests.ts

12

CHANGELOG.md
# @rdfjs/types
## 1.1.0
### Minor Changes
- 95f1e31: Dataset: Use correct type of `dataset` in methods with callbacks
- 2539ab3: Add queryable interfaces
### Patch Changes
- 8164183: Documentation Fix: Update reference of Quad to BaseQuad in the definition of Term in order to align with the type declaration.
- a19ed91: Make queryable metadata types configurable
## 1.1.0-next.1

@@ -4,0 +16,0 @@

2

package.json
{
"name": "@rdfjs/types",
"version": "1.1.0-next.1",
"version": "1.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "types": "index.d.ts",

@@ -5,5 +5,4 @@ /* Query Interfaces */

export * from './query/common';
export * from './query/filterable';
export * from './query/queryable';

@@ -188,10 +188,10 @@ /* Query Interfaces - Common */

* Check if a binding exist for the given variable.
* @param key A variable
* @param key A variable term or string. If it is a string, no `?` prefix must be given.
*/
has: (key: RDF.Variable) => boolean;
has: (key: RDF.Variable | string) => boolean;
/**
* Obtain the binding value for the given variable.
* @param key A variable
* @param key A variable term or string. If it is a string, no `?` prefix must be given.
*/
get: (key: RDF.Variable) => RDF.Term | undefined;
get: (key: RDF.Variable | string) => RDF.Term | undefined;
/**

@@ -202,6 +202,6 @@ * Create a new Bindings object by adding the given variable and value mapping.

*
* @param key The variable key.
* @param key The variable key term or string. If it is a string, no `?` prefix must be given.
* @param value The value.
*/
set: (key: RDF.Variable, value: RDF.Term) => Bindings;
set: (key: RDF.Variable | string, value: RDF.Term) => Bindings;
/**

@@ -212,5 +212,5 @@ * Create a new Bindings object by removing the given variable.

*
* @param key The variable key.
* @param key The variable key term or string. If it is a string, no `?` prefix must be given.
*/
delete: (key: RDF.Variable) => Bindings;
delete: (key: RDF.Variable | string) => Bindings;
/**

@@ -217,0 +217,0 @@ * Obtain all variables for which mappings exist.

@@ -8,10 +8,6 @@ /* Query Interfaces - Queryable */

/**
* Context objects provide a way to pass additional bits information to the query engine when executing a query.
* Context properties provide a way to pass additional bits information to the query engine when executing a query.
*/
export interface QueryContext<SourceType> {
export interface QueryContext {
/**
* An array of data sources the query engine must use.
*/
sources?: [SourceType, ...SourceType[]];
/**
* The date that should be used by SPARQL operations such as NOW().

@@ -27,5 +23,5 @@ */

/**
* Context object in the case the passed query is a string.
* Context properties in the case the passed query is a string.
*/
export interface QueryStringContext<SourceType> extends QueryContext<SourceType> {
export interface QueryStringContext extends QueryContext {
/**

@@ -43,7 +39,17 @@ * The format in which the query string is defined.

/**
* Context object in the case the passed query is an algebra object.
* Context properties in the case the passed query is an algebra object.
*/
export type QueryAlgebraContext<SourceType> = QueryContext<SourceType>;
export type QueryAlgebraContext = QueryContext;
/**
* Context properties for engines that can query upon dynamic sets of sources.
*/
export interface QuerySourceContext<SourceType> {
/**
* An array of data sources the query engine must use.
*/
sources: [SourceType, ...SourceType[]];
}
/**
* Represents a specific query format

@@ -68,28 +74,13 @@ */

/**
* Placeholder to represent SPARQL Algebra trees.
* Algebra typings are TBD. Reference implementations include:
* - https://www.npmjs.com/package/sparqlalgebrajs
*/
export type Algebra = any;
/**
* Generic query engine interfaces.
* It allow engines to return any type of result object for any type of query.
* @param QueryFormatTypesAvailable The format of the query, either string or algebra object.
* @param SourceType The allowed sources over which queries can be executed.
* It allow engines to return any type of result object for string queries.
* @param SupportedMetadataType The allowed metadata types.
* @param QueryType The allowed query types.
* @param QueryStringContextType Type of the string-based query context.
* @param QueryAlgebraContextType Type of the algebra-based query context.
*/
export interface Queryable<
QueryFormatTypesAvailable extends string | Algebra,
SourceType,
export interface StringQueryable<
SupportedMetadataType,
QueryType extends Query<SupportedMetadataType>,
QueryStringContextType extends QueryStringContext<SourceType>,
QueryAlgebraContextType extends QueryAlgebraContext<SourceType>,
QueryStringContextType extends QueryStringContext = QueryStringContext,
> {
/**
* Initiate a given query.
* Initiate a given query provided as a string.
*

@@ -102,46 +93,69 @@ * This will produce a future to a query result, which has to be executed to obtain the query results.

*/
query<QueryFormatType extends QueryFormatTypesAvailable>(
query: QueryFormatType,
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType,
): Promise<QueryType>;
query(query: string, context?: QueryStringContextType): Promise<Query<SupportedMetadataType>>;
}
/**
* SPARQL-constrainted query interface.
* Generic query engine interfaces.
* It allow engines to return any type of result object for Algebra queries.
* @param AlgebraType The supported algebra types.
* @param SupportedMetadataType The allowed metadata types.
* @param QueryStringContextType Type of the algebra-based query context.
*/
export interface AlgebraQueryable<
AlgebraType,
SupportedMetadataType,
QueryAlgebraContextType extends QueryAlgebraContext = QueryAlgebraContext,
> {
/**
* Initiate a given query provided as an Algebra object.
*
* This will produce a future to a query result, which has to be executed to obtain the query results.
*
* This can reject given an unsupported or invalid query.
*
* @see Query
*/
query(query: AlgebraType, context?: QueryAlgebraContextType): Promise<Query<SupportedMetadataType>>;
}
/**
* SPARQL-constrained query interface for queries provided as strings.
*
* This interface guarantees that result objects are of the expected type as defined by the SPARQL spec.
*/
export type SparqlQueryable<
QueryFormatTypesAvailable extends string | Algebra,
SourceType,
QueryStringContextType extends QueryStringContext<SourceType>,
QueryAlgebraContextType extends QueryAlgebraContext<SourceType>,
SupportedResultType,
> = unknown
export type StringSparqlQueryable<SupportedResultType, QueryStringContextType extends QueryStringContext = QueryStringContext> = unknown
& (SupportedResultType extends BindingsResultSupport ? {
queryBindings<QueryFormatType extends QueryFormatTypesAvailable>(
query: QueryFormatType,
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType,
): Promise<ResultStream<Bindings>>;
queryBindings(query: string, context?: QueryStringContextType): Promise<ResultStream<Bindings>>;
} : unknown)
& (SupportedResultType extends BooleanResultSupport ? {
queryBoolean<QueryFormatType extends QueryFormatTypesAvailable>(
query: QueryFormatType,
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType,
): Promise<boolean>;
queryBoolean(query: string, context?: QueryStringContextType): Promise<boolean>;
} : unknown)
& (SupportedResultType extends QuadsResultSupport ? {
queryQuads<QueryFormatType extends QueryFormatTypesAvailable>(
query: QueryFormatType,
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType,
): Promise<ResultStream<RDF.Quad>>;
queryQuads(query: string, context?: QueryStringContextType): Promise<ResultStream<RDF.Quad>>;
} : unknown)
& (SupportedResultType extends VoidResultSupport ? {
queryVoid<QueryFormatType extends QueryFormatTypesAvailable>(
query: QueryFormatType,
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType,
): Promise<void>;
queryVoid(query: string, context?: QueryStringContextType): Promise<void>;
} : unknown)
;
;
/**
* SPARQL-constrainted query interface for queries provided as Algebra objects.
*
* This interface guarantees that result objects are of the expected type as defined by the SPARQL spec.
*/
export type AlgebraSparqlQueryable<AlgebraType, SupportedResultType, QueryAlgebraContextType extends QueryAlgebraContext = QueryAlgebraContext> = unknown
& (SupportedResultType extends BindingsResultSupport ? {
queryBindings(query: AlgebraType, context?: QueryAlgebraContextType): Promise<ResultStream<Bindings>>;
} : unknown)
& (SupportedResultType extends BooleanResultSupport ? {
queryBoolean(query: AlgebraType, context?: QueryAlgebraContextType): Promise<boolean>;
} : unknown)
& (SupportedResultType extends QuadsResultSupport ? {
queryQuads(query: AlgebraType, context?: QueryAlgebraContextType): Promise<ResultStream<RDF.Quad>>;
} : unknown)
& (SupportedResultType extends VoidResultSupport ? {
queryVoid(query: AlgebraType, context?: QueryAlgebraContextType): Promise<void>;
} : unknown)
;
export type SparqlResultSupport = BindingsResultSupport & VoidResultSupport & QuadsResultSupport & BooleanResultSupport;

@@ -148,0 +162,0 @@ export type BindingsResultSupport = { bindings: true };

@@ -12,3 +12,3 @@ # RDF/JS Types

```
yarn add @types/rdf-js
yarn add @rdfjs/types
```

@@ -15,0 +15,0 @@

@@ -14,8 +14,10 @@ {

"noEmit": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true
},
"files": [
"index.d.ts",
"rdf-js-tests.ts"
"rdf-js-tests.ts",
"rdf-js-query-tests.ts"
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc