Skip to content

Commit

Permalink
Test uses lib api instead of raw queries
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ar committed Nov 28, 2023
1 parent e72d5d8 commit 8d3cfc3
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 157 deletions.
3 changes: 2 additions & 1 deletion scripts/populate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from "../template-data/templateData.js";

import untypedTemplateData from "../template-data/template_data.json" assert { type: "json" };
import { RuntimeCompositeDefinition } from "@composedb/types";

const templateData: DataTemplate = untypedTemplateData;

Expand All @@ -58,7 +59,7 @@ type ProfileIndexResult = { profileIndex: { edges: [] } };
export const loadIfUninitialised = async (ceramic: CeramicClient) => {
const composeClient = new ComposeClient({
ceramic,
definition,
definition: definition as RuntimeCompositeDefinition,
});
const firstProfile = await composeClient.executeQuery<ProfileIndexResult>(`
query {
Expand Down
2 changes: 1 addition & 1 deletion src/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const loadVersionIndex = async (
): Promise<Stream> => {
const stream = await client.loadStream(id);
const log = getVersionLog(stream);
if (index < 0 || index >= length) {
if (index < 0 || index >= log.length) {
throw new RangeError(
`Index not within the known ${log.length} stream states`,
);
Expand Down
18 changes: 16 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export type ResearchComponent = {

metadata?: string; // CID
};
export type ResearchComponentStatic = "researchObjectID";
export type ResearchComponentUpdate = Omit<
ResearchComponent,
ResearchComponentStatic
>;

export type Claim = {
title: string;
Expand All @@ -53,7 +58,7 @@ export type AttestationUpdate = Omit<Attestation, AttestationStatic | "claim">;
* The full range of model fields on the Annotation, unexported
* because not all combinations make sense. See subtypes below.
*/
type AnnotationFull = {
export type AnnotationFull = {
comment?: string;

researchObjectID: string;
Expand Down Expand Up @@ -110,7 +115,10 @@ export type Annotation =
export type AnnotationStatic = "researchObjectID" | "claimID" | "targetID";

/** Any `Annotation` instance, but excluding static fields. */
export type AnnotationUpdate = DistributiveOmit<Annotation, AnnotationStatic>;
export type AnnotationUpdate = DistributiveOmit<
Annotation,
AnnotationStatic | "claim"
>;

export type ContributorRelation = {
role: string;
Expand All @@ -123,6 +131,9 @@ export type ContributorRelation = {
revoked: boolean;
};

export type ContributorStatic = "researchObjectID" | "contributorID";
export type ContributorUpdate = Omit<ContributorRelation, ContributorStatic>;

export type ReferenceRelation = {
toID: string;
toVersion: string;
Expand All @@ -133,6 +144,9 @@ export type ReferenceRelation = {
revoked: boolean;
};

export type ReferenceStatic = "toID" | "fromID";
export type ReferenceUpdate = Omit<ReferenceRelation, ReferenceStatic>;

export type ResearchField = {
title: string;
};
Expand Down
Loading

0 comments on commit 8d3cfc3

Please sign in to comment.