@carlonicora/nextjs-jsonapi 1.79.0 → 1.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/{AssistantMessageInterface-DWnbd6J7.d.ts → AssistantMessageInterface-BpEhx2pC.d.ts} +18 -1
  2. package/dist/{AssistantMessageInterface-Mla6kgPe.d.mts → AssistantMessageInterface-DJ3Me16Y.d.mts} +18 -1
  3. package/dist/{BlockNoteEditor-6CBDTVKV.mjs → BlockNoteEditor-3M5PD3BZ.mjs} +4 -4
  4. package/dist/{BlockNoteEditor-EH4HWI7H.js → BlockNoteEditor-YLTPJPTV.js} +14 -14
  5. package/dist/{BlockNoteEditor-EH4HWI7H.js.map → BlockNoteEditor-YLTPJPTV.js.map} +1 -1
  6. package/dist/billing/index.js +346 -346
  7. package/dist/billing/index.mjs +3 -3
  8. package/dist/{chunk-ZDP3MBUI.js → chunk-4NOQNTFI.js} +1151 -740
  9. package/dist/chunk-4NOQNTFI.js.map +1 -0
  10. package/dist/{chunk-BKM5U3DE.mjs → chunk-6UMB5LTQ.mjs} +98 -7
  11. package/dist/chunk-6UMB5LTQ.mjs.map +1 -0
  12. package/dist/{chunk-5IEWLLLD.js → chunk-N4YZ45SK.js} +115 -24
  13. package/dist/chunk-N4YZ45SK.js.map +1 -0
  14. package/dist/{chunk-ENRSFVOS.mjs → chunk-NQV5RDCK.mjs} +1112 -701
  15. package/dist/chunk-NQV5RDCK.mjs.map +1 -0
  16. package/dist/{chunk-MEWXQEVE.mjs → chunk-PV5V6CVW.mjs} +2 -2
  17. package/dist/{chunk-TWDSDTHU.js → chunk-ZEJSPTHS.js} +7 -7
  18. package/dist/{chunk-TWDSDTHU.js.map → chunk-ZEJSPTHS.js.map} +1 -1
  19. package/dist/client/index.js +4 -4
  20. package/dist/client/index.mjs +3 -3
  21. package/dist/components/index.d.mts +25 -7
  22. package/dist/components/index.d.ts +25 -7
  23. package/dist/components/index.js +6 -4
  24. package/dist/components/index.js.map +1 -1
  25. package/dist/components/index.mjs +5 -3
  26. package/dist/contexts/index.d.mts +1 -1
  27. package/dist/contexts/index.d.ts +1 -1
  28. package/dist/contexts/index.js +4 -4
  29. package/dist/contexts/index.mjs +3 -3
  30. package/dist/core/index.d.mts +35 -3
  31. package/dist/core/index.d.ts +35 -3
  32. package/dist/core/index.js +6 -2
  33. package/dist/core/index.js.map +1 -1
  34. package/dist/core/index.mjs +5 -1
  35. package/dist/index.d.mts +2 -2
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.js +7 -3
  38. package/dist/index.js.map +1 -1
  39. package/dist/index.mjs +6 -2
  40. package/dist/server/index.js +3 -3
  41. package/dist/server/index.mjs +1 -1
  42. package/package.json +1 -1
  43. package/src/core/index.ts +2 -0
  44. package/src/core/registry/ModuleRegistry.ts +1 -0
  45. package/src/features/assistant/components/parts/AssistantThread.tsx +1 -1
  46. package/src/features/assistant-message/AssistantMessageModule.ts +4 -0
  47. package/src/features/assistant-message/components/MessageItem.tsx +7 -7
  48. package/src/features/assistant-message/components/MessageList.tsx +1 -1
  49. package/src/features/assistant-message/components/__tests__/MessageItem.spec.tsx +11 -7
  50. package/src/features/assistant-message/components/index.ts +1 -0
  51. package/src/features/assistant-message/components/parts/MessageSourcesContainer.tsx +135 -0
  52. package/src/features/assistant-message/components/parts/MessageSourcesPanel.tsx +151 -0
  53. package/src/features/assistant-message/components/parts/RelevanceMeter.tsx +29 -0
  54. package/src/features/assistant-message/components/parts/__tests__/MessageSourcesPanel.spec.tsx +70 -0
  55. package/src/features/assistant-message/components/parts/tabs/CitationsTab.tsx +105 -0
  56. package/src/features/assistant-message/components/parts/tabs/ContentsTab.tsx +88 -0
  57. package/src/features/assistant-message/components/parts/tabs/ReferencesTab.tsx +51 -0
  58. package/src/features/assistant-message/components/parts/tabs/SuggestedQuestionsTab.tsx +24 -0
  59. package/src/features/assistant-message/components/parts/tabs/UsersTab.tsx +142 -0
  60. package/src/features/assistant-message/data/AssistantMessage.ts +20 -0
  61. package/src/features/assistant-message/data/AssistantMessageInterface.ts +2 -0
  62. package/src/features/assistant-message/data/AssistantMessageService.ts +13 -4
  63. package/src/features/assistant-message/data/__tests__/AssistantMessage.citations.spec.ts +65 -0
  64. package/src/features/assistant-message/data/__tests__/AssistantMessage.spec.ts +8 -0
  65. package/src/features/chunk/ChunkModule.ts +18 -0
  66. package/src/features/chunk/data/Chunk.ts +49 -0
  67. package/src/features/chunk/data/ChunkInput.ts +3 -0
  68. package/src/features/chunk/data/ChunkInterface.ts +18 -0
  69. package/src/features/chunk/data/__tests__/Chunk.spec.ts +83 -0
  70. package/src/features/chunk/data/index.ts +3 -0
  71. package/src/features/chunk/index.ts +2 -0
  72. package/dist/chunk-5IEWLLLD.js.map +0 -1
  73. package/dist/chunk-BKM5U3DE.mjs.map +0 -1
  74. package/dist/chunk-ENRSFVOS.mjs.map +0 -1
  75. package/dist/chunk-ZDP3MBUI.js.map +0 -1
  76. package/src/features/assistant-message/components/parts/ReferenceBadges.tsx +0 -46
  77. package/src/features/assistant-message/components/parts/SuggestedFollowUps.tsx +0 -52
  78. package/src/features/assistant-message/components/parts/__tests__/ReferenceBadges.spec.tsx +0 -59
  79. package/src/features/assistant-message/components/parts/__tests__/SuggestedFollowUps.spec.tsx +0 -29
  80. /package/dist/{BlockNoteEditor-6CBDTVKV.mjs.map → BlockNoteEditor-3M5PD3BZ.mjs.map} +0 -0
  81. /package/dist/{chunk-MEWXQEVE.mjs.map → chunk-PV5V6CVW.mjs.map} +0 -0
@@ -0,0 +1,18 @@
1
+ import { ApiDataInterface } from "../../../core";
2
+
3
+ /**
4
+ * Edge properties on the (:AssistantMessage)-[:CITES]->(:Chunk) relationship.
5
+ * Surfaced via _readIncludedWithMeta on AssistantMessage.citations.
6
+ */
7
+ export interface ChunkRelationshipMeta {
8
+ relevance: number;
9
+ reason?: string;
10
+ }
11
+
12
+ export interface ChunkInterface extends ApiDataInterface {
13
+ get content(): string;
14
+ get nodeId(): string | undefined;
15
+ get nodeType(): string | undefined;
16
+ get imagePath(): string | undefined;
17
+ get source(): ApiDataInterface | undefined;
18
+ }
@@ -0,0 +1,83 @@
1
+ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
2
+ import { AbstractApiData } from "../../../../core/abstracts/AbstractApiData";
3
+ import { DataClassRegistry } from "../../../../core/registry/DataClassRegistry";
4
+ import { JsonApiHydratedDataInterface } from "../../../../core/interfaces/JsonApiHydratedDataInterface";
5
+ import { ApiRequestDataTypeInterface } from "../../../../core/interfaces/ApiRequestDataTypeInterface";
6
+ import { Chunk } from "../Chunk";
7
+ import { resolveReferenceableModules } from "../../../assistant/utils/resolveReferenceableModules";
8
+
9
+ vi.mock("../../../assistant/utils/resolveReferenceableModules", () => ({
10
+ resolveReferenceableModules: vi.fn(() => []),
11
+ }));
12
+
13
+ // Minimal AbstractApiData-derived class so RehydrationFactory can `new` it
14
+ // and call `instance.rehydrate(data)`.
15
+ class TestDocument extends AbstractApiData {
16
+ static identifierFields: string[] = ["name"];
17
+
18
+ rehydrate(data: JsonApiHydratedDataInterface): this {
19
+ super.rehydrate(data);
20
+ return this;
21
+ }
22
+
23
+ createJsonApi(_data?: any): any {
24
+ return {};
25
+ }
26
+ }
27
+
28
+ const testDocumentModule: ApiRequestDataTypeInterface = {
29
+ name: "documents",
30
+ model: TestDocument,
31
+ } as any;
32
+
33
+ beforeAll(() => {
34
+ DataClassRegistry.clear();
35
+ DataClassRegistry.registerObjectClass(testDocumentModule, TestDocument);
36
+ });
37
+
38
+ afterAll(() => {
39
+ DataClassRegistry.clear();
40
+ });
41
+
42
+ describe("Chunk model", () => {
43
+ it("rehydrates content, nodeId, nodeType from attributes", () => {
44
+ const chunk = new Chunk();
45
+ chunk.rehydrate({
46
+ jsonApi: {
47
+ id: "c1",
48
+ type: "chunks",
49
+ attributes: { content: "hello", nodeId: "doc-1", nodeType: "documents" },
50
+ } as any,
51
+ included: [],
52
+ });
53
+ expect(chunk.content).toBe("hello");
54
+ expect(chunk.nodeId).toBe("doc-1");
55
+ expect(chunk.nodeType).toBe("documents");
56
+ });
57
+
58
+ it("resolves the source relationship polymorphically when matching module is registered", () => {
59
+ (resolveReferenceableModules as any).mockReturnValue([testDocumentModule]);
60
+
61
+ const chunk = new Chunk();
62
+ chunk.rehydrate({
63
+ jsonApi: {
64
+ id: "c1",
65
+ type: "chunks",
66
+ attributes: { content: "hello" },
67
+ relationships: { source: { data: { type: "documents", id: "doc-1" } } },
68
+ } as any,
69
+ included: [{ id: "doc-1", type: "documents", attributes: { name: "Manual v1" } }],
70
+ });
71
+ expect(chunk.source).toBeDefined();
72
+ expect((chunk.source as any).type).toBe("documents");
73
+ });
74
+
75
+ it("returns undefined source when relationship is absent", () => {
76
+ const chunk = new Chunk();
77
+ chunk.rehydrate({
78
+ jsonApi: { id: "c1", type: "chunks", attributes: { content: "x" } } as any,
79
+ included: [],
80
+ });
81
+ expect(chunk.source).toBeUndefined();
82
+ });
83
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./Chunk";
2
+ export * from "./ChunkInterface";
3
+ export * from "./ChunkInput";
@@ -0,0 +1,2 @@
1
+ export * from "./ChunkModule";
2
+ export * from "./data";