@igstack/app-catalog-frontend-core 0.3.1-alpha-20260405015231 → 0.3.1-alpha-20260406011911

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 (62) hide show
  1. package/dist/esm/__tests__/integration/harness/MockBackendVerifier.d.ts +3 -3
  2. package/dist/esm/__tests__/integration/mock-backend/MockBackendConfigurer.d.ts +4 -4
  3. package/dist/esm/__tests__/integration/mock-backend/MockDb.d.ts +11 -7
  4. package/dist/esm/api/infra/trpc.d.ts +3 -3
  5. package/dist/esm/modules/appCatalog/context/AppCatalogContext.d.ts +2 -3
  6. package/dist/esm/modules/appCatalog/context/AppCatalogContext.js +2 -4
  7. package/dist/esm/modules/appCatalog/context/AppCatalogContext.js.map +1 -1
  8. package/dist/esm/modules/appCatalog/hooks/useAppCounts.d.ts +2 -2
  9. package/dist/esm/modules/appCatalog/hooks/useAppCounts.js +3 -3
  10. package/dist/esm/modules/appCatalog/hooks/useAppCounts.js.map +1 -1
  11. package/dist/esm/modules/appCatalog/hooks/useUpdateApp.d.ts +9 -0
  12. package/dist/esm/modules/appCatalog/ui/components/AccessRequestSection.d.ts +2 -2
  13. package/dist/esm/modules/appCatalog/ui/components/AccessRequestSection.js.map +1 -1
  14. package/dist/esm/modules/appCatalog/ui/components/AppDetailModal.d.ts +2 -2
  15. package/dist/esm/modules/appCatalog/ui/components/ScreenshotGallery.d.ts +2 -2
  16. package/dist/esm/modules/appCatalog/ui/components/ScreenshotGallery.js.map +1 -1
  17. package/dist/esm/modules/appCatalog/ui/components/SubResourcesSection.d.ts +2 -2
  18. package/dist/esm/modules/appCatalog/ui/components/SubResourcesSection.js +12 -14
  19. package/dist/esm/modules/appCatalog/ui/components/SubResourcesSection.js.map +1 -1
  20. package/dist/esm/modules/appCatalog/ui/components/TierVariantsSection.d.ts +2 -2
  21. package/dist/esm/modules/appCatalog/ui/components/TierVariantsSection.js.map +1 -1
  22. package/dist/esm/modules/appCatalog/ui/filters/FilterBar.d.ts +2 -2
  23. package/dist/esm/modules/appCatalog/ui/filters/FilterBar.js.map +1 -1
  24. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.d.ts +3 -3
  25. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.js +19 -19
  26. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.js.map +1 -1
  27. package/dist/esm/modules/appCatalog/ui/grid/AppCatalogTable.d.ts +2 -2
  28. package/dist/esm/modules/appCatalog/ui/grid/appCatalogUtils.d.ts +2 -2
  29. package/dist/esm/modules/appCatalog/ui/hooks/useKeyboardNavigation.d.ts +3 -3
  30. package/dist/esm/modules/appCatalog/ui/hooks/useKeyboardNavigation.js.map +1 -1
  31. package/dist/esm/modules/appCatalog/ui/pages/AppCatalogPage.js +20 -12
  32. package/dist/esm/modules/appCatalog/ui/pages/AppCatalogPage.js.map +1 -1
  33. package/dist/esm/modules/appCatalog/utils/resolveHelpers.d.ts +5 -2
  34. package/dist/esm/modules/appCatalog/utils/resolveHelpers.js +4 -4
  35. package/dist/esm/modules/appCatalog/utils/resolveHelpers.js.map +1 -1
  36. package/dist/esm/modules/appCatalog/utils/searchApps.d.ts +11 -6
  37. package/dist/esm/modules/appCatalog/utils/searchApps.js +15 -14
  38. package/dist/esm/modules/appCatalog/utils/searchApps.js.map +1 -1
  39. package/package.json +3 -3
  40. package/src/__tests__/integration/appCatalog.integration.test.ts +3 -3
  41. package/src/__tests__/integration/harness/MockBackendVerifier.ts +5 -5
  42. package/src/__tests__/integration/mock-backend/MockBackendConfigurer.ts +16 -12
  43. package/src/__tests__/integration/mock-backend/MockDb.ts +30 -22
  44. package/src/__tests__/modules/appCatalog/ScreenshotPreview.test.tsx +4 -5
  45. package/src/__tests__/modules/appCatalog/utils/searchApps.test.ts +28 -30
  46. package/src/__tests__/modules/gallery/EscapeDismissal.integration.test.tsx +3 -4
  47. package/src/modules/appCatalog/context/AppCatalogContext.tsx +4 -8
  48. package/src/modules/appCatalog/hooks/useAppCounts.ts +5 -5
  49. package/src/modules/appCatalog/ui/components/AccessRequestSection.tsx +2 -2
  50. package/src/modules/appCatalog/ui/components/AppDetailModal.tsx +10 -10
  51. package/src/modules/appCatalog/ui/components/ScreenshotGallery.tsx +2 -2
  52. package/src/modules/appCatalog/ui/components/SearchAndFilterHeader.tsx +6 -2
  53. package/src/modules/appCatalog/ui/components/SubResourcesSection.tsx +17 -17
  54. package/src/modules/appCatalog/ui/components/TierVariantsSection.tsx +2 -2
  55. package/src/modules/appCatalog/ui/filters/FilterBar.tsx +2 -2
  56. package/src/modules/appCatalog/ui/grid/AppCatalogGrid.tsx +34 -37
  57. package/src/modules/appCatalog/ui/grid/AppCatalogTable.tsx +3 -3
  58. package/src/modules/appCatalog/ui/grid/appCatalogUtils.ts +2 -2
  59. package/src/modules/appCatalog/ui/hooks/useKeyboardNavigation.ts +3 -3
  60. package/src/modules/appCatalog/ui/pages/AppCatalogPage.tsx +24 -14
  61. package/src/modules/appCatalog/utils/resolveHelpers.ts +13 -10
  62. package/src/modules/appCatalog/utils/searchApps.ts +36 -31
@@ -1,4 +1,7 @@
1
- import { Group, Person, SubResource } from '@igstack/app-catalog-backend-core';
1
+ import { Group, Person, Resource } from '@igstack/app-catalog-backend-core';
2
2
  export declare function getPersonBySlug(persons: Person[], slug: string): Person | undefined;
3
3
  export declare function getGroupBySlug(groups: Group[], slug: string): Group | undefined;
4
- export declare function getSubResourcesForApp(subResources: SubResource[], appSlug: string): SubResource[];
4
+ export declare function getChildResources(resources: Resource[], parentSlug: string): Resource[];
5
+ export declare function getRootResources(resources: Resource[]): Resource[];
6
+ /** @deprecated Use getChildResources instead */
7
+ export declare const getSubResourcesForApp: typeof getChildResources;
@@ -4,12 +4,12 @@ function getPersonBySlug(persons, slug) {
4
4
  function getGroupBySlug(groups, slug) {
5
5
  return groups.find((g) => g.slug === slug);
6
6
  }
7
- function getSubResourcesForApp(subResources, appSlug) {
8
- return subResources.filter((sr) => sr.appSlug === appSlug);
7
+ function getChildResources(resources, parentSlug) {
8
+ return resources.filter((r) => r.parentSlug === parentSlug);
9
9
  }
10
10
  export {
11
+ getChildResources,
11
12
  getGroupBySlug,
12
- getPersonBySlug,
13
- getSubResourcesForApp
13
+ getPersonBySlug
14
14
  };
15
15
  //# sourceMappingURL=resolveHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveHelpers.js","sources":["../../../../../src/modules/appCatalog/utils/resolveHelpers.ts"],"sourcesContent":["import type {\n Group,\n Person,\n SubResource,\n} from '@igstack/app-catalog-backend-core'\n\nexport function getPersonBySlug(\n persons: Person[],\n slug: string,\n): Person | undefined {\n return persons.find((p) => p.slug === slug)\n}\n\nexport function getGroupBySlug(\n groups: Group[],\n slug: string,\n): Group | undefined {\n return groups.find((g) => g.slug === slug)\n}\n\nexport function getSubResourcesForApp(\n subResources: SubResource[],\n appSlug: string,\n): SubResource[] {\n return subResources.filter((sr) => sr.appSlug === appSlug)\n}\n"],"names":[],"mappings":"AAMO,SAAS,gBACd,SACA,MACoB;AACpB,SAAO,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAC5C;AAEO,SAAS,eACd,QACA,MACmB;AACnB,SAAO,OAAO,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAC3C;AAEO,SAAS,sBACd,cACA,SACe;AACf,SAAO,aAAa,OAAO,CAAC,OAAO,GAAG,YAAY,OAAO;AAC3D;"}
1
+ {"version":3,"file":"resolveHelpers.js","sources":["../../../../../src/modules/appCatalog/utils/resolveHelpers.ts"],"sourcesContent":["import type { Group, Person, Resource } from '@igstack/app-catalog-backend-core'\n\nexport function getPersonBySlug(\n persons: Person[],\n slug: string,\n): Person | undefined {\n return persons.find((p) => p.slug === slug)\n}\n\nexport function getGroupBySlug(\n groups: Group[],\n slug: string,\n): Group | undefined {\n return groups.find((g) => g.slug === slug)\n}\n\nexport function getChildResources(\n resources: Resource[],\n parentSlug: string,\n): Resource[] {\n return resources.filter((r) => r.parentSlug === parentSlug)\n}\n\nexport function getRootResources(resources: Resource[]): Resource[] {\n return resources.filter((r) => !r.parentSlug)\n}\n\n/** @deprecated Use getChildResources instead */\nexport const getSubResourcesForApp = getChildResources\n"],"names":[],"mappings":"AAEO,SAAS,gBACd,SACA,MACoB;AACpB,SAAO,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAC5C;AAEO,SAAS,eACd,QACA,MACmB;AACnB,SAAO,OAAO,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAC3C;AAEO,SAAS,kBACd,WACA,YACY;AACZ,SAAO,UAAU,OAAO,CAAC,MAAM,EAAE,eAAe,UAAU;AAC5D;"}
@@ -1,4 +1,4 @@
1
- import { AppForCatalog, SubResource } from '@igstack/app-catalog-backend-core';
1
+ import { Resource } from '@igstack/app-catalog-backend-core';
2
2
  export interface SearchMatch {
3
3
  /** Field where the match occurred */
4
4
  field: 'displayName' | 'abbreviation' | 'nicknames' | 'slug' | 'tags' | 'teams' | 'description' | 'subResource';
@@ -6,11 +6,14 @@ export interface SearchMatch {
6
6
  type: 'exact' | 'prefix' | 'contains';
7
7
  }
8
8
  export interface SearchResult {
9
- app: AppForCatalog;
9
+ app: Resource;
10
10
  match: SearchMatch;
11
11
  }
12
12
  /**
13
- * Search and sort apps by relevance with highlighting support.
13
+ * Search and sort resources by relevance with highlighting support.
14
+ * Only root resources (no parentSlug) are scored and returned.
15
+ * Child resources (with parentSlug) contribute to their parent's score.
16
+ *
14
17
  * Priority order:
15
18
  * 0. Exact match in abbreviation
16
19
  * 1. Exact match in displayName
@@ -27,11 +30,11 @@ export interface SearchResult {
27
30
  * 12. Teams
28
31
  * 13. Description
29
32
  *
30
- * @param apps - Array of apps to search
33
+ * @param resources - Array of all resources (root + children)
31
34
  * @param searchQuery - Search query string
32
- * @returns Filtered and sorted array of apps with search results
35
+ * @returns Filtered and sorted array of root resources
33
36
  */
34
- export declare function searchApps(apps: AppForCatalog[], searchQuery: string, subResources?: SubResource[]): AppForCatalog[];
37
+ export declare function searchResources(resources: Resource[], searchQuery: string): Resource[];
35
38
  /**
36
39
  * Highlight matching text in a string
37
40
  * @param text - Text to highlight
@@ -42,3 +45,5 @@ export declare function highlightText(text: string, query: string): {
42
45
  text: string;
43
46
  highlight: boolean;
44
47
  }[];
48
+ /** @deprecated Use searchResources instead */
49
+ export declare const searchApps: typeof searchResources;
@@ -1,19 +1,20 @@
1
- function searchApps(apps, searchQuery, subResources) {
1
+ function searchResources(resources, searchQuery) {
2
2
  const normalizedQuery = searchQuery.trim().toLowerCase();
3
+ const rootResources = resources.filter((r) => !r.parentSlug);
3
4
  if (normalizedQuery === "") {
4
- return apps;
5
+ return rootResources;
5
6
  }
6
7
  const queryTerms = normalizedQuery.split(/\s+/).filter(Boolean);
7
8
  const allTermsMatch = (text) => queryTerms.every((term) => text.includes(term));
8
- const subResourcesByApp = /* @__PURE__ */ new Map();
9
- if (subResources) {
10
- for (const sr of subResources) {
11
- const list = subResourcesByApp.get(sr.appSlug) ?? [];
12
- list.push(sr);
13
- subResourcesByApp.set(sr.appSlug, list);
9
+ const childrenByParent = /* @__PURE__ */ new Map();
10
+ for (const r of resources) {
11
+ if (r.parentSlug) {
12
+ const list = childrenByParent.get(r.parentSlug) ?? [];
13
+ list.push(r);
14
+ childrenByParent.set(r.parentSlug, list);
14
15
  }
15
16
  }
16
- const scoredApps = apps.map((app) => {
17
+ const scoredApps = rootResources.map((app) => {
17
18
  var _a, _b, _c, _d, _e, _f, _g;
18
19
  const name = app.displayName.toLowerCase();
19
20
  const abbreviation = ((_a = app.abbreviation) == null ? void 0 : _a.toLowerCase()) || "";
@@ -63,10 +64,10 @@ function searchApps(apps, searchQuery, subResources) {
63
64
  if (allTermsMatch(description)) {
64
65
  return { app, match: { field: "description", type: "contains" } };
65
66
  }
66
- const appSubResources = subResourcesByApp.get(app.slug);
67
- if (appSubResources) {
68
- const subMatch = appSubResources.some(
69
- (sr) => allTermsMatch(sr.displayName.toLowerCase()) || sr.aliases.some((a) => allTermsMatch(a.toLowerCase())) || (sr.description ? allTermsMatch(sr.description.toLowerCase()) : false)
67
+ const children = childrenByParent.get(app.slug);
68
+ if (children) {
69
+ const subMatch = children.some(
70
+ (r) => allTermsMatch(r.displayName.toLowerCase()) || (r.aliases ?? []).some((a) => allTermsMatch(a.toLowerCase())) || (r.description ? allTermsMatch(r.description.toLowerCase()) : false)
70
71
  );
71
72
  if (subMatch) {
72
73
  return { app, match: { field: "subResource", type: "contains" } };
@@ -138,6 +139,6 @@ function highlightText(text, query) {
138
139
  }
139
140
  export {
140
141
  highlightText,
141
- searchApps
142
+ searchResources
142
143
  };
143
144
  //# sourceMappingURL=searchApps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"searchApps.js","sources":["../../../../../src/modules/appCatalog/utils/searchApps.ts"],"sourcesContent":["import type {\n AppForCatalog,\n SubResource,\n} from '@igstack/app-catalog-backend-core'\n\nexport interface SearchMatch {\n /** Field where the match occurred */\n field:\n | 'displayName'\n | 'abbreviation'\n | 'nicknames'\n | 'slug'\n | 'tags'\n | 'teams'\n | 'description'\n | 'subResource'\n /** Type of match */\n type: 'exact' | 'prefix' | 'contains'\n}\n\nexport interface SearchResult {\n app: AppForCatalog\n match: SearchMatch\n}\n\n/**\n * Search and sort apps by relevance with highlighting support.\n * Priority order:\n * 0. Exact match in abbreviation\n * 1. Exact match in displayName\n * 2. Exact match in nickname\n * 3. Prefix match in abbreviation\n * 4. Prefix match in displayName\n * 5. Prefix match in nickname\n * 6. Exact match in tags\n * 7. Prefix match in tags\n * 8. Contains match in abbreviation\n * 9. Contains match in displayName\n * 10. Contains match in nickname\n * 11. Contains match in tags\n * 12. Teams\n * 13. Description\n *\n * @param apps - Array of apps to search\n * @param searchQuery - Search query string\n * @returns Filtered and sorted array of apps with search results\n */\nexport function searchApps(\n apps: AppForCatalog[],\n searchQuery: string,\n subResources?: SubResource[],\n): AppForCatalog[] {\n const normalizedQuery = searchQuery.trim().toLowerCase()\n\n if (normalizedQuery === '') {\n return apps\n }\n\n // Split query into terms for multi-word matching (AND logic)\n const queryTerms = normalizedQuery.split(/\\s+/).filter(Boolean)\n\n // Helper: all terms appear in the text (order-independent)\n const allTermsMatch = (text: string): boolean =>\n queryTerms.every((term) => text.includes(term))\n\n // Build sub-resource lookup: appSlug -> SubResource[]\n const subResourcesByApp = new Map<string, SubResource[]>()\n if (subResources) {\n for (const sr of subResources) {\n const list = subResourcesByApp.get(sr.appSlug) ?? []\n list.push(sr)\n subResourcesByApp.set(sr.appSlug, list)\n }\n }\n\n // Filter and score apps\n const scoredApps = apps\n .map((app): SearchResult | null => {\n const name = app.displayName.toLowerCase()\n const abbreviation = app.abbreviation?.toLowerCase() || ''\n const nicknames = app.nicknames?.map((n) => n.toLowerCase()) || []\n const description = app.description?.toLowerCase() || ''\n const tags = app.tags?.join(' ').toLowerCase() || ''\n const teams = app.teams?.join(' ').toLowerCase() || ''\n\n // Check exact matches first - prioritize abbreviation over displayName\n if (abbreviation && abbreviation === normalizedQuery) {\n return { app, match: { field: 'abbreviation', type: 'exact' } }\n }\n if (name === normalizedQuery) {\n return { app, match: { field: 'displayName', type: 'exact' } }\n }\n if (nicknames.some((n) => n === normalizedQuery)) {\n return { app, match: { field: 'nicknames', type: 'exact' } }\n }\n\n // Check prefix matches\n if (abbreviation && abbreviation.startsWith(normalizedQuery)) {\n return { app, match: { field: 'abbreviation', type: 'prefix' } }\n }\n if (name.startsWith(normalizedQuery)) {\n return { app, match: { field: 'displayName', type: 'prefix' } }\n }\n if (nicknames.some((n) => n.startsWith(normalizedQuery))) {\n return { app, match: { field: 'nicknames', type: 'prefix' } }\n }\n\n // Check exact match in tags (any tag exactly matches query)\n if (app.tags?.some((tag) => tag.toLowerCase() === normalizedQuery)) {\n return { app, match: { field: 'tags', type: 'exact' } }\n }\n\n // Check tags - prefix match (any tag starts with query)\n if (\n app.tags?.some((tag) => tag.toLowerCase().startsWith(normalizedQuery))\n ) {\n return { app, match: { field: 'tags', type: 'prefix' } }\n }\n\n // Check contains matches - prioritize abbreviation over displayName\n if (abbreviation && abbreviation.includes(normalizedQuery)) {\n return { app, match: { field: 'abbreviation', type: 'contains' } }\n }\n if (name.includes(normalizedQuery)) {\n return { app, match: { field: 'displayName', type: 'contains' } }\n }\n if (nicknames.some((n) => n.includes(normalizedQuery))) {\n return { app, match: { field: 'nicknames', type: 'contains' } }\n }\n\n // Check tags - contains match\n if (tags.includes(normalizedQuery)) {\n return { app, match: { field: 'tags', type: 'contains' } }\n }\n\n // Check teams (multi-word)\n if (allTermsMatch(teams)) {\n return { app, match: { field: 'teams', type: 'contains' } }\n }\n\n // Check description (multi-word)\n if (allTermsMatch(description)) {\n return { app, match: { field: 'description', type: 'contains' } }\n }\n\n // Check sub-resources (name, aliases, description) — supports multi-word queries\n const appSubResources = subResourcesByApp.get(app.slug)\n if (appSubResources) {\n const subMatch = appSubResources.some(\n (sr) =>\n allTermsMatch(sr.displayName.toLowerCase()) ||\n sr.aliases.some((a) => allTermsMatch(a.toLowerCase())) ||\n (sr.description\n ? allTermsMatch(sr.description.toLowerCase())\n : false),\n )\n if (subMatch) {\n return { app, match: { field: 'subResource', type: 'contains' } }\n }\n }\n\n // No match found\n return null\n })\n .filter((item): item is SearchResult => item !== null)\n\n // Calculate numeric scores for sorting\n const scoreMap = new Map<string, number>()\n scoredApps.forEach(({ app, match }) => {\n let score = 0\n\n // Exact matches: 0-2 (abbreviation, displayName, nicknames)\n if (match.type === 'exact') {\n if (match.field === 'abbreviation') score = 0\n else if (match.field === 'displayName') score = 1\n else if (match.field === 'nicknames') score = 2\n else if (match.field === 'tags') score = 6\n else score = 999\n }\n // Prefix matches: 3-5 (abbreviation, displayName, nicknames), 7 (tags)\n else if (match.type === 'prefix') {\n if (match.field === 'abbreviation') score = 3\n else if (match.field === 'displayName') score = 4\n else if (match.field === 'nicknames') score = 5\n else if (match.field === 'tags') score = 7\n else score = 999\n }\n // Contains matches\n else {\n if (match.field === 'abbreviation') score = 8\n else if (match.field === 'displayName') score = 9\n else if (match.field === 'nicknames') score = 10\n else if (match.field === 'tags') score = 11\n else if (match.field === 'teams') score = 12\n else if (match.field === 'subResource') score = 13\n else score = 14 // description\n }\n\n scoreMap.set(app.id, score)\n })\n\n // Sort by score (ascending - lower score = higher priority)\n scoredApps.sort((a, b) => {\n const scoreA = scoreMap.get(a.app.id) ?? 999\n const scoreB = scoreMap.get(b.app.id) ?? 999\n\n if (scoreA !== scoreB) {\n return scoreA - scoreB\n }\n // If same score, sort alphabetically by display name\n return a.app.displayName.localeCompare(b.app.displayName)\n })\n\n return scoredApps.map((item) => item.app)\n}\n\n/**\n * Highlight matching text in a string\n * @param text - Text to highlight\n * @param query - Search query\n * @returns Array of text segments with highlight flags\n */\nexport function highlightText(\n text: string,\n query: string,\n): { text: string; highlight: boolean }[] {\n if (!query.trim()) {\n return [{ text, highlight: false }]\n }\n\n const normalizedQuery = query.trim().toLowerCase()\n const lowerText = text.toLowerCase()\n const index = lowerText.indexOf(normalizedQuery)\n\n if (index === -1) {\n return [{ text, highlight: false }]\n }\n\n const segments: { text: string; highlight: boolean }[] = []\n\n // Text before match\n if (index > 0) {\n segments.push({ text: text.slice(0, index), highlight: false })\n }\n\n // Matched text\n segments.push({\n text: text.slice(index, index + normalizedQuery.length),\n highlight: true,\n })\n\n // Text after match\n if (index + normalizedQuery.length < text.length) {\n segments.push({\n text: text.slice(index + normalizedQuery.length),\n highlight: false,\n })\n }\n\n return segments\n}\n"],"names":[],"mappings":"AA+CO,SAAS,WACd,MACA,aACA,cACiB;AACjB,QAAM,kBAAkB,YAAY,KAAA,EAAO,YAAA;AAE3C,MAAI,oBAAoB,IAAI;AAC1B,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,gBAAgB,MAAM,KAAK,EAAE,OAAO,OAAO;AAG9D,QAAM,gBAAgB,CAAC,SACrB,WAAW,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC;AAGhD,QAAM,wCAAwB,IAAA;AAC9B,MAAI,cAAc;AACh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aAAO,SAAS;AAAA,IAClB;AAEA,WAAO,EAAE,IAAI,YAAY,cAAc,EAAE,IAAI,WAAW;AAAA,EAC1D,CAAC;AAED,SAAO,WAAW,IAAI,CAAC,SAAS,KAAK,GAAG;AAC1C;AAQO,SAAS,cACd,MACA,OACwC;AACxC,MAAI,CAAC,MAAM,QAAQ;AACjB,WAAO,CAAC,EAAE,MAAM,WAAW,OAAO;AAAA,EACpC;AAEA,QAAM,kBAAkB,MAAM,KAAA,EAAO,YAAA;AACrC,QAAM,YAAY,KAAK,YAAA;AACvB,QAAM,QAAQ,UAAU,QAAQ,eAAe;AAE/C,MAAI,UAAU,IAAI;AAChB,WAAO,CAAC,EAAE,MAAM,WAAW,OAAO;AAAA,EACpC;AAEA,QAAM,WAAmD,CAAA;AAGzD,MAAI,QAAQ,GAAG;AACb,aAAS,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,KAAK,GAAG,WAAW,OAAO;AAAA,EAChE;AAGA,WAAS,KAAK;AAAA,IACZ,MAAM,KAAK,MAAM,OAAO,QAAQ,gBAAgB,MAAM;AAAA,IACtD,WAAW;AAAA,EAAA,CACZ;AAGD,MAAI,QAAQ,gBAAgB,SAAS,KAAK,QAAQ;AAChD,aAAS,KAAK;AAAA,MACZ,MAAM,KAAK,MAAM,QAAQ,gBAAgB,MAAM;AAAA,MAC/C,WAAW;AAAA,IAAA,CACZ;AAAA,EACH;AAEA,SAAO;AACT;"}
1
+ {"version":3,"file":"searchApps.js","sources":["../../../../../src/modules/appCatalog/utils/searchApps.ts"],"sourcesContent":["import type { Resource } from '@igstack/app-catalog-backend-core'\n\nexport interface SearchMatch {\n /** Field where the match occurred */\n field:\n | 'displayName'\n | 'abbreviation'\n | 'nicknames'\n | 'slug'\n | 'tags'\n | 'teams'\n | 'description'\n | 'subResource'\n /** Type of match */\n type: 'exact' | 'prefix' | 'contains'\n}\n\nexport interface SearchResult {\n app: Resource\n match: SearchMatch\n}\n\n/**\n * Search and sort resources by relevance with highlighting support.\n * Only root resources (no parentSlug) are scored and returned.\n * Child resources (with parentSlug) contribute to their parent's score.\n *\n * Priority order:\n * 0. Exact match in abbreviation\n * 1. Exact match in displayName\n * 2. Exact match in nickname\n * 3. Prefix match in abbreviation\n * 4. Prefix match in displayName\n * 5. Prefix match in nickname\n * 6. Exact match in tags\n * 7. Prefix match in tags\n * 8. Contains match in abbreviation\n * 9. Contains match in displayName\n * 10. Contains match in nickname\n * 11. Contains match in tags\n * 12. Teams\n * 13. Description\n *\n * @param resources - Array of all resources (root + children)\n * @param searchQuery - Search query string\n * @returns Filtered and sorted array of root resources\n */\nexport function searchResources(\n resources: Resource[],\n searchQuery: string,\n): Resource[] {\n const normalizedQuery = searchQuery.trim().toLowerCase()\n\n // Separate root resources from children\n const rootResources = resources.filter((r) => !r.parentSlug)\n\n if (normalizedQuery === '') {\n return rootResources\n }\n\n // Split query into terms for multi-word matching (AND logic)\n const queryTerms = normalizedQuery.split(/\\s+/).filter(Boolean)\n\n // Helper: all terms appear in the text (order-independent)\n const allTermsMatch = (text: string): boolean =>\n queryTerms.every((term) => text.includes(term))\n\n // Build children lookup: parentSlug -> Resource[]\n const childrenByParent = new Map<string, Resource[]>()\n for (const r of resources) {\n if (r.parentSlug) {\n const list = childrenByParent.get(r.parentSlug) ?? []\n list.push(r)\n childrenByParent.set(r.parentSlug, list)\n }\n }\n\n // Filter and score root resources\n const scoredApps = rootResources\n .map((app): SearchResult | null => {\n const name = app.displayName.toLowerCase()\n const abbreviation = app.abbreviation?.toLowerCase() || ''\n const nicknames = app.nicknames?.map((n) => n.toLowerCase()) || []\n const description = app.description?.toLowerCase() || ''\n const tags = app.tags?.join(' ').toLowerCase() || ''\n const teams = app.teams?.join(' ').toLowerCase() || ''\n\n // Check exact matches first - prioritize abbreviation over displayName\n if (abbreviation && abbreviation === normalizedQuery) {\n return { app, match: { field: 'abbreviation', type: 'exact' } }\n }\n if (name === normalizedQuery) {\n return { app, match: { field: 'displayName', type: 'exact' } }\n }\n if (nicknames.some((n) => n === normalizedQuery)) {\n return { app, match: { field: 'nicknames', type: 'exact' } }\n }\n\n // Check prefix matches\n if (abbreviation && abbreviation.startsWith(normalizedQuery)) {\n return { app, match: { field: 'abbreviation', type: 'prefix' } }\n }\n if (name.startsWith(normalizedQuery)) {\n return { app, match: { field: 'displayName', type: 'prefix' } }\n }\n if (nicknames.some((n) => n.startsWith(normalizedQuery))) {\n return { app, match: { field: 'nicknames', type: 'prefix' } }\n }\n\n // Check exact match in tags (any tag exactly matches query)\n if (app.tags?.some((tag) => tag.toLowerCase() === normalizedQuery)) {\n return { app, match: { field: 'tags', type: 'exact' } }\n }\n\n // Check tags - prefix match (any tag starts with query)\n if (\n app.tags?.some((tag) => tag.toLowerCase().startsWith(normalizedQuery))\n ) {\n return { app, match: { field: 'tags', type: 'prefix' } }\n }\n\n // Check contains matches - prioritize abbreviation over displayName\n if (abbreviation && abbreviation.includes(normalizedQuery)) {\n return { app, match: { field: 'abbreviation', type: 'contains' } }\n }\n if (name.includes(normalizedQuery)) {\n return { app, match: { field: 'displayName', type: 'contains' } }\n }\n if (nicknames.some((n) => n.includes(normalizedQuery))) {\n return { app, match: { field: 'nicknames', type: 'contains' } }\n }\n\n // Check tags - contains match\n if (tags.includes(normalizedQuery)) {\n return { app, match: { field: 'tags', type: 'contains' } }\n }\n\n // Check teams (multi-word)\n if (allTermsMatch(teams)) {\n return { app, match: { field: 'teams', type: 'contains' } }\n }\n\n // Check description (multi-word)\n if (allTermsMatch(description)) {\n return { app, match: { field: 'description', type: 'contains' } }\n }\n\n // Check child resources (name, aliases, description) — supports multi-word queries\n const children = childrenByParent.get(app.slug)\n if (children) {\n const subMatch = children.some(\n (r) =>\n allTermsMatch(r.displayName.toLowerCase()) ||\n (r.aliases ?? []).some((a) => allTermsMatch(a.toLowerCase())) ||\n (r.description\n ? allTermsMatch(r.description.toLowerCase())\n : false),\n )\n if (subMatch) {\n return { app, match: { field: 'subResource', type: 'contains' } }\n }\n }\n\n // No match found\n return null\n })\n .filter((item): item is SearchResult => item !== null)\n\n // Calculate numeric scores for sorting\n const scoreMap = new Map<string, number>()\n scoredApps.forEach(({ app, match }) => {\n let score = 0\n\n // Exact matches: 0-2 (abbreviation, displayName, nicknames)\n if (match.type === 'exact') {\n if (match.field === 'abbreviation') score = 0\n else if (match.field === 'displayName') score = 1\n else if (match.field === 'nicknames') score = 2\n else if (match.field === 'tags') score = 6\n else score = 999\n }\n // Prefix matches: 3-5 (abbreviation, displayName, nicknames), 7 (tags)\n else if (match.type === 'prefix') {\n if (match.field === 'abbreviation') score = 3\n else if (match.field === 'displayName') score = 4\n else if (match.field === 'nicknames') score = 5\n else if (match.field === 'tags') score = 7\n else score = 999\n }\n // Contains matches\n else {\n if (match.field === 'abbreviation') score = 8\n else if (match.field === 'displayName') score = 9\n else if (match.field === 'nicknames') score = 10\n else if (match.field === 'tags') score = 11\n else if (match.field === 'teams') score = 12\n else if (match.field === 'subResource') score = 13\n else score = 14 // description\n }\n\n scoreMap.set(app.id, score)\n })\n\n // Sort by score (ascending - lower score = higher priority)\n scoredApps.sort((a, b) => {\n const scoreA = scoreMap.get(a.app.id) ?? 999\n const scoreB = scoreMap.get(b.app.id) ?? 999\n\n if (scoreA !== scoreB) {\n return scoreA - scoreB\n }\n // If same score, sort alphabetically by display name\n return a.app.displayName.localeCompare(b.app.displayName)\n })\n\n return scoredApps.map((item) => item.app)\n}\n\n/**\n * Highlight matching text in a string\n * @param text - Text to highlight\n * @param query - Search query\n * @returns Array of text segments with highlight flags\n */\nexport function highlightText(\n text: string,\n query: string,\n): { text: string; highlight: boolean }[] {\n if (!query.trim()) {\n return [{ text, highlight: false }]\n }\n\n const normalizedQuery = query.trim().toLowerCase()\n const lowerText = text.toLowerCase()\n const index = lowerText.indexOf(normalizedQuery)\n\n if (index === -1) {\n return [{ text, highlight: false }]\n }\n\n const segments: { text: string; highlight: boolean }[] = []\n\n // Text before match\n if (index > 0) {\n segments.push({ text: text.slice(0, index), highlight: false })\n }\n\n // Matched text\n segments.push({\n text: text.slice(index, index + normalizedQuery.length),\n highlight: true,\n })\n\n // Text after match\n if (index + normalizedQuery.length < text.length) {\n segments.push({\n text: text.slice(index + normalizedQuery.length),\n highlight: false,\n })\n }\n\n return segments\n}\n\n/** @deprecated Use searchResources instead */\nexport const searchApps = searchResources\n"],"names":[],"mappings":"AA+CO,SAAS,gBACd,WACA,aACY;AACZ,QAAM,kBAAkB,YAAY,KAAA,EAAO,YAAA;AAG3C,QAAM,gBAAgB,UAAU,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU;AAE3D,MAAI,oBAAoB,IAAI;AAC1B,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,gBAAgB,MAAM,KAAK,EAAE,OAAO,OAAO;AAG9D,QAAM,gBAAgB,CAAC,SACrB,WAAW,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC;AAGhD,QAAM,uCAAuB,IAAA;AAC7B,aAAW,KAAK,WAAW;AACzB,QAAI,EAAE,YAAY;AAChB,YAAM,OAAO,iBAAiB,IAAI,EAAE,UAAU,KAAK,CAAA;AACnD,WAAK,KAAK,CAAC;AACX,uBAAiB,IAAI,EAAE,YAAY,IAAI;AAAA,IACzC;AAAA,EACF;AAGA,QAAM,aAAa,cAChB,IAAI,CAAC,QAA6B;AAhChC;AAiCD,UAAM,OAAO,IAAI,YAAY,YAAA;AAC7B,UAAM,iBAAe,SAAI,iBAAJ,mBAAkB,kBAAiB;AACxD,UAAM,cAAY,SAAI,cAAJ,mBAAe,IAAI,CAAC,MAAM,EAAE,YAAA,OAAkB,CAAA;AAChE,UAAM,gBAAc,SAAI,gBAAJ,mBAAiB,kBAAiB;AACtD,UAAM,SAAO,SAAI,SAAJ,mBAAU,KAAK,KAAK,kBAAiB;AAClD,UAAM,UAAQ,SAAI,UAAJ,mBAAW,KAAK,KAAK,kBAAiB;AAGpD,QAAI,gBAAgB,iBAAiB,iBAAiB;AACpD,aAAO,EAAE,KAAK,OAAO,EAAE,OAAO,gBAAgB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AAO,QAAQ,gBAAgB,MAAM;AAAA,IACtD,WAAW;AAAA,EAAA,CACZ;AAGD,MAAI,QAAQ,gBAAgB,SAAS,KAAK,QAAQ;AAChD,aAAS,KAAK;AAAA,MACZ,MAAM,KAAK,MAAM,QAAQ,gBAAgB,MAAM;AAAA,MAC/C,WAAW;AAAA,IAAA,CACZ;AAAA,EACH;AAEA,SAAO;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igstack/app-catalog-frontend-core",
3
- "version": "0.3.1-alpha-20260405015231",
3
+ "version": "0.3.1-alpha-20260406011911",
4
4
  "description": "Frontend core library for App Catalog",
5
5
  "homepage": "https://github.com/lislon/app-catalog",
6
6
  "repository": {
@@ -134,8 +134,8 @@
134
134
  "vite-plugin-static-copy": "^3.1.4",
135
135
  "vite-plugin-svgr": "^4.2.0",
136
136
  "vitest": "^4.1.2",
137
- "@igstack/app-catalog-backend-core": "0.3.1-alpha-20260405015231",
138
- "@igstack/app-catalog-shared-core": "0.3.1-alpha-20260405015231"
137
+ "@igstack/app-catalog-backend-core": "0.3.1-alpha-20260406011911",
138
+ "@igstack/app-catalog-shared-core": "0.3.1-alpha-20260406011911"
139
139
  },
140
140
  "peerDependencies": {
141
141
  "react": "19.1.2",
@@ -125,19 +125,19 @@ describe('App Catalog Integration', () => {
125
125
  backendCfg.withSubResource({
126
126
  appSlug: app.slug,
127
127
  displayName: 'acct-prod',
128
- tierSlug: 'prod',
128
+ tier: 'prod',
129
129
  ownerPersonSlug: 'jsmith',
130
130
  })
131
131
  backendCfg.withSubResource({
132
132
  appSlug: app.slug,
133
133
  displayName: 'acct-dev',
134
- tierSlug: 'dev',
134
+ tier: 'dev',
135
135
  ownerPersonSlug: 'jdoe',
136
136
  })
137
137
  backendCfg.withSubResource({
138
138
  appSlug: app.slug,
139
139
  displayName: 'acct-staging',
140
- tierSlug: 'staging',
140
+ tier: 'staging',
141
141
  })
142
142
  }),
143
143
  )
@@ -1,14 +1,14 @@
1
- import type { AppForCatalog } from '@igstack/app-catalog-backend-core'
1
+ import type { Resource } from '@igstack/app-catalog-backend-core'
2
2
  import type { MockDb } from '../mock-backend/MockDb'
3
3
 
4
4
  export class MockBackendVerifier {
5
5
  constructor(readonly db: MockDb) {}
6
6
 
7
- apps(): AppForCatalog[] {
8
- return this.db.getApps()
7
+ apps(): Resource[] {
8
+ return this.db.getResources()
9
9
  }
10
10
 
11
- getApp(slug: string): AppForCatalog {
12
- return this.db.getApp(slug)
11
+ getApp(slug: string): Resource {
12
+ return this.db.getResource(slug)
13
13
  }
14
14
  }
@@ -1,8 +1,7 @@
1
1
  import type {
2
2
  AppApprovalMethod,
3
- AppForCatalog,
4
3
  GroupingTagDefinition,
5
- SubResource,
4
+ Resource,
6
5
  } from '@igstack/app-catalog-backend-core'
7
6
  import type { MockDb } from './MockDb'
8
7
  import type { MockUserContext, UserConfig } from './MockUserContext'
@@ -24,9 +23,9 @@ export class MockBackendConfigurer {
24
23
  readonly userContext: MockUserContext,
25
24
  ) {}
26
25
 
27
- withApp(overrides?: Partial<AppForCatalog>): AppForCatalog {
26
+ withApp(overrides?: Partial<Resource>): Resource {
28
27
  const id = overrides?.id ?? nextId()
29
- const app: AppForCatalog = {
28
+ const app: Resource = {
30
29
  id,
31
30
  slug: overrides?.slug ?? nextSlug(),
32
31
  displayName: overrides?.displayName ?? `App ${counter}`,
@@ -35,7 +34,7 @@ export class MockBackendConfigurer {
35
34
  screenshotIds: overrides?.screenshotIds ?? [],
36
35
  ...overrides,
37
36
  }
38
- this.db.upsertApp(app)
37
+ this.db.upsertResource(app)
39
38
  return app
40
39
  }
41
40
 
@@ -67,17 +66,22 @@ export class MockBackendConfigurer {
67
66
  }
68
67
 
69
68
  withSubResource(
70
- overrides: Partial<SubResource> & { appSlug: string },
71
- ): SubResource {
72
- const sr: SubResource = {
73
- slug: overrides.slug ?? `sr-${nextId()}`,
69
+ overrides: Partial<Resource> & { appSlug: string },
70
+ ): Resource {
71
+ const appSlug = overrides.appSlug
72
+ const id = overrides.id ?? nextId()
73
+ const resource: Resource = {
74
+ id,
75
+ slug: overrides.slug ?? `sr-${id}`,
74
76
  displayName: overrides.displayName ?? `Sub Resource ${counter}`,
75
77
  aliases: overrides.aliases ?? [],
76
78
  accessMaintainerGroupSlugs: overrides.accessMaintainerGroupSlugs ?? [],
77
- ...overrides,
79
+ parentSlug: appSlug,
80
+ tier: overrides.tier,
81
+ ownerPersonSlug: overrides.ownerPersonSlug,
78
82
  }
79
- this.db.addSubResource(sr)
80
- return sr
83
+ this.db.upsertResource(resource)
84
+ return resource
81
85
  }
82
86
 
83
87
  withUser(overrides: Partial<UserConfig>): void {
@@ -1,33 +1,49 @@
1
1
  import type {
2
2
  AppApprovalMethod,
3
3
  AppCatalogData,
4
- AppForCatalog,
5
4
  GroupingTagDefinition,
6
- SubResource,
5
+ Resource,
7
6
  } from '@igstack/app-catalog-backend-core'
8
7
 
9
8
  export class MockDb {
10
- apps: AppForCatalog[] = []
9
+ resources: Resource[] = []
11
10
  tagsDefinitions: GroupingTagDefinition[] = []
12
11
  approvalMethods: AppApprovalMethod[] = []
13
- subResources: SubResource[] = []
14
12
 
15
- upsertApp(app: AppForCatalog): void {
16
- this.apps = [...this.apps.filter((a) => a.id !== app.id), app]
13
+ upsertResource(resource: Resource): void {
14
+ this.resources = [
15
+ ...this.resources.filter((r) => r.id !== resource.id),
16
+ resource,
17
+ ]
18
+ }
19
+
20
+ /** @deprecated Use upsertResource */
21
+ upsertApp(app: Resource): void {
22
+ this.upsertResource(app)
23
+ }
24
+
25
+ getResources(): Resource[] {
26
+ return this.resources
17
27
  }
18
28
 
19
- getApps(): AppForCatalog[] {
20
- return this.apps
29
+ /** @deprecated Use getResources */
30
+ getApps(): Resource[] {
31
+ return this.getResources()
21
32
  }
22
33
 
23
- getApp(slug: string): AppForCatalog {
24
- const app = this.apps.find((a) => a.slug === slug)
25
- if (!app) {
34
+ getResource(slug: string): Resource {
35
+ const resource = this.resources.find((r) => r.slug === slug)
36
+ if (!resource) {
26
37
  throw new Error(
27
- `MockDb: app with slug "${slug}" not found. Available: ${this.apps.map((a) => a.slug).join(', ')}`,
38
+ `MockDb: resource with slug "${slug}" not found. Available: ${this.resources.map((r) => r.slug).join(', ')}`,
28
39
  )
29
40
  }
30
- return app
41
+ return resource
42
+ }
43
+
44
+ /** @deprecated Use getResource */
45
+ getApp(slug: string): Resource {
46
+ return this.getResource(slug)
31
47
  }
32
48
 
33
49
  setTagDefinitions(defs: GroupingTagDefinition[]): void {
@@ -38,21 +54,13 @@ export class MockDb {
38
54
  this.approvalMethods = methods
39
55
  }
40
56
 
41
- addSubResource(sr: SubResource): void {
42
- this.subResources = [
43
- ...this.subResources.filter((s) => s.slug !== sr.slug),
44
- sr,
45
- ]
46
- }
47
-
48
57
  getAppCatalogData(): AppCatalogData {
49
58
  return {
50
- apps: this.apps,
59
+ resources: this.resources,
51
60
  tagsDefinitions: this.tagsDefinitions,
52
61
  approvalMethods: this.approvalMethods,
53
62
  persons: [],
54
63
  groups: [],
55
- subResources: this.subResources,
56
64
  }
57
65
  }
58
66
  }
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react'
2
2
  import { describe, expect, it } from 'vitest'
3
3
  import '@testing-library/jest-dom/vitest'
4
4
 
5
- import type { AppForCatalog } from '@igstack/app-catalog-backend-core'
5
+ import type { Resource } from '@igstack/app-catalog-backend-core'
6
6
  import { AppDetailModal } from '~/modules/appCatalog/ui/components/AppDetailModal'
7
7
  import { AppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'
8
8
  import type { AppCatalogContextIface } from '~/modules/appCatalog/context/AppCatalogContext'
@@ -10,16 +10,15 @@ import type { AppCatalogContextIface } from '~/modules/appCatalog/context/AppCat
10
10
  // Minimal context value — ScreenshotPreview doesn't use context directly,
11
11
  // but AccessSection (sibling in AppDetailModal) does.
12
12
  const minimalContext: AppCatalogContextIface = {
13
- apps: [],
13
+ resources: [],
14
14
  isLoadingApps: false,
15
15
  tagsDefinitions: [],
16
16
  approvalMethods: [],
17
17
  persons: [],
18
18
  groups: [],
19
- subResources: [],
20
19
  }
21
20
 
22
- function renderWithContext(app: AppForCatalog) {
21
+ function renderWithContext(app: Resource) {
23
22
  return render(
24
23
  <AppCatalogContext value={minimalContext}>
25
24
  <AppDetailModal app={app} isOpen={true} onClose={() => {}} />
@@ -27,7 +26,7 @@ function renderWithContext(app: AppForCatalog) {
27
26
  )
28
27
  }
29
28
 
30
- function makeApp(screenshotIds: string[]): AppForCatalog {
29
+ function makeApp(screenshotIds: string[]): Resource {
31
30
  return {
32
31
  id: 'app-1',
33
32
  slug: 'test-app',
@@ -1,13 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import type {
3
- AppForCatalog,
4
- SubResource,
5
- } from '@igstack/app-catalog-backend-core'
6
- import { searchApps } from '~/modules/appCatalog/utils/searchApps'
2
+ import type { Resource } from '@igstack/app-catalog-backend-core'
3
+ import { searchResources } from '~/modules/appCatalog/utils/searchApps'
7
4
 
8
- function makeApp(
9
- overrides: Partial<AppForCatalog> & { slug: string },
10
- ): AppForCatalog {
5
+ function makeApp(overrides: Partial<Resource> & { slug: string }): Resource {
11
6
  return {
12
7
  id: overrides.slug,
13
8
  displayName: overrides.slug,
@@ -15,10 +10,11 @@ function makeApp(
15
10
  }
16
11
  }
17
12
 
18
- function makeSubResource(
19
- overrides: Partial<SubResource> & { slug: string; appSlug: string },
20
- ): SubResource {
13
+ function makeChildResource(
14
+ overrides: Partial<Resource> & { slug: string; parentSlug: string },
15
+ ): Resource {
21
16
  return {
17
+ id: overrides.slug,
22
18
  displayName: overrides.slug,
23
19
  aliases: [],
24
20
  accessMaintainerGroupSlugs: [],
@@ -26,8 +22,8 @@ function makeSubResource(
26
22
  }
27
23
  }
28
24
 
29
- describe('searchApps', () => {
30
- const apps: AppForCatalog[] = [
25
+ describe('searchResources', () => {
26
+ const apps: Resource[] = [
31
27
  makeApp({
32
28
  slug: 'jira',
33
29
  displayName: 'Jira',
@@ -41,51 +37,53 @@ describe('searchApps', () => {
41
37
  makeApp({ slug: 'slack', displayName: 'Slack', description: 'Messaging' }),
42
38
  ]
43
39
 
44
- it('returns all apps when query is empty', () => {
45
- expect(searchApps(apps, '')).toHaveLength(3)
40
+ it('returns all root apps when query is empty', () => {
41
+ expect(searchResources(apps, '')).toHaveLength(3)
46
42
  })
47
43
 
48
44
  it('finds app by displayName', () => {
49
- const results = searchApps(apps, 'jira')
45
+ const results = searchResources(apps, 'jira')
50
46
  expect(results).toHaveLength(1)
51
47
  expect(results[0]!.slug).toBe('jira')
52
48
  })
53
49
 
54
- describe('sub-resource search', () => {
55
- const subResources: SubResource[] = [
56
- makeSubResource({
50
+ describe('child resource search', () => {
51
+ const childResources: Resource[] = [
52
+ makeChildResource({
57
53
  slug: 'aws-natera-pipelines-dev',
58
54
  displayName: 'natera-pipelines-biomarkers-ici-dev',
59
- appSlug: 'aws-console',
55
+ parentSlug: 'aws-console',
60
56
  aliases: ['043902793406'],
61
57
  }),
62
- makeSubResource({
58
+ makeChildResource({
63
59
  slug: 'aws-natera-infosec-dev',
64
60
  displayName: 'natera-infosec-dev',
65
- appSlug: 'aws-console',
61
+ parentSlug: 'aws-console',
66
62
  aliases: [],
67
63
  }),
68
64
  ]
69
65
 
70
- it('finds app by sub-resource displayName', () => {
71
- const results = searchApps(apps, 'pipelines biomarkers', subResources)
66
+ const allResources = [...apps, ...childResources]
67
+
68
+ it('finds app by child resource displayName', () => {
69
+ const results = searchResources(allResources, 'pipelines biomarkers')
72
70
  expect(results).toHaveLength(1)
73
71
  expect(results[0]!.slug).toBe('aws-console')
74
72
  })
75
73
 
76
- it('finds app by sub-resource alias (account ID)', () => {
77
- const results = searchApps(apps, '043902793406', subResources)
74
+ it('finds app by child resource alias (account ID)', () => {
75
+ const results = searchResources(allResources, '043902793406')
78
76
  expect(results).toHaveLength(1)
79
77
  expect(results[0]!.slug).toBe('aws-console')
80
78
  })
81
79
 
82
- it('does not match sub-resources when no subResources provided', () => {
83
- const results = searchApps(apps, '043902793406')
80
+ it('does not match child resources when none provided', () => {
81
+ const results = searchResources(apps, '043902793406')
84
82
  expect(results).toHaveLength(0)
85
83
  })
86
84
 
87
- it('direct app match ranks higher than sub-resource match', () => {
88
- const results = searchApps(apps, 'aws', subResources)
85
+ it('direct app match ranks higher than child resource match', () => {
86
+ const results = searchResources(allResources, 'aws')
89
87
  // 'aws-console' matches by displayName, should appear
90
88
  expect(results.length).toBeGreaterThanOrEqual(1)
91
89
  expect(results[0]!.slug).toBe('aws-console')
@@ -2,7 +2,7 @@ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'
2
2
  import { describe, expect, it, vi } from 'vitest'
3
3
  import '@testing-library/jest-dom/vitest'
4
4
 
5
- import type { AppForCatalog } from '@igstack/app-catalog-backend-core'
5
+ import type { Resource } from '@igstack/app-catalog-backend-core'
6
6
  import { AppDetailModal } from '~/modules/appCatalog/ui/components/AppDetailModal'
7
7
  import { AppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'
8
8
  import type { AppCatalogContextIface } from '~/modules/appCatalog/context/AppCatalogContext'
@@ -13,16 +13,15 @@ import type { AppCatalogContextIface } from '~/modules/appCatalog/context/AppCat
13
13
  // Each Escape press dismisses only the innermost active layer.
14
14
 
15
15
  const minimalContext: AppCatalogContextIface = {
16
- apps: [],
16
+ resources: [],
17
17
  isLoadingApps: false,
18
18
  tagsDefinitions: [],
19
19
  approvalMethods: [],
20
20
  persons: [],
21
21
  groups: [],
22
- subResources: [],
23
22
  }
24
23
 
25
- function makeApp(): AppForCatalog {
24
+ function makeApp(): Resource {
26
25
  return {
27
26
  id: 'app-1',
28
27
  slug: 'test-app',
@@ -1,11 +1,10 @@
1
1
  import type {
2
2
  AppApprovalMethod,
3
- AppForCatalog,
4
3
  AppVersionInfo,
5
4
  Group,
6
5
  GroupingTagDefinition,
7
6
  Person,
8
- SubResource,
7
+ Resource,
9
8
  } from '@igstack/app-catalog-backend-core'
10
9
  import { useQuery } from '@tanstack/react-query'
11
10
  import type { ReactNode } from 'react'
@@ -14,13 +13,12 @@ import { ApiQueryMagazineAppCatalog } from '~/modules/appCatalog'
14
13
  import { useUiSettings } from '~/context/UiSettingsContext'
15
14
 
16
15
  export interface AppCatalogContextIface {
17
- apps: AppForCatalog[]
16
+ resources: Resource[]
18
17
  isLoadingApps: boolean
19
18
  tagsDefinitions: GroupingTagDefinition[]
20
19
  approvalMethods: AppApprovalMethod[]
21
20
  persons: Person[]
22
21
  groups: Group[]
23
- subResources?: SubResource[]
24
22
  versions?: AppVersionInfo
25
23
  }
26
24
 
@@ -40,13 +38,12 @@ export function AppCatalogProvider({ children }: AppCatalogProviderProps) {
40
38
 
41
39
  const contextValue = useMemo<AppCatalogContextIface>(
42
40
  () => ({
43
- apps: data?.apps ?? [],
41
+ resources: data?.resources ?? [],
44
42
  isLoadingApps,
45
43
  tagsDefinitions: data?.tagsDefinitions ?? [],
46
44
  approvalMethods: data?.approvalMethods ?? [],
47
45
  persons: data?.persons ?? [],
48
46
  groups: data?.groups ?? [],
49
- subResources: data?.subResources ?? [],
50
47
  versions: {
51
48
  ...data?.versions,
52
49
  ...(uiSettings.frontendBuildId && {
@@ -61,11 +58,10 @@ export function AppCatalogProvider({ children }: AppCatalogProviderProps) {
61
58
  }),
62
59
  [
63
60
  data?.approvalMethods,
64
- data?.apps,
61
+ data?.resources,
65
62
  data?.tagsDefinitions,
66
63
  data?.persons,
67
64
  data?.groups,
68
- data?.subResources,
69
65
  data?.versions,
70
66
  uiSettings.frontendBuildId,
71
67
  isLoadingApps,