Skip to content

Commit 6a9b6b1

Browse files
committed
ESM management. Tests run now.
1 parent 1235e25 commit 6a9b6b1

11 files changed

Lines changed: 680 additions & 468 deletions

File tree

chats/ldo/package-lock.json

Lines changed: 586 additions & 436 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chats/ldo/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@
3232
"build:ldo": "ldo build --input src/.shapes --output src/.ldo"
3333
},
3434
"devDependencies": {
35-
"@ldo/cli": "^1.0.0-alpha.15",
36-
"@ldo/test-solid-server": "^1.0.0-alpha.14",
35+
"@ldo/cli": "^1.0.0-alpha.21",
36+
"@ldo/test-solid-server": "^1.0.0-alpha.24",
3737
"@types/jsonld": "^1.5.15",
3838
"@types/node": "^22.15.21",
3939
"@types/shexj": "^2.1.7",
4040
"rimraf": "^6.0.1",
4141
"vitest": "^3.1.4"
4242
},
4343
"dependencies": {
44-
"@ldo/connected": "^1.0.0-alpha.18",
45-
"@ldo/connected-solid": "^1.0.0-alpha.18",
46-
"@ldo/ldo": "^1.0.0-alpha.14",
44+
"@ldo/connected": "^1.0.0-alpha.24",
45+
"@ldo/connected-solid": "^1.0.0-alpha.24",
46+
"@ldo/ldo": "^1.0.0-alpha.21",
4747
"uuid": "^11.1.0"
4848
}
49-
}
49+
}

chats/ldo/src/.ldo/longChat.shapeTypes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { ShapeType } from "@ldo/ldo";
2-
import { longChatSchema } from "./longChat.schema";
3-
import { longChatContext } from "./longChat.context";
2+
import { longChatSchema } from "./longChat.schema.js";
3+
import { longChatContext } from "./longChat.context.js";
44
import {
55
ChatShape,
66
ChatParticipationShape,
77
ChatMessageListShape,
88
ChatMessageShape,
9-
} from "./longChat.typings";
9+
} from "./longChat.typings.js";
1010

1111
/**
1212
* =============================================================================
@@ -27,11 +27,11 @@ export const ChatShapeShapeType: ShapeType<ChatShape> = {
2727
* ChatParticipationShape ShapeType
2828
*/
2929
export const ChatParticipationShapeShapeType: ShapeType<ChatParticipationShape> =
30-
{
31-
schema: longChatSchema,
32-
shape: "https://shaperepo.com/schemas/longChat#ChatParticipationShape",
33-
context: longChatContext,
34-
};
30+
{
31+
schema: longChatSchema,
32+
shape: "https://shaperepo.com/schemas/longChat#ChatParticipationShape",
33+
context: longChatContext,
34+
};
3535

3636
/**
3737
* ChatMessageListShape ShapeType

chats/ldo/src/Chat.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { ConnectedLdoDataset } from "@ldo/connected";
22
import { SolidConnectedPlugin, SolidContainer, SolidContainerUri, SolidLeaf, SolidLeafUri, SolidResource } from "@ldo/connected-solid";
3-
import { ChatMessageShape, ChatShape } from "./.ldo/longChat.typings";
4-
import { scheduleNewDayTrigger } from "./util/scheduleNewDayTrigger";
5-
import { ChatMessageListShapeShapeType, ChatMessageShapeShapeType, ChatShapeShapeType } from "./.ldo/longChat.shapeTypes";
6-
import { getResource, throwIfErr } from "./util/resultHelpers";
3+
import { ChatMessageShape, ChatShape } from "./.ldo/longChat.typings.js";
4+
import { scheduleNewDayTrigger } from "./util/scheduleNewDayTrigger.js";
5+
import { ChatMessageListShapeShapeType, ChatMessageShapeShapeType, ChatShapeShapeType } from "./.ldo/longChat.shapeTypes.js";
6+
import { getResource, throwIfErr } from "./util/resultHelpers.js";
77
import { v4 } from "uuid";
8-
import { namedNode } from "@rdfjs/data-model";
9-
8+
import { namedNode } from "@ldo/rdf-utils";
109
export class Chat {
1110
public readonly containerResource: SolidContainer;
1211
public readonly chatResource: SolidLeaf;
@@ -310,6 +309,7 @@ export class Chat {
310309
const self = this;
311310

312311
async function* messageGenerator(): AsyncGenerator<ChatMessageShape[]> {
312+
await self.ensureTodaysMessageResource();
313313
let currentResource: SolidLeaf | undefined = self.todaysMessageResource;
314314

315315
while (currentResource) {

chats/ldo/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./Chat";
1+
export * from "./Chat.js";

chats/ldo/src/util/resultHelpers.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { ConnectedResult, SuccessResult } from "@ldo/connected";
2-
31
type NonError<T> = T extends { isError: true } ? never : T;
42

53
export function throwIfErr<Results extends { isError: boolean }>(

chats/ldo/test/configs/template/base/sample-chats/2023/11/25/chat.ttl renamed to chats/ldo/test/configs/template/base/sample-chat-1/2023/11/25/chat.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@prefix sioc: <http://rdfs.org/sioc/ns#>.
55
@prefix wf: <http://www.w3.org/2005/01/wf/flow#>.
66
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
7-
@prefix c: </profile/card#>.
7+
@prefix c: <http://example.com/profile/card#>.
88
@prefix terms: <https://liqid.chat/terms/>.
99
@prefix in: <../../../index.ttl#>.
1010

chats/ldo/test/configs/template/base/sample-chats/2024/11/27/chat.ttl renamed to chats/ldo/test/configs/template/base/sample-chat-1/2024/11/27/chat.ttl

File renamed without changes.

chats/ldo/test/configs/template/base/sample-chats/index.ttl renamed to chats/ldo/test/configs/template/base/sample-chat-1/index.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@prefix meeting: <http://www.w3.org/ns/pim/meeting#>.
44
@prefix ui: <http://www.w3.org/ns/ui#>.
55
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
6-
@prefix c: </profile/card#>.
6+
@prefix c: <http://example.com/profile/card#>.
77
@prefix terms: <https://liqid.chat/terms/>.
88

99
:this

chats/ldo/test/integration.test.ts

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,63 @@
1-
import { describe, it, expect } from "vitest";
1+
import { describe, it, expect, beforeEach } from "vitest";
22
import { setupServer } from "@ldo/test-solid-server";
33
import { testFiles } from "./testFiles.helper";
44
import path from "path";
55
import { fileURLToPath } from "url";
6+
import { ConnectedLdoDataset, createConnectedLdoDataset } from "@ldo/connected";
7+
import { solidConnectedPlugin, SolidConnectedPlugin } from "@ldo/connected-solid";
8+
import { Chat } from "../src";
9+
import { ChatMessageShape, ChatShape } from "../src/.ldo/longChat.typings";
610

711
const __filename = fileURLToPath(import.meta.url);
812
const __dirname = path.dirname(__filename);
913

14+
const BASE_URI = "http://localhost:3003/example/";
15+
const SAMPLE_CHAT_1_CONTAINER_URI = `${BASE_URI}sample-chat-1/`;
16+
const SAMPLE_CHAT_1_INDEX_URI = `${SAMPLE_CHAT_1_CONTAINER_URI}index.ttl`;
17+
const SAMPLE_CHAT_1_INDEX_INFO: ChatShape = {
18+
"@id": `${SAMPLE_CHAT_1_INDEX_URI}#this`,
19+
"type": { "@id": "LongChat" },
20+
author: { "@id": "http://example.com/profile/card#me" },
21+
created: "2023-11-25T20:58:21.266Z",
22+
title: "Scatterverse "
23+
}
24+
const SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI = `${SAMPLE_CHAT_1_CONTAINER_URI}2023/11/25/index.ttl`;
25+
const SAMPLE_CHAT_1_MESSAGE_RESOURCE_1__MESSAGES: ChatMessageShape[] = [
26+
{
27+
"@id": `${SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI}#6def4609-3a97-44a7-ac5f-7cb8d2c5d2e0`,
28+
created2: "2023-11-25T20:58:26.606Z",
29+
content: 'thmooove created "Scatterverse "',
30+
maker: { "@id": "http://example.com/profile/card#me" }
31+
},
32+
{
33+
"@id": `${SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI}#bf343557-915b-4302-8377-d6e98d0963fc`,
34+
created2: "2023-11-25T21:34:17.354Z",
35+
content: "If youre reading this, ily ",
36+
maker: { "@id": "http://example.com/profile/card#me" }
37+
},
38+
{
39+
"@id": `${SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI}#c22cf637-7a5e-4c1f-b83d-74eeb6638657`,
40+
created2: "2023-11-25T20:59:49.014Z",
41+
content: "How many people actively use this?",
42+
maker: { "@id": "http://example.com/profile/card#me" }
43+
},
44+
{
45+
"@id": `${SAMPLE_CHAT_1_MESSAGE_RESOURCE_1_URI}#cb1a3293-d890-4d16-b462-ee60fceb3bc2`,
46+
created2: "2023-11-25T20:58:43.163Z",
47+
content: "this is pretty clean ",
48+
maker: { "@id": "http://example.com/profile/card#me" }
49+
}
50+
]
51+
const SAMPLE_CHAT_1_MESSAGE_RESOURCE_2_URI = `${SAMPLE_CHAT_1_CONTAINER_URI}2024/11/27/index.ttl`;
52+
const SAMPLE_CHAT_1_MESSAGE_RESOURCE_2_MESSAGES = [
53+
{
54+
"@id": `${SAMPLE_CHAT_1_MESSAGE_RESOURCE_2_URI}#d4d513fa-23e0-4726-89aa-f5e433bb6c58`,
55+
created2: "2024-11-07T08:52:38.447Z",
56+
content: "Hi",
57+
maker: { "@id": "https://juliusisnya.solidcommunity.net/profile/card#me" }
58+
}
59+
]
60+
1061
describe("integration", () => {
1162
const s = setupServer(
1263
3003,
@@ -18,7 +69,19 @@ describe("integration", () => {
1869
true
1970
);
2071

21-
it("trivial", () => {
22-
expect(true).toBe(true);
72+
let dataset: ConnectedLdoDataset<SolidConnectedPlugin[]>;
73+
let sample1Chat: Chat;
74+
75+
beforeEach(() => {
76+
dataset = createConnectedLdoDataset([solidConnectedPlugin]);
77+
sample1Chat = new Chat(SAMPLE_CHAT_1_CONTAINER_URI, dataset);
78+
})
79+
80+
it("Fetches chat information", async () => {
81+
const chatInfo = await sample1Chat.getChatInfo();
82+
expect(chatInfo["@id"]).toBe(SAMPLE_CHAT_1_INDEX_INFO["@id"]);
83+
expect(chatInfo.author).toBe(SAMPLE_CHAT_1_INDEX_INFO.author);
84+
expect(chatInfo.created).toBe(SAMPLE_CHAT_1_INDEX_INFO.created);
85+
expect(chatInfo.title).toBe(SAMPLE_CHAT_1_INDEX_INFO.title);
2386
});
2487
});

0 commit comments

Comments
 (0)