diff --git a/README.md b/README.md index cd169d3..7e23f90 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ Every `hub.database` method (73) and every `api.database` method (22) of `@norbi | `useApplyDatabaseSchemaBundleMutation` | `hub.database.applyDatabaseSchemaBundle` | invalidates `DatabaseSchemas` + taxonomies + terms | | `useUpdateDatabaseSchemaEmbedMutation` | `hub.database.updateDatabaseSchemaEmbed` | invalidates `DatabaseSchemas` | | `useGetDatabaseSchemaListSettingsQuery` | `hub.database.getDatabaseSchemaListSettings` | provides `DatabaseSchemas` | +| `useGetDatabaseSchemaIndexStatusQuery` | `hub.database.getDatabaseSchemaIndexStatus` | provides `DatabaseSchemas/` — the last schema-index run (building / ready / refused / partial) | | `useUpdateDatabaseSchemaListSettingsMutation` | `hub.database.updateDatabaseSchemaListSettings` | invalidates `DatabaseSchemas` | | `useGetCollectionImportsQuery` | `hub.database.getCollectionImports` | provides `DatabaseImports` | | `useGetCollectionImportQuery` | `hub.database.getCollectionImport` | provides `DatabaseImports` | diff --git a/package-lock.json b/package-lock.json index 5ce970c..764646a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@commitlint/cli": "^21.2.2", "@commitlint/config-conventional": "^21.2.2", "@eslint/js": "^10.0.1", - "@norbix.ai/ts": "^4.11.0", + "@norbix.ai/ts": "^4.17.0", "@reduxjs/toolkit": "^2.12.0", "@semantic-release/commit-analyzer": "^13.0.1", "@semantic-release/github": "^12.0.9", @@ -1490,9 +1490,9 @@ } }, "node_modules/@norbix.ai/ts": { - "version": "4.11.0", - "resolved": "https://registry.npmjs.org/@norbix.ai/ts/-/ts-4.11.0.tgz", - "integrity": "sha512-Amrs58kmKBnegPCNdrYtiHaCwRnx9hN+JHS+qneLRAzmQuJ86evMDohn13qs+YwBgvvhOkwEb76opcs31y3Isg==", + "version": "4.17.0", + "resolved": "https://registry.npmjs.org/@norbix.ai/ts/-/ts-4.17.0.tgz", + "integrity": "sha512-Wo4DOnyaW91UUz3gbTUyvgxHC8dHPxL4W9FGmdBgPXBNtAgSwReaPuOEqLXXrsQ0F79mkfvrsxQR0ir0BqqbPw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 31e28e9..92acf4f 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@commitlint/cli": "^21.2.2", "@commitlint/config-conventional": "^21.2.2", "@eslint/js": "^10.0.1", - "@norbix.ai/ts": "^4.11.0", + "@norbix.ai/ts": "^4.17.0", "@reduxjs/toolkit": "^2.12.0", "@semantic-release/commit-analyzer": "^13.0.1", "@semantic-release/github": "^12.0.9", diff --git a/src/hooks/hub/database.ts b/src/hooks/hub/database.ts index e7224da..7ee9016 100644 --- a/src/hooks/hub/database.ts +++ b/src/hooks/hub/database.ts @@ -72,6 +72,7 @@ type GetDatabaseMergedTermTree = Norbix['hub']['database']['getDatabaseMergedTer type ApplyDatabaseSchemaBundle = Norbix['hub']['database']['applyDatabaseSchemaBundle']; type UpdateDatabaseSchemaEmbed = Norbix['hub']['database']['updateDatabaseSchemaEmbed']; type GetDatabaseSchemaListSettings = Norbix['hub']['database']['getDatabaseSchemaListSettings']; +type GetDatabaseSchemaIndexStatus = Norbix['hub']['database']['getDatabaseSchemaIndexStatus']; type UpdateDatabaseSchemaListSettings = Norbix['hub']['database']['updateDatabaseSchemaListSettings']; type GetCollectionImports = Norbix['hub']['database']['getCollectionImports']; @@ -510,6 +511,18 @@ export const hubDatabase = (b: Builder) => ({ query: (args) => (norbix) => norbix.hub.database.getDatabaseSchemaListSettings(args), providesTags: ['DatabaseSchemas'], }), + // The last schema-index run (campaign 24 mongo-indexes): building | ready | + // refused | partial, one entry per database. Cached per schema so a List + // tab polling one schema never refetches the others. + getDatabaseSchemaIndexStatus: b.query< + Result, + Arg + >({ + query: (args) => (norbix) => norbix.hub.database.getDatabaseSchemaIndexStatus(args), + providesTags: (_res, _err, arg) => [ + { type: 'DatabaseSchemas', id: (arg as { id?: string })?.id ?? 'ANY' }, + ], + }), updateDatabaseSchemaListSettings: b.mutation< Result, diff --git a/tests/database.test.ts b/tests/database.test.ts index bba1304..1cd52dd 100644 --- a/tests/database.test.ts +++ b/tests/database.test.ts @@ -75,9 +75,9 @@ const RECORD_WRITES = [ describe('hubDatabase', () => { const endpoints = hubDatabase(fakeBuilder()) as unknown as Record; - it('has one hook per hub.database method of @norbix.ai/ts, same name (73)', () => { + it('has one hook per hub.database method of @norbix.ai/ts, same name (74)', () => { const methods = sdkMethods('hub'); - expect(methods).toHaveLength(73); + expect(methods).toHaveLength(74); expect(Object.keys(endpoints).sort()).toEqual(methods); }); @@ -174,6 +174,10 @@ describe('hubDatabase', () => { it('embed and list settings live on the schema cache', () => { expect(endpoints.getDatabaseSchemaListSettings.__kind).toBe('query'); expect(endpoints.getDatabaseSchemaListSettings.providesTags).toEqual(['DatabaseSchemas']); + expect(endpoints.getDatabaseSchemaIndexStatus.__kind).toBe('query'); + expect(tags(endpoints.getDatabaseSchemaIndexStatus, 'providesTags', { id: 'sch_1' })).toEqual([ + { type: 'DatabaseSchemas', id: 'sch_1' }, + ]); for (const key of ['updateDatabaseSchemaListSettings', 'updateDatabaseSchemaEmbed']) { expect(endpoints[key].__kind).toBe('mutation'); expect(endpoints[key].invalidatesTags).toEqual(['DatabaseSchemas']); @@ -258,7 +262,7 @@ describe('database hooks in the flat endpoint map', () => { await all[key].query({})(viaFlatMap.client); } expect(viaFlatMap.calls).toEqual(viaFactory.calls); - expect(viaFlatMap.calls.filter((c) => c.method.startsWith('hub.'))).toHaveLength(73); + expect(viaFlatMap.calls.filter((c) => c.method.startsWith('hub.'))).toHaveLength(74); }); });