Skip to content

Commit 7e6e3b7

Browse files
feat(api): api update
1 parent 01f0f2a commit 7e6e3b7

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 40
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-c99300223257d60d7614e76585c62cfea40f43df0547db63c952b20c52f209f4.yml
3-
openapi_spec_hash: 1d4e473f3c566b7a1c3def11b6d84fe0
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-4f279e7b1f0a52f5c917d4256e17188dfe330ddf7495146e2b1611e812605fdc.yml
3+
openapi_spec_hash: 53a74c4cccbdec8590db38183840a446
44
config_hash: 920678668dd2da6f8966fbf1b8fde4e2

‎pkg/cmd/brand.go‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,38 @@ var brandRetrieveSimplified = cli.Command{
154154

155155
var brandSearch = cli.Command{
156156
Name: "search",
157-
Usage: "Search brands by name or domain and get back up to 10 lightweight matches\n(domain, name, logo). Name matches rank ahead of domain matches; within each\ngroup the most popular brands come first: by Tranco rank, then market cap for\nbrands outside the Tranco list, with text relevance breaking ties. Matching is\nprefix-based with no typo tolerance, so it is suited to autocomplete. Only\nbrands already in the Context.dev index are returned — use /brand/retrieve to\nfetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit\nper request on the Free and Starter plans.",
157+
Usage: "Search indexed brands by name or domain",
158158
Suggest: true,
159159
Flags: []cli.Flag{
160160
&requestflag.Flag[string]{
161161
Name: "query",
162-
Usage: "Search term, matched against brand names and domains by prefix (e.g. 'nike', 'nike.com', 'nik').",
162+
Usage: "Search term, matched against the fields selected by queryBy (e.g. 'nike', 'nike.com', 'nik').",
163163
Required: true,
164164
QueryPath: "query",
165165
},
166+
&requestflag.Flag[bool]{
167+
Name: "autocomplete",
168+
Usage: "Whether the search term matches by prefix, so partial words match as they are typed (e.g. 'nik' matches Nike). Set to false to match whole words only.",
169+
Default: true,
170+
QueryPath: "autocomplete",
171+
},
172+
&requestflag.Flag[[]string]{
173+
Name: "query-by",
174+
Usage: "Fields to match the search term against, as a comma-separated list or repeated parameter: 'name', 'domain', or both. Defaults to both.",
175+
Default: []string{"name", "domain"},
176+
QueryPath: "queryBy",
177+
},
166178
&requestflag.Flag[[]string]{
167179
Name: "tag",
168180
Usage: "Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.",
169181
QueryPath: "tags",
170182
},
183+
&requestflag.Flag[int64]{
184+
Name: "typo-tolerance",
185+
Usage: "Maximum number of typos tolerated when matching, from 0 to 2. Defaults to 0 (no typo tolerance).",
186+
Default: 0,
187+
QueryPath: "typoTolerance",
188+
},
171189
},
172190
Action: handleBrandSearch,
173191
HideHelpCommand: true,

‎pkg/cmd/brand_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ func TestBrandSearch(t *testing.T) {
7171
"--api-key", "string",
7272
"brand", "search",
7373
"--query", "x",
74+
"--autocomplete=true",
75+
"--query-by", "name",
7476
"--tag", "production",
7577
"--tag", "team-alpha",
78+
"--typo-tolerance", "0",
7679
)
7780
})
7881
}

0 commit comments

Comments
 (0)