Skip to content

Commit 092c1db

Browse files
chore: update @arcadeai/design-system to latest (#848)
Co-authored-by: arcadedotdev <262423181+arcadedotdev@users.noreply.github.com>
1 parent 417fa8b commit 092c1db

9 files changed

Lines changed: 7703 additions & 4333 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import type { AvailableToolsTableProps, BehaviorFlagKey } from "../types";
2+
import { normalizeScopes } from "./scopes-display";
3+
4+
export type AvailableToolsFilter =
5+
| "all"
6+
| "has_scopes"
7+
| "no_scopes"
8+
| "has_secrets"
9+
| "no_secrets";
10+
11+
export type FilterToolsOptions = {
12+
activeOperations?: Set<string>;
13+
behaviorFlags?: Partial<Record<BehaviorFlagKey, boolean>>;
14+
};
15+
16+
function buildScopeDisplayItems(scopes: string[]): string[] {
17+
return normalizeScopes(scopes);
18+
}
19+
20+
function matchesFilterCategory(
21+
tool: AvailableToolsTableProps["tools"][number],
22+
filter: AvailableToolsFilter
23+
): boolean {
24+
const hasScopes = buildScopeDisplayItems(tool.scopes ?? []).length > 0;
25+
const hasSecrets =
26+
(tool.secretsInfo?.length ?? 0) > 0 || (tool.secrets?.length ?? 0) > 0;
27+
28+
switch (filter) {
29+
case "has_scopes":
30+
return hasScopes;
31+
case "no_scopes":
32+
return !hasScopes;
33+
case "has_secrets":
34+
return hasSecrets;
35+
case "no_secrets":
36+
return !hasSecrets;
37+
default:
38+
return true;
39+
}
40+
}
41+
42+
function matchesOperations(
43+
tool: AvailableToolsTableProps["tools"][number],
44+
activeOperations: Set<string>
45+
): boolean {
46+
if (activeOperations.size === 0) {
47+
return true;
48+
}
49+
const toolOps = tool.metadata?.behavior?.operations ?? [];
50+
return toolOps.some((op) => activeOperations.has(op));
51+
}
52+
53+
function matchesBehaviorFlags(
54+
tool: AvailableToolsTableProps["tools"][number],
55+
behaviorFlags: Partial<Record<BehaviorFlagKey, boolean>>
56+
): boolean {
57+
for (const [key, expected] of Object.entries(behaviorFlags) as [
58+
BehaviorFlagKey,
59+
boolean | undefined,
60+
][]) {
61+
if (expected === undefined) {
62+
continue;
63+
}
64+
if (tool.metadata?.behavior?.[key] !== expected) {
65+
return false;
66+
}
67+
}
68+
return true;
69+
}
70+
71+
export function filterTools(
72+
tools: AvailableToolsTableProps["tools"],
73+
query: string,
74+
filter: AvailableToolsFilter,
75+
options: FilterToolsOptions = {}
76+
): AvailableToolsTableProps["tools"] {
77+
const { activeOperations = new Set(), behaviorFlags = {} } = options;
78+
const normalizedQuery = query.trim().toLowerCase();
79+
80+
return tools.filter((tool) => {
81+
const haystack = [tool.name, tool.qualifiedName, tool.description ?? ""]
82+
.join(" ")
83+
.toLowerCase();
84+
if (normalizedQuery.length > 0 && !haystack.includes(normalizedQuery)) {
85+
return false;
86+
}
87+
if (!matchesFilterCategory(tool, filter)) {
88+
return false;
89+
}
90+
if (!matchesOperations(tool, activeOperations)) {
91+
return false;
92+
}
93+
return matchesBehaviorFlags(tool, behaviorFlags);
94+
});
95+
}

app/_components/toolkit-docs/components/available-tools-table.tsx

Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,18 @@ import type {
2727
BehaviorFlagKey,
2828
SecretType,
2929
} from "../types";
30+
import {
31+
type AvailableToolsFilter,
32+
filterTools,
33+
} from "./available-tools-filter";
3034
import { normalizeScopes } from "./scopes-display";
3135

36+
export {
37+
type AvailableToolsFilter,
38+
type FilterToolsOptions,
39+
filterTools,
40+
} from "./available-tools-filter";
41+
3242
const DEFAULT_PAGE_SIZE = 25;
3343
const PAGE_SIZE_OPTIONS = [25, 50, 100, 200] as const;
3444

@@ -226,13 +236,6 @@ export function toToolAnchorId(value: string): string {
226236
return value.toLowerCase().replace(/\s+/g, "-").replace(/\./g, "");
227237
}
228238

229-
export type AvailableToolsFilter =
230-
| "all"
231-
| "has_scopes"
232-
| "no_scopes"
233-
| "has_secrets"
234-
| "no_secrets";
235-
236239
export type AvailableToolsSort =
237240
| "name_asc"
238241
| "name_desc"
@@ -692,88 +695,6 @@ export function sortTools(
692695
}
693696
}
694697

695-
export type FilterToolsOptions = {
696-
activeOperations?: Set<string>;
697-
behaviorFlags?: Partial<Record<BehaviorFlagKey, boolean>>;
698-
};
699-
700-
function matchesFilterCategory(
701-
tool: AvailableToolsTableProps["tools"][number],
702-
filter: AvailableToolsFilter
703-
): boolean {
704-
const hasScopes = buildScopeDisplayItems(tool.scopes ?? []).length > 0;
705-
const hasSecrets =
706-
(tool.secretsInfo?.length ?? 0) > 0 || (tool.secrets?.length ?? 0) > 0;
707-
708-
switch (filter) {
709-
case "has_scopes":
710-
return hasScopes;
711-
case "no_scopes":
712-
return !hasScopes;
713-
case "has_secrets":
714-
return hasSecrets;
715-
case "no_secrets":
716-
return !hasSecrets;
717-
default:
718-
return true;
719-
}
720-
}
721-
722-
function matchesOperations(
723-
tool: AvailableToolsTableProps["tools"][number],
724-
activeOperations: Set<string>
725-
): boolean {
726-
if (activeOperations.size === 0) {
727-
return true;
728-
}
729-
const toolOps = tool.metadata?.behavior?.operations ?? [];
730-
return toolOps.some((op) => activeOperations.has(op));
731-
}
732-
733-
function matchesBehaviorFlags(
734-
tool: AvailableToolsTableProps["tools"][number],
735-
behaviorFlags: Partial<Record<BehaviorFlagKey, boolean>>
736-
): boolean {
737-
for (const [key, expected] of Object.entries(behaviorFlags) as [
738-
BehaviorFlagKey,
739-
boolean | undefined,
740-
][]) {
741-
if (expected === undefined) {
742-
continue;
743-
}
744-
if (tool.metadata?.behavior?.[key] !== expected) {
745-
return false;
746-
}
747-
}
748-
return true;
749-
}
750-
751-
export function filterTools(
752-
tools: AvailableToolsTableProps["tools"],
753-
query: string,
754-
filter: AvailableToolsFilter,
755-
options: FilterToolsOptions = {}
756-
): AvailableToolsTableProps["tools"] {
757-
const { activeOperations = new Set(), behaviorFlags = {} } = options;
758-
const normalizedQuery = query.trim().toLowerCase();
759-
760-
return tools.filter((tool) => {
761-
const haystack = [tool.name, tool.qualifiedName, tool.description ?? ""]
762-
.join(" ")
763-
.toLowerCase();
764-
if (normalizedQuery.length > 0 && !haystack.includes(normalizedQuery)) {
765-
return false;
766-
}
767-
if (!matchesFilterCategory(tool, filter)) {
768-
return false;
769-
}
770-
if (!matchesOperations(tool, activeOperations)) {
771-
return false;
772-
}
773-
return matchesBehaviorFlags(tool, behaviorFlags);
774-
});
775-
}
776-
777698
/**
778699
* AvailableToolsTable
779700
*
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export function getSharedServiceDomain(
2+
tools: ReadonlyArray<{
3+
metadata?: {
4+
classification?: {
5+
serviceDomains?: string[];
6+
} | null;
7+
} | null;
8+
}>
9+
): string | null {
10+
if (tools.length === 0) {
11+
return null;
12+
}
13+
14+
let sharedDomain: string | null = null;
15+
16+
for (const tool of tools) {
17+
const serviceDomains = tool.metadata?.classification?.serviceDomains;
18+
if (!serviceDomains || serviceDomains.length !== 1) {
19+
return null;
20+
}
21+
22+
const domain = serviceDomains[0];
23+
if (!domain || typeof domain !== "string") {
24+
return null;
25+
}
26+
27+
if (sharedDomain === null) {
28+
sharedDomain = domain;
29+
continue;
30+
}
31+
32+
if (sharedDomain !== domain) {
33+
return null;
34+
}
35+
}
36+
37+
return sharedDomain;
38+
}

app/_components/toolkit-docs/components/toolkit-page.tsx

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {
1212
TOOL_METADATA_FALLBACK_STYLE,
1313
TOOL_METADATA_SERVICE_DOMAIN_STYLES,
1414
} from "../constants";
15+
import { getSharedServiceDomain } from "./toolkit-page-utils";
16+
17+
export { getSharedServiceDomain } from "./toolkit-page-utils";
1518

1619
// Scroll detection thresholds
1720
const SCROLL_SHOW_BUTTONS_THRESHOLD = 300;
@@ -210,45 +213,6 @@ function inferToolkitType(toolkitId: string, type: ToolkitType): ToolkitType {
210213
return type;
211214
}
212215

213-
export function getSharedServiceDomain(
214-
tools: ReadonlyArray<{
215-
metadata?: {
216-
classification?: {
217-
serviceDomains?: string[];
218-
} | null;
219-
} | null;
220-
}>
221-
): string | null {
222-
if (tools.length === 0) {
223-
return null;
224-
}
225-
226-
let sharedDomain: string | null = null;
227-
228-
for (const tool of tools) {
229-
const serviceDomains = tool.metadata?.classification?.serviceDomains;
230-
if (!serviceDomains || serviceDomains.length !== 1) {
231-
return null;
232-
}
233-
234-
const domain = serviceDomains[0];
235-
if (!domain || typeof domain !== "string") {
236-
return null;
237-
}
238-
239-
if (sharedDomain === null) {
240-
sharedDomain = domain;
241-
continue;
242-
}
243-
244-
if (sharedDomain !== domain) {
245-
return null;
246-
}
247-
}
248-
249-
return sharedDomain;
250-
}
251-
252216
function toTitleCaseCategory(category: ToolkitCategory): string {
253217
return category
254218
.split("-")

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"homepage": "https://arcade.dev/",
4242
"dependencies": {
43-
"@arcadeai/design-system": "^3.30.0",
43+
"@arcadeai/design-system": "^3.32.0",
4444
"@mdx-js/mdx": "^3.1.1",
4545
"@mdx-js/react": "^3.1.1",
4646
"@next/third-parties": "16.0.1",

0 commit comments

Comments
 (0)