Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ added on a connection (`func_…`). Every tag is of type `CodeMarketplace`.
| Area | Hooks | Cache tag (`CodeMarketplace/…`) |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| Catalog | `useGetMarketplaceListingsQuery`, `useGetMarketplaceListingQuery`, `useGetMarketplaceListingFunctionTokensQuery` | provides `LISTINGS` |
| Connections | `useGetMarketplaceIntegrationsQuery`, `useGetMarketplaceIntegrationQuery`, `useSaveMarketplaceIntegrationMutation`, `useDeleteMarketplaceIntegrationMutation`, `useEnableMarketplaceIntegrationMutation`, `useDisableMarketplaceIntegrationMutation`, `useReplaceMarketplaceIntegrationSecretsMutation`, `useRevealMarketplaceIntegrationSecretsMutation`, `useSetMarketplaceIntegrationTokenMappingsMutation`, `useTestMarketplaceIntegrationMutation`, `useGetMarketplaceFunctionCatalogQuery` | `INTEGRATIONS`, `<integrationViewId>`, `CATALOG:<integrationViewId>`; reveal touches nothing |
| Connections | `useGetMarketplaceIntegrationsQuery`, `useGetMarketplaceIntegrationQuery`, `useSaveMarketplaceIntegrationMutation`, `useDeleteMarketplaceIntegrationMutation`, `useEnableMarketplaceIntegrationMutation`, `useDisableMarketplaceIntegrationMutation`, `useReplaceMarketplaceIntegrationSecretsMutation`, `useRevealMarketplaceIntegrationSecretsMutation`, `useSetMarketplaceIntegrationTokenMappingsMutation`, `useTestMarketplaceIntegrationMutation`, `useGetMarketplaceFunctionCatalogQuery`, `useGetMarketplaceIntegrationToolsQuery` (the stored MCP tool catalog of an MCP connection, core SDK 4.23.0+) | `INTEGRATIONS`, `<integrationViewId>`, `CATALOG:<integrationViewId>`, `TOOLS:<integrationViewId>` (test and delete invalidate it); reveal touches nothing |
| Functions | `useGetMarketplaceFunctionsQuery`, `useGetMarketplaceFunctionQuery`, `useSaveMarketplaceFunctionMutation`, `useDeleteMarketplaceFunctionMutation`, `useEnableMarketplaceFunctionMutation`, `useDisableMarketplaceFunctionMutation`, `useGetMarketplaceFunctionTokensQuery`, `useInvokeMarketplaceFunctionMutation`, `useGetMarketplaceFunctionRunsQuery` | `FUNCTIONS:<integrationViewId>`, `<functionViewId>`, `RUNS`; invoke touches nothing |

Revealing secrets is a mutation on purpose: a query would keep the clear values
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@commitlint/cli": "^21.2.2",
"@commitlint/config-conventional": "^21.2.2",
"@eslint/js": "^10.0.1",
"@norbix.ai/ts": "^4.22.0",
"@norbix.ai/ts": "^4.23.0",
"@reduxjs/toolkit": "^2.12.0",
"@semantic-release/commit-analyzer": "^13.0.1",
"@semantic-release/github": "^12.0.9",
Expand Down
13 changes: 12 additions & 1 deletion src/hooks/hub/marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import type { Arg, Result } from '../types.js';
* - `<integrationViewId>` — one connection (secrets, token mappings and the
* last validation steps live on it)
* - `CATALOG:<integrationId>` — the vendor functions a connection offers
* - `TOOLS:<integrationId>` — the stored MCP tool catalog of an MCP connection;
* validation (test) rewrites it (core SDK 4.23.0)
* - `FUNCTIONS:<integrationId>`— the functions added on a connection
* - `<functionViewId>` — one function and its tokens
* - `RUNS` — the last runs of a trigger or task (core SDK 4.21.0)
Expand All @@ -41,6 +43,7 @@ export const hubCodeMarketplace = (b: Builder) => {
type SetTokenMappings = Fn<'setMarketplaceIntegrationTokenMappings'>;
type TestIntegration = Fn<'testMarketplaceIntegration'>;
type GetCatalog = Fn<'getMarketplaceFunctionCatalog'>;
type GetTools = Fn<'getMarketplaceIntegrationTools'>;
type GetFunctions = Fn<'getMarketplaceFunctions'>;
type GetFunction = Fn<'getMarketplaceFunction'>;
type SaveFunction = Fn<'saveMarketplaceFunction'>;
Expand Down Expand Up @@ -108,6 +111,7 @@ export const hubCodeMarketplace = (b: Builder) => {
invalidatesTags: (_res, _err, arg) => [
...integration(arg),
{ type: T, id: `FUNCTIONS:${integrationId(arg)}` },
{ type: T, id: `TOOLS:${integrationId(arg)}` },
],
}),
enableMarketplaceIntegration: b.mutation<Result<EnableIntegration>, Arg<EnableIntegration>>({
Expand All @@ -134,12 +138,19 @@ export const hubCodeMarketplace = (b: Builder) => {
}),
testMarketplaceIntegration: b.mutation<Result<TestIntegration>, Arg<TestIntegration>>({
query: (args) => (norbix) => callHC(norbix).testMarketplaceIntegration(args),
invalidatesTags: (_res, _err, arg) => [{ type: T, id: integrationId(arg) }],
invalidatesTags: (_res, _err, arg) => [
{ type: T, id: integrationId(arg) },
{ type: T, id: `TOOLS:${integrationId(arg)}` },
],
}),
getMarketplaceFunctionCatalog: b.query<Result<GetCatalog>, Arg<GetCatalog>>({
query: (args) => (norbix) => callHC(norbix).getMarketplaceFunctionCatalog(args),
providesTags: (_res, _err, arg) => [{ type: T, id: `CATALOG:${integrationId(arg)}` }],
}),
getMarketplaceIntegrationTools: b.query<Result<GetTools>, Arg<GetTools>>({
query: (args) => (norbix) => callHC(norbix).getMarketplaceIntegrationTools(args),
providesTags: (_res, _err, arg) => [{ type: T, id: `TOOLS:${integrationId(arg)}` }],
}),

// ---- Functions on a connection ----
getMarketplaceFunctions: b.query<Result<GetFunctions>, Arg<GetFunctions>>({
Expand Down
16 changes: 14 additions & 2 deletions tests/marketplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const CASES: Array<
],
['testMarketplaceIntegration', 'mutation', 'POST', `${I}/test`, IDS, {}],
['getMarketplaceFunctionCatalog', 'query', 'GET', `${I}/catalog`, IDS, {}],
['getMarketplaceIntegrationTools', 'query', 'GET', `${I}/tools`, IDS, {}],
['getMarketplaceFunctions', 'query', 'GET', `${I}/functions`, IDS, {}],
['getMarketplaceFunction', 'query', 'GET', `${I}/functions/${FUNCTION}`, FN_IDS, {}],
[
Expand Down Expand Up @@ -152,7 +153,7 @@ function tagsFor(tags: Tags | undefined, arg: unknown): unknown {
const endpoints = hubCodeMarketplace(fakeBuilder()) as unknown as Record<string, Def>;

describe('hubCodeMarketplace', () => {
it('wraps the 23 marketplace methods of the published core SDK', () => {
it('wraps the 24 marketplace methods of the published core SDK', () => {
expect(Object.keys(endpoints).sort()).toEqual([...NAMES].sort());
});

Expand Down Expand Up @@ -202,19 +203,30 @@ describe('hubCodeMarketplace', () => {
{ type: 'CodeMarketplace', id: 'INTEGRATIONS' },
{ type: 'CodeMarketplace', id: INTEGRATION },
{ type: 'CodeMarketplace', id: `FUNCTIONS:${INTEGRATION}` },
{ type: 'CodeMarketplace', id: `TOOLS:${INTEGRATION}` },
]);
expect(tagsFor(endpoints['saveMarketplaceIntegration']!.invalidatesTags, {})).toEqual([
{ type: 'CodeMarketplace', id: 'INTEGRATIONS' },
]);
for (const key of [
'replaceMarketplaceIntegrationSecrets',
'setMarketplaceIntegrationTokenMappings',
'testMarketplaceIntegration',
]) {
expect(tagsFor(endpoints[key]!.invalidatesTags, IDS)).toEqual([
{ type: 'CodeMarketplace', id: INTEGRATION },
]);
}
// Validation lists the MCP server's tools again and stores the catalog (gateway item mcp-step1).
expect(tagsFor(endpoints['testMarketplaceIntegration']!.invalidatesTags, IDS)).toEqual([
{ type: 'CodeMarketplace', id: INTEGRATION },
{ type: 'CodeMarketplace', id: `TOOLS:${INTEGRATION}` },
]);
});

it('the MCP tool catalog provides TOOLS:<integration> (core SDK 4.23.0)', () => {
expect(tagsFor(endpoints['getMarketplaceIntegrationTools']!.providesTags, IDS)).toEqual([
{ type: 'CodeMarketplace', id: `TOOLS:${INTEGRATION}` },
]);
});

it('the last runs provide CodeMarketplace/RUNS', () => {
Expand Down