@squadbase/vite-server 0.1.9-dev.a57a0ac → 0.1.9-dev.a70dcaa

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.
@@ -311,7 +311,7 @@ var inputSchema = z.object({
311
311
  "HTTP method. GET for almost all Semrush endpoints. POST is used for a few Projects API mutations."
312
312
  ),
313
313
  path: z.string().describe(
314
- "API path appended to https://api.semrush.com (e.g., '/' for the Standard Analytics API, '/analytics/v1/' for the Trends API, '/management/v1/projects/' for the Projects API)."
314
+ "API path appended to https://api.semrush.com (e.g., '/' for the Standard Analytics API, '/analytics/v1/' for the Trends API, '/management/v1/projects/' for the Projects API). You may also pass an absolute https:// URL on a Semrush host (e.g., 'https://www.semrush.com/users/countapiunits.html' to check API unit balance)."
315
315
  ),
316
316
  queryParams: z.record(z.string(), z.string()).optional().describe(
317
317
  "Query parameters to append to the URL. The 'key' parameter is injected automatically \u2014 do not include it. Common params: 'type' (report type, e.g. 'domain_overview'), 'domain', 'phrase', 'database' (e.g. 'us', 'uk', 'jp'), 'export_columns' (comma-separated), 'display_limit', 'display_offset', 'display_date' (YYYYMM15)."
@@ -369,8 +369,18 @@ Errors from the Standard API are returned as a plain text body starting with "ER
369
369
  );
370
370
  try {
371
371
  const apiKey = parameters.apiKey.getValue(connection2);
372
+ const isAbsolute = /^https?:\/\//i.test(path2);
373
+ if (isAbsolute) {
374
+ const host = new URL(path2).hostname.toLowerCase();
375
+ if (host !== "api.semrush.com" && host !== "www.semrush.com") {
376
+ return {
377
+ success: false,
378
+ error: `Absolute URLs are only allowed on api.semrush.com or www.semrush.com (got ${host})`
379
+ };
380
+ }
381
+ }
372
382
  const url = new URL(
373
- `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`
383
+ isAbsolute ? path2 : `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`
374
384
  );
375
385
  if (queryParams) {
376
386
  for (const [k, v] of Object.entries(queryParams)) {
@@ -434,25 +444,27 @@ var semrushOnboarding = new ConnectorOnboarding({
434
444
  connectionSetupInstructions: {
435
445
  ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Semrush\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
436
446
 
437
- 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001API\u6B8B\u91CF\u3092\u78BA\u8A8D\u3059\u308B:
447
+ 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001API\u6B8B\u91CF\u3092\u78BA\u8A8D\u3059\u308B\uFF08\u3053\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u306FAPI\u30E6\u30CB\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u305B\u3093\uFF09:
438
448
  - \`method\`: \`"GET"\`
439
- - \`path\`: \`"/"\`
440
- - \`queryParams\`: \`{ "type": "user_units" }\`
449
+ - \`path\`: \`"https://www.semrush.com/users/countapiunits.html"\`
450
+ - \`queryParams\`: \u306A\u3057
451
+ - \`responseFormat\`: \`"text"\`
441
452
  2. \u30EC\u30B9\u30DD\u30F3\u30B9\u672C\u6587\u304C \`ERROR\` \u3067\u59CB\u307E\u308B\u3001\u307E\u305F\u306FAPI\u30E6\u30CB\u30C3\u30C8\u6B8B\u91CF\u304C0\u306E\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BAPI\u30AD\u30FC\u3068\u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u72B6\u614B\uFF08API units \u304C\u4ED8\u4E0E\u3055\u308C\u3066\u3044\u308B\u304B\uFF09\u306E\u78BA\u8A8D\u3092\u4F9D\u983C\u3059\u308B
442
453
 
443
454
  #### \u5236\u7D04
444
- - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306BAPI\u30E6\u30CB\u30C3\u30C8\u3092\u5927\u91CF\u6D88\u8CBB\u3059\u308B\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3057\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u307F
455
+ - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306BAPI\u30E6\u30CB\u30C3\u30C8\u3092\u6D88\u8CBB\u3059\u308B\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C\u3057\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u306E\u6B8B\u91CF\u78BA\u8A8D\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u307F\uFF08\`countapiunits.html\` \u306F\u7121\u6599\uFF09
445
456
  - \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u3002\u4E0D\u8981\u306A\u8AAC\u660E\u306F\u7701\u7565\u3057\u3001\u52B9\u7387\u7684\u306B\u9032\u3081\u308B`,
446
457
  en: `Follow these steps to set up the Semrush connection.
447
458
 
448
- 1. Call \`${requestToolName}\` to check the remaining API units:
459
+ 1. Call \`${requestToolName}\` to check the remaining API units (this request does NOT consume API units):
449
460
  - \`method\`: \`"GET"\`
450
- - \`path\`: \`"/"\`
451
- - \`queryParams\`: \`{ "type": "user_units" }\`
461
+ - \`path\`: \`"https://www.semrush.com/users/countapiunits.html"\`
462
+ - \`queryParams\`: none
463
+ - \`responseFormat\`: \`"text"\`
452
464
  2. If the response body starts with \`ERROR\` or API units are 0, ask the user to verify the API key and subscription status (API units must be granted to the account)
453
465
 
454
466
  #### Constraints
455
- - **Do NOT run reports that consume large amounts of API units during setup**. Only the metadata request specified above is allowed
467
+ - **Do NOT run reports that consume API units during setup**. Only the unit balance check above is allowed (the \`countapiunits.html\` endpoint is free)
456
468
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
457
469
  },
458
470
  dataOverviewInstructions: {
@@ -536,7 +548,8 @@ Authentication: API key passed as the \`key\` query parameter on every request (
536
548
  - \`backlinks\` \u2014 list of backlinks
537
549
  - \`backlinks_refdomains\` \u2014 referring domains
538
550
  - \`url_organic\` / \`url_adwords\` \u2014 keywords ranking for a specific URL
539
- - \`user_units\` \u2014 remaining API units for the account
551
+
552
+ To check remaining API units (free, does NOT consume units), call the request tool with an absolute URL: \`path: "https://www.semrush.com/users/countapiunits.html"\`, no query params, \`responseFormat: "text"\`. The response body is just a number.
540
553
 
541
554
  #### Common query parameters
542
555
  - \`type\` \u2014 report type (required for the Standard API)
@@ -550,7 +563,7 @@ Authentication: API key passed as the \`key\` query parameter on every request (
550
563
  - \`display_filter\` \u2014 filter directive (e.g. \`+|Ph|Co|keyword\`)
551
564
 
552
565
  #### Tips
553
- - Each report consumes API units; check \`type=user_units\` first if you suspect a quota issue
566
+ - Each Standard Analytics report consumes API units; check the unit balance via \`https://www.semrush.com/users/countapiunits.html?key=...\` (free) first if you suspect a quota issue
554
567
  - The CSV separator is \`;\` (semicolon), NOT \`,\`. Some cells may contain commas inside them.
555
568
  - An HTTP 200 response with a body starting with \`ERROR\` indicates an API error (auth, parameters, or quota)
556
569
  - The Trends API requires a separate Trends subscription; calls without it will fail with an authorization error
@@ -609,7 +622,8 @@ export default async function handler(c: Context) {
609
622
  - \`backlinks\` \u2014 \u30D0\u30C3\u30AF\u30EA\u30F3\u30AF\u4E00\u89A7
610
623
  - \`backlinks_refdomains\` \u2014 \u53C2\u7167\u30C9\u30E1\u30A4\u30F3
611
624
  - \`url_organic\` / \`url_adwords\` \u2014 \u7279\u5B9AURL\u3067\u30E9\u30F3\u30AF\u30A4\u30F3\u3057\u3066\u3044\u308B\u30AD\u30FC\u30EF\u30FC\u30C9
612
- - \`user_units\` \u2014 \u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u6B8BAPI\u30E6\u30CB\u30C3\u30C8\u6570
625
+
626
+ API \u30E6\u30CB\u30C3\u30C8\u6B8B\u91CF\u306E\u78BA\u8A8D\uFF08\u7121\u6599\u3001\u30E6\u30CB\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u306A\u3044\uFF09\u306F request \u30C4\u30FC\u30EB\u306B\u7D76\u5BFEURL\u3092\u6E21\u3059: \`path: "https://www.semrush.com/users/countapiunits.html"\`\u3001queryParams \u306A\u3057\u3001\`responseFormat: "text"\`\u3002\u30EC\u30B9\u30DD\u30F3\u30B9\u672C\u6587\u306F\u6570\u5024\u306E\u307F\u3002
613
627
 
614
628
  #### \u4E3B\u8981\u306A\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF
615
629
  - \`type\` \u2014 \u30EC\u30DD\u30FC\u30C8\u7A2E\u5225\uFF08Standard API \u3067\u306F\u5FC5\u9808\uFF09
@@ -623,7 +637,7 @@ export default async function handler(c: Context) {
623
637
  - \`display_filter\` \u2014 \u30D5\u30A3\u30EB\u30BF\u6307\u5B9A\uFF08\u4F8B: \`+|Ph|Co|keyword\`\uFF09
624
638
 
625
639
  #### \u30D2\u30F3\u30C8
626
- - \u5404\u30EC\u30DD\u30FC\u30C8\u306F API \u30E6\u30CB\u30C3\u30C8\u3092\u6D88\u8CBB\u3059\u308B\u3002\u30AF\u30A9\u30FC\u30BF\u304C\u7591\u308F\u3057\u3044\u5834\u5408\u306F \`type=user_units\` \u3067\u6B8B\u91CF\u3092\u5148\u306B\u78BA\u8A8D\u3059\u308B
640
+ - Standard Analytics \u306E\u5404\u30EC\u30DD\u30FC\u30C8\u306F API \u30E6\u30CB\u30C3\u30C8\u3092\u6D88\u8CBB\u3059\u308B\u3002\u30AF\u30A9\u30FC\u30BF\u304C\u7591\u308F\u3057\u3044\u5834\u5408\u306F \`https://www.semrush.com/users/countapiunits.html?key=...\` \u3067\u6B8B\u91CF\u3092\u5148\u306B\u78BA\u8A8D\u3059\u308B\uFF08\u7121\u6599\uFF09
627
641
  - CSV \u306E\u30BB\u30D1\u30EC\u30FC\u30BF\u306F \`;\`\uFF08\u30BB\u30DF\u30B3\u30ED\u30F3\uFF09\u3067\u3042\u308A \`,\` \u3067\u306F\u306A\u3044\u3002\u30BB\u30EB\u5185\u306B\u30AB\u30F3\u30DE\u304C\u542B\u307E\u308C\u308B\u3053\u3068\u304C\u3042\u308B
628
642
  - HTTP 200 \u3067\u3082\u672C\u6587\u304C \`ERROR\` \u3067\u59CB\u307E\u308B\u5834\u5408\u306F API\u30A8\u30E9\u30FC\uFF08\u8A8D\u8A3C\u3001\u30D1\u30E9\u30E1\u30FC\u30BF\u3001\u30AF\u30A9\u30FC\u30BF\uFF09
629
643
  - Trends API \u306F\u5225\u9014 Trends \u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u304C\u5FC5\u8981\u3002\u672A\u5951\u7D04\u3060\u3068\u8A8D\u53EF\u30A8\u30E9\u30FC\u306B\u306A\u308B
@@ -639,8 +653,7 @@ export default async function handler(c: Context) {
639
653
  error: "API Key is not configured"
640
654
  };
641
655
  }
642
- const url = new URL("https://api.semrush.com/");
643
- url.searchParams.set("type", "user_units");
656
+ const url = new URL("https://www.semrush.com/users/countapiunits.html");
644
657
  url.searchParams.set("key", apiKey);
645
658
  const res = await fetch(url.toString(), { method: "GET" });
646
659
  const text = await res.text();