@startsimpli/hooks 0.4.19 → 0.4.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/hooks",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "description": "Shared React hooks for StartSimpli apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -23,7 +23,7 @@
23
23
  "@tanstack/react-query": ">=5.0.0",
24
24
  "react": ">=18.0.0",
25
25
  "react-native": ">=0.74.0",
26
- "@startsimpli/api": "0.5.28"
26
+ "@startsimpli/api": "0.5.29"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@tanstack/react-query": {
@@ -46,7 +46,7 @@
46
46
  "tsup": "^8.5.1",
47
47
  "typescript": "^6.0.3",
48
48
  "vitest": "^4.1.5",
49
- "@startsimpli/api": "0.5.28"
49
+ "@startsimpli/api": "0.5.29"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup",
@@ -8,6 +8,7 @@ import {
8
8
  useDeleteProject,
9
9
  useDeleteSecret,
10
10
  useLinkSharedKey,
11
+ useProject,
11
12
  useRotateSharedKey,
12
13
  useUpdateSecret,
13
14
  } from '../useVault'
@@ -169,6 +170,15 @@ describe('projects + global keys hooks (startsim-oftw, startsim-1m4g)', () => {
169
170
  )
170
171
  })
171
172
 
173
+ it('useProject fetches a single project with aggregates', async () => {
174
+ const qc = mkClient()
175
+ const api = fakeApi({ getProject: vi.fn().mockResolvedValue({ slug: 'alpha', totalSecretCount: 4, linkedSharedKeyCount: 1 }) })
176
+ const { result } = renderHook(() => useProject(api, 'alpha'), { wrapper: wrap(qc) })
177
+ await waitFor(() => expect(result.current.isSuccess).toBe(true))
178
+ expect(api.getProject).toHaveBeenCalledWith('alpha')
179
+ expect(result.current.data?.totalSecretCount).toBe(4)
180
+ })
181
+
172
182
  it('useLinkSharedKey links and refreshes the env links + shared-secret counts', async () => {
173
183
  const qc = mkClient()
174
184
  const seen = trackInvalidations(qc)
package/src/index.ts CHANGED
@@ -73,6 +73,7 @@ export type { UseAsyncOptionsResult } from './useAsyncOptions'
73
73
  // + projects + global/shared keys (startsim-oftw, startsim-1m4g)
74
74
  export {
75
75
  useProjects,
76
+ useProject,
76
77
  useCreateProject,
77
78
  useUpdateProject,
78
79
  useDeleteProject,
package/src/useVault.ts CHANGED
@@ -41,6 +41,16 @@ export function useProjects(api: VaultApi, params?: VaultListParams) {
41
41
  })
42
42
  }
43
43
 
44
+ /** Single project with aggregates (env count, total secrets, linked global keys)
45
+ * for the project detail page (startsim-6fv6). */
46
+ export function useProject(api: VaultApi, slug: string) {
47
+ return useQuery({
48
+ queryKey: ['vault', 'project', slug],
49
+ queryFn: () => api.getProject(slug),
50
+ enabled: !!slug,
51
+ })
52
+ }
53
+
44
54
  export function useCreateProject(api: VaultApi) {
45
55
  const qc = useQueryClient()
46
56
  return useMutation({