@carlonicora/nextjs-jsonapi 1.78.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 (128) hide show
  1. package/dist/{AssistantMessageInterface-DS_tyJTV.d.ts → AssistantMessageInterface-BpEhx2pC.d.ts} +19 -2
  2. package/dist/{AssistantMessageInterface-D0Kwf8CR.d.mts → AssistantMessageInterface-DJ3Me16Y.d.mts} +19 -2
  3. package/dist/{AuthComponent-Blbs06ud.d.ts → AuthComponent-B6DIk8Vf.d.ts} +1 -1
  4. package/dist/{AuthComponent-huIaK5rm.d.mts → AuthComponent-BKI0ZbtD.d.mts} +1 -1
  5. package/dist/{BlockNoteEditor-JXK3JGKJ.mjs → BlockNoteEditor-3M5PD3BZ.mjs} +4 -4
  6. package/dist/{BlockNoteEditor-2G5UYALC.js → BlockNoteEditor-YLTPJPTV.js} +14 -14
  7. package/dist/{BlockNoteEditor-2G5UYALC.js.map → BlockNoteEditor-YLTPJPTV.js.map} +1 -1
  8. package/dist/RbacTypes-BTbr27Ew.d.mts +43 -0
  9. package/dist/RbacTypes-BTbr27Ew.d.ts +43 -0
  10. package/dist/{auth.interface-CQJ6A2Cj.d.ts → auth.interface-BBUgMZzs.d.ts} +1 -1
  11. package/dist/{auth.interface-Bdq7-8iV.d.mts → auth.interface-XYEREOD6.d.mts} +1 -1
  12. package/dist/billing/index.js +346 -346
  13. package/dist/billing/index.mjs +3 -3
  14. package/dist/{chunk-ZEDB6JVB.js → chunk-4NOQNTFI.js} +1585 -1405
  15. package/dist/chunk-4NOQNTFI.js.map +1 -0
  16. package/dist/{chunk-I65SSQ5Z.mjs → chunk-6UMB5LTQ.mjs} +157 -7
  17. package/dist/chunk-6UMB5LTQ.mjs.map +1 -0
  18. package/dist/{chunk-FDJQRIMY.js → chunk-N4YZ45SK.js} +174 -24
  19. package/dist/chunk-N4YZ45SK.js.map +1 -0
  20. package/dist/{chunk-NB6TIKHK.mjs → chunk-NQV5RDCK.mjs} +2524 -2344
  21. package/dist/chunk-NQV5RDCK.mjs.map +1 -0
  22. package/dist/{chunk-NZOUEN67.mjs → chunk-PV5V6CVW.mjs} +38 -29
  23. package/dist/{chunk-NZOUEN67.mjs.map → chunk-PV5V6CVW.mjs.map} +1 -1
  24. package/dist/{chunk-X4YDETTD.js → chunk-ZEJSPTHS.js} +39 -30
  25. package/dist/chunk-ZEJSPTHS.js.map +1 -0
  26. package/dist/client/index.d.mts +6 -24
  27. package/dist/client/index.d.ts +6 -24
  28. package/dist/client/index.js +4 -10
  29. package/dist/client/index.js.map +1 -1
  30. package/dist/client/index.mjs +3 -9
  31. package/dist/components/index.d.mts +55 -39
  32. package/dist/components/index.d.ts +55 -39
  33. package/dist/components/index.js +4 -8
  34. package/dist/components/index.js.map +1 -1
  35. package/dist/components/index.mjs +5 -9
  36. package/dist/{config-B3jKt9P7.d.ts → config-B5oBQVEA.d.ts} +1 -1
  37. package/dist/{config-DkHF61xA.d.mts → config-Bx_uh22h.d.mts} +1 -1
  38. package/dist/contexts/index.d.mts +41 -4
  39. package/dist/contexts/index.d.ts +41 -4
  40. package/dist/contexts/index.js +8 -4
  41. package/dist/contexts/index.js.map +1 -1
  42. package/dist/contexts/index.mjs +7 -3
  43. package/dist/core/index.d.mts +51 -11
  44. package/dist/core/index.d.ts +51 -11
  45. package/dist/core/index.js +8 -2
  46. package/dist/core/index.js.map +1 -1
  47. package/dist/core/index.mjs +7 -1
  48. package/dist/index.d.mts +117 -20
  49. package/dist/index.d.ts +117 -20
  50. package/dist/index.js +11 -3
  51. package/dist/index.js.map +1 -1
  52. package/dist/index.mjs +10 -2
  53. package/dist/{notification.interface-DG6obXUH.d.mts → notification.interface-DLZGtV7Z.d.mts} +1 -1
  54. package/dist/{notification.interface-DcSuc9CL.d.ts → notification.interface-aLEJbA_g.d.ts} +1 -1
  55. package/dist/{s3.service-DGilbikH.d.mts → s3.service-CVgLWaDc.d.mts} +2 -2
  56. package/dist/{s3.service-DjwEQJPe.d.ts → s3.service-SLlX0Zbz.d.ts} +2 -2
  57. package/dist/server/index.d.mts +3 -3
  58. package/dist/server/index.d.ts +3 -3
  59. package/dist/server/index.js +3 -3
  60. package/dist/server/index.mjs +1 -1
  61. package/dist/useDataListRetriever-BqJSFBck.d.mts +33 -0
  62. package/dist/useDataListRetriever-BqJSFBck.d.ts +33 -0
  63. package/dist/{useSocket-CmzVtg32.d.mts → useSocket-BkxHHujj.d.mts} +1 -1
  64. package/dist/{useSocket-8eUtnL7J.d.ts → useSocket-CMDjWFYm.d.ts} +1 -1
  65. package/package.json +1 -1
  66. package/src/client/index.ts +0 -4
  67. package/src/components/index.ts +0 -3
  68. package/src/contexts/index.ts +1 -0
  69. package/src/core/index.ts +2 -0
  70. package/src/core/registry/ModuleRegistry.ts +2 -0
  71. package/src/features/assistant/components/parts/AssistantThread.tsx +1 -1
  72. package/src/features/assistant-message/AssistantMessageModule.ts +4 -0
  73. package/src/features/assistant-message/components/MessageItem.tsx +7 -7
  74. package/src/features/assistant-message/components/MessageList.tsx +1 -1
  75. package/src/features/assistant-message/components/__tests__/MessageItem.spec.tsx +11 -7
  76. package/src/features/assistant-message/components/index.ts +1 -0
  77. package/src/features/assistant-message/components/parts/MessageSourcesContainer.tsx +135 -0
  78. package/src/features/assistant-message/components/parts/MessageSourcesPanel.tsx +151 -0
  79. package/src/features/assistant-message/components/parts/RelevanceMeter.tsx +29 -0
  80. package/src/features/assistant-message/components/parts/__tests__/MessageSourcesPanel.spec.tsx +70 -0
  81. package/src/features/assistant-message/components/parts/tabs/CitationsTab.tsx +105 -0
  82. package/src/features/assistant-message/components/parts/tabs/ContentsTab.tsx +88 -0
  83. package/src/features/assistant-message/components/parts/tabs/ReferencesTab.tsx +51 -0
  84. package/src/features/assistant-message/components/parts/tabs/SuggestedQuestionsTab.tsx +24 -0
  85. package/src/features/assistant-message/components/parts/tabs/UsersTab.tsx +142 -0
  86. package/src/features/assistant-message/data/AssistantMessage.ts +20 -0
  87. package/src/features/assistant-message/data/AssistantMessageInterface.ts +2 -0
  88. package/src/features/assistant-message/data/AssistantMessageService.ts +13 -4
  89. package/src/features/assistant-message/data/__tests__/AssistantMessage.citations.spec.ts +65 -0
  90. package/src/features/assistant-message/data/__tests__/AssistantMessage.spec.ts +8 -0
  91. package/src/features/chunk/ChunkModule.ts +18 -0
  92. package/src/features/chunk/data/Chunk.ts +49 -0
  93. package/src/features/chunk/data/ChunkInput.ts +3 -0
  94. package/src/features/chunk/data/ChunkInterface.ts +18 -0
  95. package/src/features/chunk/data/__tests__/Chunk.spec.ts +83 -0
  96. package/src/features/chunk/data/index.ts +3 -0
  97. package/src/features/chunk/index.ts +2 -0
  98. package/src/features/rbac/components/RbacContainer.tsx +318 -49
  99. package/src/features/rbac/components/RbacPermissionPicker.tsx +144 -121
  100. package/src/features/rbac/contexts/RbacContext.tsx +209 -0
  101. package/src/features/rbac/contexts/index.ts +1 -0
  102. package/src/features/rbac/data/RbacMatrixModel.ts +84 -0
  103. package/src/features/rbac/data/RbacService.ts +61 -33
  104. package/src/features/rbac/data/RbacTypes.ts +28 -0
  105. package/src/features/rbac/data/index.ts +1 -0
  106. package/src/features/rbac/index.ts +1 -10
  107. package/src/features/rbac/rbac.module.ts +13 -0
  108. package/dist/ModulePathsInterface-BrdqgteS.d.mts +0 -31
  109. package/dist/ModulePathsInterface-DJKs7s_s.d.ts +0 -31
  110. package/dist/chunk-FDJQRIMY.js.map +0 -1
  111. package/dist/chunk-I65SSQ5Z.mjs.map +0 -1
  112. package/dist/chunk-NB6TIKHK.mjs.map +0 -1
  113. package/dist/chunk-X4YDETTD.js.map +0 -1
  114. package/dist/chunk-ZEDB6JVB.js.map +0 -1
  115. package/dist/useRbacState-C88O-5L8.d.ts +0 -77
  116. package/dist/useRbacState-mqYiRp3J.d.mts +0 -77
  117. package/src/features/assistant-message/components/parts/ReferenceBadges.tsx +0 -46
  118. package/src/features/assistant-message/components/parts/SuggestedFollowUps.tsx +0 -52
  119. package/src/features/assistant-message/components/parts/__tests__/ReferenceBadges.spec.tsx +0 -59
  120. package/src/features/assistant-message/components/parts/__tests__/SuggestedFollowUps.spec.tsx +0 -29
  121. package/src/features/rbac/components/RbacFeatureSection.tsx +0 -66
  122. package/src/features/rbac/components/RbacModuleTable.tsx +0 -121
  123. package/src/features/rbac/components/RbacToolbar.tsx +0 -40
  124. package/src/features/rbac/hooks/useRbacState.test.ts +0 -180
  125. package/src/features/rbac/hooks/useRbacState.ts +0 -319
  126. package/src/features/rbac/utils/RbacMigrationGenerator.test.ts +0 -124
  127. package/src/features/rbac/utils/RbacMigrationGenerator.ts +0 -184
  128. /package/dist/{BlockNoteEditor-JXK3JGKJ.mjs.map → BlockNoteEditor-3M5PD3BZ.mjs.map} +0 -0
@@ -1,47 +1,75 @@
1
1
  import { AbstractService, EndpointCreator, HttpMethod, Modules } from "../../../core";
2
- import { FeatureInterface } from "../../feature";
3
- import { RoleInterface } from "../../role";
4
- import { PermissionMappingInterface } from "./PermissionMappingInterface";
5
- import { ModulePathsInterface } from "./ModulePathsInterface";
2
+ import type { RbacMatrixModel } from "./RbacMatrixModel";
3
+ import type { RbacMatrix } from "./RbacTypes";
6
4
 
5
+ /**
6
+ * RbacService — fetches RBAC configuration for the admin UI.
7
+ *
8
+ * Declarative-matrix methods (`fetchMatrix`, `saveMatrix`) talk to the
9
+ * dev-only endpoints added in
10
+ * `packages/nestjs-neo4jsonapi/.../rbac-dev.controller.ts`. The controller
11
+ * speaks JSON:API (singleton resource with `type: "rbac-matrix"`, `id:
12
+ * "singleton"`), so these methods go through the standard `callApi()`
13
+ * pipeline like every other service in the codebase.
14
+ *
15
+ * The backend only registers these routes when `devMode` is enabled on
16
+ * `RbacModule.register` (see `apps/api/src/features/features.modules.ts`).
17
+ * In production the routes return 404; callers should guard with a dev-mode
18
+ * check.
19
+ */
7
20
  export class RbacService extends AbstractService {
8
- static async getFeatures(): Promise<FeatureInterface[]> {
9
- const endpoint = new EndpointCreator({ endpoint: Modules.Feature }).addAdditionalParam("fetchAll", "true");
21
+ /**
22
+ * Fetch the current RBAC matrix plus each module's known BFS relationship
23
+ * paths (used by the permission picker as scope suggestions).
24
+ *
25
+ * Dev-only endpoint — see class header.
26
+ */
27
+ static async fetchMatrix(): Promise<{
28
+ matrix: RbacMatrix;
29
+ modulePaths: Record<string, readonly string[]>;
30
+ }> {
31
+ const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();
10
32
 
11
- return this.callApi<FeatureInterface[]>({
12
- type: Modules.Feature,
33
+ const model = await this.callApi<RbacMatrixModel>({
34
+ type: Modules.RbacMatrix,
13
35
  method: HttpMethod.GET,
14
- endpoint: endpoint.generate(),
36
+ endpoint,
15
37
  });
16
- }
17
-
18
- static async getRoles(): Promise<RoleInterface[]> {
19
- const endpoint = new EndpointCreator({ endpoint: Modules.Role }).addAdditionalParam("fetchAll", "true");
20
38
 
21
- return this.callApi<RoleInterface[]>({
22
- type: Modules.Role,
23
- method: HttpMethod.GET,
24
- endpoint: endpoint.generate(),
25
- });
39
+ return {
40
+ matrix: model.matrix ?? {},
41
+ modulePaths: model.modulePaths ?? {},
42
+ };
26
43
  }
27
44
 
28
- static async getPermissionMappings(): Promise<PermissionMappingInterface[]> {
29
- const endpoint = new EndpointCreator({ endpoint: Modules.PermissionMapping });
45
+ /**
46
+ * Persist a matrix back to the declarative `permissions.ts` file.
47
+ *
48
+ * The backend serializes the matrix to formatted TypeScript using the
49
+ * provided `roleNames` / `moduleNames` lookup tables (so the emitted file
50
+ * references `RoleId.X` / `ModuleId.X` rather than raw UUIDs) and writes
51
+ * it to `outputPath` (absolute, or relative to the repo root).
52
+ *
53
+ * Dev-only endpoint — see class header.
54
+ */
55
+ static async saveMatrix(args: {
56
+ matrix: RbacMatrix;
57
+ roleNames: Record<string, string>;
58
+ moduleNames: Record<string, string>;
59
+ outputPath: string;
60
+ }): Promise<{ bytesWritten: number; path: string }> {
61
+ const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();
30
62
 
31
- return this.callApi<PermissionMappingInterface[]>({
32
- type: Modules.PermissionMapping,
33
- method: HttpMethod.GET,
34
- endpoint: endpoint.generate(),
63
+ const model = await this.callApi<RbacMatrixModel>({
64
+ type: Modules.RbacMatrix,
65
+ method: HttpMethod.PUT,
66
+ endpoint,
67
+ input: args,
35
68
  });
36
- }
37
-
38
- static async getModuleRelationshipPaths(): Promise<ModulePathsInterface[]> {
39
- const endpoint = new EndpointCreator({ endpoint: Modules.ModulePaths });
40
69
 
41
- return this.callApi<ModulePathsInterface[]>({
42
- type: Modules.ModulePaths,
43
- method: HttpMethod.GET,
44
- endpoint: endpoint.generate(),
45
- });
70
+ return {
71
+ bytesWritten: model.bytesWritten ?? 0,
72
+ path: model.path ?? "",
73
+ };
46
74
  }
47
75
  }
@@ -13,3 +13,31 @@ export type PermissionsMap = {
13
13
  update?: PermissionValue;
14
14
  delete?: PermissionValue;
15
15
  };
16
+
17
+ /**
18
+ * Declarative-RBAC matrix types.
19
+ *
20
+ * Mirror of the library types defined in
21
+ * `packages/nestjs-neo4jsonapi/src/foundations/rbac/dsl/types.ts`.
22
+ * Frontend does not import from backend, so the shape is redefined here.
23
+ *
24
+ * A `PermToken` represents a single permission entry:
25
+ * - `scope: true` → unconditional (e.g. full read of the module)
26
+ * - `scope: false` → nothing (rarely used, mostly a placeholder)
27
+ * - `scope: "path"` → scoped by relationship path (e.g. "orders.account")
28
+ */
29
+ export type PermToken = { action: string; scope: boolean | string };
30
+
31
+ /**
32
+ * A per-module block of the matrix. Always has a `default` row (permissions
33
+ * granted to every role). Additional keys are role IDs → role-specific
34
+ * permission tokens that are unioned with `default` to produce the effective
35
+ * permissions for that role in that module.
36
+ */
37
+ export type RbacModuleBlock = { default: PermToken[] } & Record<string, PermToken[]>;
38
+
39
+ /**
40
+ * The full RBAC matrix as served by the dev endpoint `GET /_dev/rbac/matrix`.
41
+ * Keys are module IDs; values are module blocks.
42
+ */
43
+ export type RbacMatrix = Record<string, RbacModuleBlock>;
@@ -3,4 +3,5 @@ export * from "./PermissionMapping";
3
3
  export * from "./PermissionMappingInterface";
4
4
  export * from "./ModulePaths";
5
5
  export * from "./ModulePathsInterface";
6
+ export * from "./RbacMatrixModel";
6
7
  export * from "./RbacService";
@@ -1,19 +1,10 @@
1
1
  // Data layer
2
2
  export * from "./data";
3
3
 
4
- // Hooks
5
- export { useRbacState } from "./hooks/useRbacState";
6
-
7
- // Utils
8
- export { generateMigrationFile, downloadMigrationFile } from "./utils/RbacMigrationGenerator";
9
-
10
4
  // Components
11
5
  export { RbacContainer } from "./components/RbacContainer";
12
- export { RbacToolbar } from "./components/RbacToolbar";
13
- export { RbacFeatureSection } from "./components/RbacFeatureSection";
14
- export { RbacModuleTable } from "./components/RbacModuleTable";
15
6
  export { RbacPermissionCell } from "./components/RbacPermissionCell";
16
7
  export { RbacPermissionPicker } from "./components/RbacPermissionPicker";
17
8
 
18
9
  // Module registrations
19
- export { PermissionMappingModule, ModulePathsModule } from "./rbac.module";
10
+ export { PermissionMappingModule, ModulePathsModule, RbacMatrixModule } from "./rbac.module";
@@ -1,6 +1,7 @@
1
1
  import { ModuleFactory } from "../../permissions";
2
2
  import { PermissionMapping } from "./data/PermissionMapping";
3
3
  import { ModulePaths } from "./data/ModulePaths";
4
+ import { RbacMatrixModel } from "./data/RbacMatrixModel";
4
5
 
5
6
  export const PermissionMappingModule = (factory: ModuleFactory) =>
6
7
  factory({
@@ -17,3 +18,15 @@ export const ModulePathsModule = (factory: ModuleFactory) =>
17
18
  model: ModulePaths,
18
19
  moduleId: "f4fb3f01-a947-4c2e-89c8-354a518cdb13",
19
20
  });
21
+
22
+ /**
23
+ * Dev-only matrix module. The `name` is the URL path of the dev singleton
24
+ * endpoint (`GET|PUT _dev/rbac/matrix`), NOT a plural resource collection.
25
+ * This module is only useful when the backend is running with `devMode: true`
26
+ * on `RbacModule.register`.
27
+ */
28
+ export const RbacMatrixModule = (factory: ModuleFactory) =>
29
+ factory({
30
+ name: "_dev/rbac/matrix",
31
+ model: RbacMatrixModel,
32
+ });
@@ -1,31 +0,0 @@
1
- import { A as ApiDataInterface } from './ApiDataInterface-BcZeXy5X.mjs';
2
-
3
- declare const COMPANY_ADMINISTRATOR_ROLE_ID = "2e1eee00-6cba-4506-9059-ccd24e4ea5b0";
4
- type PermissionValue = boolean | string;
5
- type ActionType = "read" | "create" | "update" | "delete";
6
- declare const ACTION_TYPES: ActionType[];
7
- /** The permissions object shape used by both Module and PermissionMapping entities */
8
- type PermissionsMap = {
9
- create?: PermissionValue;
10
- read?: PermissionValue;
11
- update?: PermissionValue;
12
- delete?: PermissionValue;
13
- };
14
-
15
- interface PermissionMappingInterface extends ApiDataInterface {
16
- get roleId(): string;
17
- get moduleId(): string;
18
- get permissions(): {
19
- create?: boolean | string;
20
- read?: boolean | string;
21
- update?: boolean | string;
22
- delete?: boolean | string;
23
- };
24
- }
25
-
26
- interface ModulePathsInterface extends ApiDataInterface {
27
- get moduleId(): string;
28
- get paths(): string[];
29
- }
30
-
31
- export { type ActionType as A, COMPANY_ADMINISTRATOR_ROLE_ID as C, type ModulePathsInterface as M, type PermissionMappingInterface as P, type PermissionValue as a, type PermissionsMap as b, ACTION_TYPES as c };
@@ -1,31 +0,0 @@
1
- import { A as ApiDataInterface } from './ApiDataInterface-BcZeXy5X.js';
2
-
3
- declare const COMPANY_ADMINISTRATOR_ROLE_ID = "2e1eee00-6cba-4506-9059-ccd24e4ea5b0";
4
- type PermissionValue = boolean | string;
5
- type ActionType = "read" | "create" | "update" | "delete";
6
- declare const ACTION_TYPES: ActionType[];
7
- /** The permissions object shape used by both Module and PermissionMapping entities */
8
- type PermissionsMap = {
9
- create?: PermissionValue;
10
- read?: PermissionValue;
11
- update?: PermissionValue;
12
- delete?: PermissionValue;
13
- };
14
-
15
- interface PermissionMappingInterface extends ApiDataInterface {
16
- get roleId(): string;
17
- get moduleId(): string;
18
- get permissions(): {
19
- create?: boolean | string;
20
- read?: boolean | string;
21
- update?: boolean | string;
22
- delete?: boolean | string;
23
- };
24
- }
25
-
26
- interface ModulePathsInterface extends ApiDataInterface {
27
- get moduleId(): string;
28
- get paths(): string[];
29
- }
30
-
31
- export { type ActionType as A, COMPANY_ADMINISTRATOR_ROLE_ID as C, type ModulePathsInterface as M, type PermissionMappingInterface as P, type PermissionValue as a, type PermissionsMap as b, ACTION_TYPES as c };