|
|
@ -19,13 +19,20 @@ import type { |
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
export type LdoBase = Record<string, any>; |
|
|
|
export type LdoBase = Record<string, any>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @category Types |
|
|
|
|
|
|
|
* `LdoCompactBase` is an interface defining that a Linked Data Object |
|
|
|
|
|
|
|
* in compact format is a JavaScript Object Literal and has an id. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
export type LdoCompactBase = LdoBase & { id: string }; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Converts a node/string into just a node |
|
|
|
* Converts a node/string into just a node |
|
|
|
* @param input A Node or string |
|
|
|
* @param input A Node or string |
|
|
|
* @returns A node |
|
|
|
* @returns A node |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function normalizeNodeName<NodeType extends AnyNode>( |
|
|
|
export function normalizeNodeName<NodeType extends AnyNode>( |
|
|
|
input: NodeType | string, |
|
|
|
input: NodeType | string |
|
|
|
): NodeType { |
|
|
|
): NodeType { |
|
|
|
return (typeof input === "string" ? namedNode(input) : input) as NodeType; |
|
|
|
return (typeof input === "string" ? namedNode(input) : input) as NodeType; |
|
|
|
} |
|
|
|
} |
|
|
@ -36,13 +43,13 @@ export function normalizeNodeName<NodeType extends AnyNode>( |
|
|
|
* @returns An array of nodes |
|
|
|
* @returns An array of nodes |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function normalizeNodeNames<NodeType extends AnyNode>( |
|
|
|
export function normalizeNodeNames<NodeType extends AnyNode>( |
|
|
|
inputs: (NodeType | string)[], |
|
|
|
inputs: (NodeType | string)[] |
|
|
|
): NodeType[] { |
|
|
|
): NodeType[] { |
|
|
|
return inputs.map((input) => normalizeNodeName<NodeType>(input)); |
|
|
|
return inputs.map((input) => normalizeNodeName<NodeType>(input)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function canDatasetStartTransaction( |
|
|
|
export function canDatasetStartTransaction( |
|
|
|
dataset: Dataset, |
|
|
|
dataset: Dataset |
|
|
|
): dataset is ISubscribableDataset<Quad> { |
|
|
|
): dataset is ISubscribableDataset<Quad> { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
typeof (dataset as ISubscribableDataset).startTransaction === "function" |
|
|
|
typeof (dataset as ISubscribableDataset).startTransaction === "function" |
|
|
@ -50,13 +57,13 @@ export function canDatasetStartTransaction( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function isTransactionalDataset( |
|
|
|
export function isTransactionalDataset( |
|
|
|
dataset: Dataset, |
|
|
|
dataset: Dataset |
|
|
|
): dataset is ITransactionDataset<Quad> { |
|
|
|
): dataset is ITransactionDataset<Quad> { |
|
|
|
return typeof (dataset as ITransactionDataset).commit === "function"; |
|
|
|
return typeof (dataset as ITransactionDataset).commit === "function"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function getTransactionalDatasetFromLdo( |
|
|
|
export function getTransactionalDatasetFromLdo( |
|
|
|
ldo: LdoBase, |
|
|
|
ldo: LdoBase |
|
|
|
): [ITransactionDataset<Quad>, SubjectProxy | SetProxy] { |
|
|
|
): [ITransactionDataset<Quad>, SubjectProxy | SetProxy] { |
|
|
|
const proxy = getProxyFromObject(ldo); |
|
|
|
const proxy = getProxyFromObject(ldo); |
|
|
|
const dataset = proxy[_getUnderlyingDataset]; |
|
|
|
const dataset = proxy[_getUnderlyingDataset]; |
|
|
|