Reconcile interfaces

main
Jackson Morgan 5 months ago
parent ef4e07ce93
commit 9afd82ee69
  1. 6
      packages/connected/src/ConnectedLdoDataset.ts
  2. 4
      packages/connected/src/ConnectedLdoTransactionDataset.ts
  3. 2
      packages/connected/src/createConntectedLdoDataset.ts
  4. 8
      packages/connected/src/index.ts
  5. 4
      packages/connected/src/notifications/NotificationSubscription.ts
  6. 0
      packages/connected/src/notifications/SubscriptionCallbacks.ts
  7. 2
      packages/connected/src/types/ConnectedContext.ts
  8. 4
      packages/connected/src/types/ConnectedPlugin.ts
  9. 12
      packages/connected/src/types/IConnectedLdoBuilder.ts
  10. 2
      packages/connected/src/types/IConnectedLdoDataset.ts
  11. 88
      packages/connected/src/types/linkQuery/LinkQuery.ts
  12. 0
      packages/connected/src/types/linkQuery/test.ts
  13. 1
      packages/ldo/test/profileData.ts

@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import type { LdoBase, ShapeType } from "@ldo/ldo"; import type { LdoBase, ShapeType } from "@ldo/ldo";
import { LdoDataset, startTransaction } from "@ldo/ldo"; import { LdoDataset, startTransaction } from "@ldo/ldo";
import type { ConnectedPlugin } from "./ConnectedPlugin"; import type { ConnectedPlugin } from "./types/ConnectedPlugin";
import type { Dataset, DatasetFactory, Quad } from "@rdfjs/types"; import type { Dataset, DatasetFactory, Quad } from "@rdfjs/types";
import type { ITransactionDatasetFactory } from "@ldo/subscribable-dataset"; import type { ITransactionDatasetFactory } from "@ldo/subscribable-dataset";
import { InvalidIdentifierResource } from "./InvalidIdentifierResource"; import { InvalidIdentifierResource } from "./InvalidIdentifierResource";
import type { ConnectedContext } from "./ConnectedContext"; import type { ConnectedContext } from "./types/ConnectedContext";
import type { import type {
GetResourceReturnType, GetResourceReturnType,
IConnectedLdoDataset, IConnectedLdoDataset,
} from "./IConnectedLdoDataset"; } from "./types/IConnectedLdoDataset";
import { ConnectedLdoTransactionDataset } from "./ConnectedLdoTransactionDataset"; import { ConnectedLdoTransactionDataset } from "./ConnectedLdoTransactionDataset";
import type { SubjectNode } from "@ldo/rdf-utils"; import type { SubjectNode } from "@ldo/rdf-utils";

@ -6,12 +6,12 @@ import {
type ITransactionDatasetFactory, type ITransactionDatasetFactory,
} from "@ldo/subscribable-dataset"; } from "@ldo/subscribable-dataset";
import type { DatasetChanges, GraphNode } from "@ldo/rdf-utils"; import type { DatasetChanges, GraphNode } from "@ldo/rdf-utils";
import type { ConnectedPlugin } from "./ConnectedPlugin"; import type { ConnectedPlugin } from "./types/ConnectedPlugin";
import type { ConnectedContext } from "./ConnectedContext"; import type { ConnectedContext } from "./ConnectedContext";
import type { import type {
GetResourceReturnType, GetResourceReturnType,
IConnectedLdoDataset, IConnectedLdoDataset,
} from "./IConnectedLdoDataset"; } from "./types/IConnectedLdoDataset";
import { splitChangesByGraph } from "./util/splitChangesByGraph"; import { splitChangesByGraph } from "./util/splitChangesByGraph";
import type { IgnoredInvalidUpdateSuccess } from "./results/success/UpdateSuccess"; import type { IgnoredInvalidUpdateSuccess } from "./results/success/UpdateSuccess";
import { UpdateDefaultGraphSuccess } from "./results/success/UpdateSuccess"; import { UpdateDefaultGraphSuccess } from "./results/success/UpdateSuccess";

@ -1,6 +1,6 @@
import { createDatasetFactory } from "@ldo/dataset"; import { createDatasetFactory } from "@ldo/dataset";
import { ConnectedLdoDataset } from "./ConnectedLdoDataset"; import { ConnectedLdoDataset } from "./ConnectedLdoDataset";
import type { ConnectedPlugin } from "./ConnectedPlugin"; import type { ConnectedPlugin } from "./types/ConnectedPlugin";
import { createTransactionDatasetFactory } from "@ldo/subscribable-dataset"; import { createTransactionDatasetFactory } from "@ldo/subscribable-dataset";
/** /**

@ -1,13 +1,13 @@
export * from "./IConnectedLdoDataset"; export * from "./types/IConnectedLdoDataset";
export * from "./ConnectedLdoDataset"; export * from "./ConnectedLdoDataset";
export * from "./ConnectedLdoTransactionDataset"; export * from "./ConnectedLdoTransactionDataset";
export * from "./ConnectedPlugin"; export * from "./types/ConnectedPlugin";
export * from "./Resource"; export * from "./Resource";
export * from "./InvalidIdentifierResource"; export * from "./InvalidIdentifierResource";
export * from "./ConnectedContext"; export * from "./types/ConnectedContext";
export * from "./methods"; export * from "./methods";
export * from "./createConntectedLdoDataset"; export * from "./createConntectedLdoDataset";
export * from "./SubscriptionCallbacks"; export * from "./notifications/SubscriptionCallbacks";
export * from "./util/splitChangesByGraph"; export * from "./util/splitChangesByGraph";

@ -1,7 +1,7 @@
import { v4 } from "uuid"; import { v4 } from "uuid";
import type { ConnectedPlugin } from "../ConnectedPlugin"; import type { ConnectedPlugin } from "../types/ConnectedPlugin";
import type { ConnectedContext } from "../ConnectedContext"; import type { ConnectedContext } from "../ConnectedContext";
import type { SubscriptionCallbacks } from "../SubscriptionCallbacks"; import type { SubscriptionCallbacks } from "./SubscriptionCallbacks";
import type { NotificationCallbackError } from "../results/error/NotificationErrors"; import type { NotificationCallbackError } from "../results/error/NotificationErrors";
/** /**

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import type { ConnectedLdoDataset } from "./ConnectedLdoDataset"; import type { ConnectedLdoDataset } from "./ConnectedLdoDataset";
import type { ConnectedPlugin } from "./ConnectedPlugin"; import type { ConnectedPlugin } from "./types/ConnectedPlugin";
/** /**
* Each Plugin comes with a context. This is the aggregate of all those contexts * Each Plugin comes with a context. This is the aggregate of all those contexts

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import type { ConnectedContext } from "./ConnectedContext"; import type { ConnectedContext } from "./ConnectedContext";
import type { Resource } from "./Resource"; import type { Resource } from "../Resource";
import type { ErrorResult } from "./results/error/ErrorResult"; import type { ErrorResult } from "../results/error/ErrorResult";
/** /**
* A ConnectedPlugin can be passed to a ConnectedDataset to allow it to connect * A ConnectedPlugin can be passed to a ConnectedDataset to allow it to connect

@ -0,0 +1,12 @@
import type { LdoBase, LdoBuilder } from "@ldo/ldo";
import type { ConnectedPlugin } from "./ConnectedPlugin";
import { SubjectNode } from "@ldo/rdf-utils";
export interface IConnectedLdoBuilder<
Type extends LdoBase,
Plugins extends ConnectedPlugin[],
> extends LdoBuilder<Type> {
fromLinkQuery(startingResource: Plugins[number]["types"]["resource"], startingSubject: SubjectNode | string, linkQueryInput:
)
}

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import type { LdoDataset } from "@ldo/ldo"; import type { LdoDataset } from "@ldo/ldo";
import type { ConnectedPlugin } from "./ConnectedPlugin"; import type { ConnectedPlugin } from "./ConnectedPlugin";
import type { InvalidIdentifierResource } from "./InvalidIdentifierResource"; import type { InvalidIdentifierResource } from "../InvalidIdentifierResource";
export type ReturnTypeFromArgs<Func, Arg> = Func extends ( export type ReturnTypeFromArgs<Func, Arg> = Func extends (
arg: Arg, arg: Arg,

@ -0,0 +1,88 @@
// This file is a stripped down version of a full-implmentation of a global
// query interface found here https://github.com/o-development/ldo-query/blob/main/lib/ShapeQuery.ts
// If I ever want to implement a global query interface, this is a good place
// to start.
import type { LdoBase, LdSet, ShapeType } from "@ldo/ldo";
import { ProfileShapeType } from "packages/ldo/test/profileData";
import { SolidProfileShape } from "packages/ldo/test/profileData";
import { PostShShapeType } from "packages/solid-react/test/.ldo/post.shapeTypes";
/**
* Link Query Input
*/
export type LQInputObject<Type> = Partial<{
[key in keyof Type]: LQInput<Type[key]>;
}>;
export type LQInputSubArray<Type> = Type extends object
? LQInputObject<Type>
: true;
export type LQInput<Type> = Type extends LdSet<infer ArraySubType>
? LQInputSubArray<ArraySubType>
: LQInputSubArray<Type>;
/**
* Link Query Input Default
*/
export type LQInputDefaultType<Type> = {
[key in keyof Type]: Type[key] extends object ? undefined : true;
};
export type LQInputDefault<Type> =
LQInputDefaultType<Type> extends LQInput<Type>
? LQInputDefaultType<Type>
: never;
/**
* Link Query Return
*/
export type LQReturnObject<Type, Input extends LQInputObject<Type>> = {
[key in keyof Required<Type> as undefined extends Input[key]
? never
: key]: Input[key] extends LQInput<Type[key]>
? undefined extends Type[key]
? LQReturnRecursive<Type[key], Input[key]> | undefined
: LQReturnRecursive<Type[key], Input[key]>
: never;
};
export type LQReturnSubArray<Type, Input> = Input extends LQInputSubArray<Input>
? Type extends object
? LQReturnObject<Type, Input>
: Type
: never;
export type LQReturnRecursive<
Type,
Input extends LQInput<Type>,
> = NonNullable<Type> extends LdSet<infer ArraySubType>
? LdSet<LQReturnSubArray<ArraySubType, Input>>
: LQReturnSubArray<Type, Input>;
export type LQReturn<Type, Input extends LQInput<Type>> = LQReturnRecursive<
Type,
Input
>;
type ExpandDeep<T> = T extends LdSet<infer U>
? LdSet<ExpandDeep<U>> // recursively expand arrays
: T extends object
? { [K in keyof T]: ExpandDeep<T[K]> } // recursively expand objects
: T; // base case (primitive types)
function sampleFunction<Type extends LdoBase, Input extends LQInput<Type>>(
_shapeType: ShapeType<Type>,
_input: Input,
): ExpandDeep<LQReturn<Type, Input>> {
throw new Error("NotImplemented");
}
type other = ExpandDeep<LQInput<SolidProfileShape>>;
const value = sampleFunction(ProfileShapeType, {
hasTelephone: { type: { "@id": true }, value: true },
});
value;

@ -974,7 +974,6 @@ export interface RSAPublicKeyShape {
export interface SolidProfileShape { export interface SolidProfileShape {
"@id"?: string; "@id"?: string;
"@context"?: ContextDefinition;
/** /**
* Defines the node as a Person (from Schema.org) | Defines the node as a Person (from foaf) * Defines the node as a Person (from Schema.org) | Defines the node as a Person (from foaf)
*/ */

Loading…
Cancel
Save