Skip to content

Commit dfac9e2

Browse files
authored
fix(ui): create event from link button (#2157)
1 parent 0e7a271 commit dfac9e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+630
-536
lines changed

lies.exposed.code-workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@
108108
"**/build": true,
109109
},
110110
"typescript.preferences.importModuleSpecifier": "project-relative",
111+
"yaml.maxItemsComputed": 500,
111112
},
112113
}

packages/@liexp/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"pdfjs-dist": "^4",
7979
"puppeteer-core": "^24.1.1",
8080
"puppeteer-extra": "^3.3.6",
81-
"query-string": "^7.1.3",
81+
"query-string": "^9.1.1",
8282
"sharp": "*",
8383
"typeorm": "^0.3.20",
8484
"wink-eng-lite-web-model": "^1.8.0",

packages/@liexp/backend/src/flows/ai/runRagChain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const runRagChain =
3434

3535
let output: any;
3636
for await (const chunk of stream) {
37-
ctx.logger.debug.log("chunk", chunk);
3837
output = chunk;
38+
ctx.logger.debug.log("Add chunk to output total %d", output.length);
3939
}
4040

4141
ctx.logger.info.log("output", output);

packages/@liexp/backend/src/flows/media/createAndUpload.flow.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
PDFType,
88
type MediaType,
99
} from "@liexp/shared/lib/io/http/Media/index.js";
10+
import { type Queue } from "@liexp/shared/lib/io/http/Queue/index.js";
1011
import {
1112
OpenAIEmbeddingQueueType,
1213
PendingStatus,
@@ -119,17 +120,17 @@ export const createAndUpload = <C extends CreateAndUploadFlowContext>(
119120
ctx.queue.queue(OpenAIEmbeddingQueueType.value).addJob({
120121
id: m.id,
121122
resource: MEDIA.value,
122-
type: OpenAIEmbeddingQueueType.value,
123123
status: PendingStatus.value,
124124
error: null,
125125
result: null,
126126
prompt: null,
127127
question: null,
128+
type: OpenAIEmbeddingQueueType.value,
128129
data: {
129130
url: m.location,
130-
type: "pdf",
131+
type: "pdf" as const,
131132
},
132-
}),
133+
} satisfies Queue),
133134
fp.TE.mapLeft(ServerError.fromUnknown),
134135
);
135136
}

packages/@liexp/backend/src/flows/tg/parseURL.flow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
OpenAIEmbeddingQueueType,
77
PendingStatus,
88
} from "@liexp/shared/lib/io/http/Queue/index.js";
9+
import { type Queue } from "@liexp/shared/lib/io/http/Queue/index.js";
910
import * as A from "fp-ts/lib/Array.js";
1011
import * as E from "fp-ts/lib/Either.js";
1112
import * as O from "fp-ts/lib/Option.js";
@@ -97,7 +98,7 @@ export const parseURLs =
9798
url: l.url,
9899
type: "link",
99100
},
100-
}),
101+
} as Queue),
101102
),
102103
TE.mapLeft(ServerError.fromUnknown),
103104
);

packages/@liexp/backend/src/io/group.io.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "@liexp/shared/lib/io/http/Error/DecodeError.js";
66
import { Media } from "@liexp/shared/lib/io/http/Media/Media.js";
77
import * as io from "@liexp/shared/lib/io/index.js";
8+
import { isValidValue } from "@liexp/shared/lib/providers/blocknote/isValidValue.js";
89
import { toInitialValue } from "@liexp/shared/lib/providers/blocknote/utils.js";
910
import { toColor } from "@liexp/shared/lib/utils/colors.js";
1011
import * as E from "fp-ts/lib/Either.js";
@@ -39,8 +40,14 @@ const toGroupIO = (
3940
startDate: group.startDate?.toISOString() ?? undefined,
4041
endDate: group.endDate?.toISOString() ?? undefined,
4142
color: toColor(group.color),
42-
excerpt: toInitialValue(group.excerpt) ?? null,
43-
body: toInitialValue(group.body) ?? null,
43+
excerpt:
44+
group.excerpt && isValidValue(group.excerpt)
45+
? toInitialValue(group.excerpt)
46+
: null,
47+
body:
48+
group.body && isValidValue(group.body)
49+
? toInitialValue(group.body)
50+
: null,
4451
avatar,
4552
members: group.members ? group.members : [],
4653
subGroups: [],

packages/@liexp/backend/src/io/groupMember.io.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
DecodeError,
55
} from "@liexp/shared/lib/io/http/Error/DecodeError.js";
66
import * as io from "@liexp/shared/lib/io/index.js";
7+
import { isValidValue } from "@liexp/shared/lib/providers/blocknote/isValidValue.js";
8+
import { toInitialValue } from "@liexp/shared/lib/providers/blocknote/utils.js";
79
import { sequenceS } from "fp-ts/lib/Apply.js";
810
import * as E from "fp-ts/lib/Either.js";
911
import { type GroupMemberEntity } from "../entities/GroupMember.entity.js";
@@ -24,6 +26,14 @@ const toGroupMemberIO = (
2426
pipe(
2527
io.http.GroupMember.GroupMember.decode({
2628
...groupMember,
29+
excerpt:
30+
groupMember.excerpt && isValidValue(groupMember.excerpt)
31+
? toInitialValue(groupMember.excerpt)
32+
: null,
33+
body:
34+
groupMember.body && isValidValue(groupMember.body)
35+
? toInitialValue(groupMember.body)
36+
: null,
2737
actor: io.http.Actor.Actor.encode(actor),
2838
group: io.http.Group.Group.encode(group),
2939
startDate: (groupMember.startDate ?? new Date()).toISOString(),

packages/@liexp/backend/src/io/media.io.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const toMediaIO = (
2929
return pipe(
3030
io.http.Media.AdminMedia.decode({
3131
...media,
32-
label: media.label ?? undefined,
32+
label: media.label ?? media.location,
3333
description: media.description ?? undefined,
3434
location: ensureHTTPS(media.location),
3535
creator: media.creator ?? undefined,

packages/@liexp/backend/src/providers/space/space.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { type Endpoint } from "@aws-sdk/types";
2222
import * as logger from "@liexp/core/lib/logger/index.js";
2323
import * as TE from "fp-ts/lib/TaskEither.js";
2424
import { pipe } from "fp-ts/lib/function.js";
25-
import * as qs from "query-string";
25+
import qs from "query-string";
2626
import { IOError } from "ts-io-error";
2727

2828
const s3Logger = logger.GetLogger("space");

packages/@liexp/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"peerDependencies": {
4949
"debug": "*",
5050
"dotenv": "^16.4.7",
51-
"query-string": "^7",
5251
"vite": "^6",
5352
"vite-plugin-css-injected-by-js": "^3",
5453
"vite-plugin-optimizer": "^1",

packages/@liexp/core/src/frontend/vite/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export const defineViteConfig = <A extends Record<string, any>>(
137137
port: config.port,
138138
host: config.host,
139139
hmr: config.hot,
140+
allowedHosts: ["*.liexp.dev", "liexp.dev"],
140141
}
141142
: undefined,
142143
ssr: {

packages/@liexp/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"io-ts-types": "^0.5.19",
3838
"lodash": "^4.17.21",
3939
"page-metadata-parser": "^1.1.4",
40-
"query-string": "^7.1.3",
40+
"query-string": "^9.1.1",
4141
"ts-endpoint": "^2.0.0",
4242
"ts-io-error": "^2.0.0",
4343
"typelevel-ts": "^0.4.0",

packages/@liexp/shared/src/endpoints/events/event.endpoints.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ export const Create = Endpoint({
4949
Output: SingleEventOutput,
5050
});
5151

52-
export const CreateFromLink = Endpoint({
53-
Method: "POST",
54-
getPath: () => `/events/from-link`,
55-
Input: {
56-
Body: t.strict({
57-
url: t.string,
58-
}),
59-
},
60-
Output: SingleEventOutput,
61-
});
62-
6352
export const CreateSuggestion = Endpoint({
6453
Method: "POST",
6554
getPath: () => `/events/suggestions`,
@@ -213,7 +202,6 @@ const events = ResourceEndpoints({
213202
Edit,
214203
Delete,
215204
Custom: {
216-
CreateFromLink,
217205
CreateSuggestion,
218206
EditSuggestion,
219207
DeleteSuggestion,

packages/@liexp/shared/src/io/http/Events/index.ts

Lines changed: 87 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,83 @@ export const EventMap: { [key in Event["type"]]: t.Mixed } = {
4343
Quote: Quote.Quote,
4444
};
4545

46-
export const EventFromURLBody = t.strict(
47-
{
48-
url: URL,
49-
type: EventType,
50-
},
46+
export const EventPayload = t.union(
47+
[
48+
Book.BookPayload,
49+
Death.DeathPayload,
50+
Patent.PatentPayload,
51+
ScientificStudy.ScientificStudyPayload,
52+
Uncategorized.UncategorizedV2Payload,
53+
Documentary.DocumentaryPayload,
54+
Transaction.TransactionPayload,
55+
Quote.QuotePayload,
56+
],
57+
"EventPayload",
58+
);
59+
60+
export type EventPayload = t.TypeOf<typeof EventPayload>;
61+
62+
export const EventFromURLBody = t.intersection(
63+
[
64+
t.strict({
65+
url: URL,
66+
}),
67+
t.union(
68+
[
69+
t.strict({ type: EventTypes.BOOK, payload: Book.BookPayload }),
70+
t.strict(
71+
{
72+
type: EventTypes.DEATH,
73+
payload: Death.DeathPayload,
74+
},
75+
"DeathTypePayload",
76+
),
77+
t.strict(
78+
{
79+
type: EventTypes.PATENT,
80+
payload: Patent.PatentPayload,
81+
},
82+
"PatentTypePayload",
83+
),
84+
t.strict(
85+
{
86+
type: EventTypes.SCIENTIFIC_STUDY,
87+
payload: ScientificStudy.ScientificStudyPayload,
88+
},
89+
"ScientificStudyTypePayload",
90+
),
91+
t.strict(
92+
{
93+
type: EventTypes.UNCATEGORIZED,
94+
payload: Uncategorized.UncategorizedV2Payload,
95+
},
96+
"UncategorizedTypePayload",
97+
),
98+
t.strict(
99+
{
100+
type: EventTypes.DOCUMENTARY,
101+
payload: Documentary.DocumentaryPayload,
102+
},
103+
"DocumentaryTypePayload",
104+
),
105+
t.strict(
106+
{
107+
type: EventTypes.TRANSACTION,
108+
payload: Transaction.TransactionPayload,
109+
},
110+
"TransactionTypePayload",
111+
),
112+
t.strict(
113+
{
114+
type: EventTypes.QUOTE,
115+
payload: Quote.QuotePayload,
116+
},
117+
"QuoteTypwPayload",
118+
),
119+
],
120+
"EventTypePayload",
121+
),
122+
],
51123
"EventFromURLBody",
52124
);
53125

@@ -91,21 +163,6 @@ export const EditEventBody = t.union(
91163

92164
export type EditEventBody = t.TypeOf<typeof EditEventBody>;
93165

94-
export const EventPayload = t.union(
95-
[
96-
Book.BookPayload,
97-
Death.DeathPayload,
98-
Patent.PatentPayload,
99-
ScientificStudy.ScientificStudyPayload,
100-
Uncategorized.UncategorizedV2Payload,
101-
Documentary.DocumentaryPayload,
102-
Transaction.TransactionPayload,
103-
],
104-
"EventPayload",
105-
);
106-
107-
export type EventPayload = t.TypeOf<typeof EventPayload>;
108-
109166
export const Event = t.union(
110167
[
111168
Book.Book,
@@ -146,22 +203,22 @@ interface EventRelations {
146203
}
147204

148205
export {
206+
Arrest,
207+
Book,
208+
Death,
209+
Documentary,
210+
EVENTS,
149211
EventType,
150212
EventTypes,
151-
Protest,
152213
Fined,
153-
Book,
154-
Arrest,
155-
PublicAnnouncement,
156-
Death,
157-
ScientificStudy,
158-
Uncategorized,
159214
Patent,
160-
Documentary,
161-
Transaction,
215+
Protest,
216+
PublicAnnouncement,
162217
Quote,
218+
ScientificStudy,
163219
SearchEvent,
164-
EVENTS,
220+
Transaction,
221+
Uncategorized,
165222
type EventRelationIds,
166223
type EventRelations,
167224
};

packages/@liexp/shared/src/io/http/Queue/CreateEventFromTextQueueData.ts renamed to packages/@liexp/shared/src/io/http/Queue/event/CreateEventFromTextQueueData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as t from "io-ts";
2-
import { EventType } from "../Events/EventType.js";
2+
import { EventType } from "../../Events/EventType.js";
33

44
export const OpenAICreateEventFromTextType = t.literal(
55
"openai-create-event-from-text",
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as t from "io-ts";
2-
import { URL } from "../Common/URL.js";
3-
import { EventType } from "../Events/index.js";
2+
import { EventFromURLBody } from "../../Events/index.js";
43

54
export const OpenAICreateEventFromURLType = t.literal(
65
"openai-create-event-from-url",
@@ -9,13 +8,8 @@ export type OpenAICreateEventFromURLType = t.TypeOf<
98
typeof OpenAICreateEventFromURLType
109
>;
1110

12-
export const CreateEventFromURLQueueData = t.strict(
13-
{
14-
url: URL,
15-
type: EventType,
16-
},
17-
"CreateEventFromURLQueueData",
18-
);
11+
export const CreateEventFromURLQueueData = EventFromURLBody;
12+
1913
export type CreateEventFromURLQueueData = t.TypeOf<
2014
typeof CreateEventFromURLQueueData
2115
>;

0 commit comments

Comments
 (0)