@hasna/connectors 1.4.2 → 1.4.3
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.
- package/bin/index.js +1 -5
- package/bin/mcp.js +1 -1
- package/bin/serve.js +1 -1
- package/connectors/clickbank/README.md +2 -2
- package/connectors/split-in-batches/CLAUDE.md +1 -1
- package/connectors/split-in-batches/README.md +1 -1
- package/connectors/split-in-batches/src/api/client.test.ts +16 -17
- package/connectors/split-in-batches/src/api/client.ts +4 -3
- package/connectors/split-in-batches/src/cli/index.ts +1 -1
- package/connectors/spreadsheet-file/.env.example +1 -1
- package/connectors/spreadsheet-file/CLAUDE.md +2 -2
- package/connectors/spreadsheet-file/README.md +3 -3
- package/connectors/spreadsheet-file/src/api/client.test.ts +8 -9
- package/connectors/spreadsheet-file/src/api/client.ts +4 -3
- package/connectors/spreadsheet-file/src/cli/index.ts +1 -1
- package/connectors/sse-trigger/.env.example +1 -1
- package/connectors/sse-trigger/CLAUDE.md +2 -2
- package/connectors/sse-trigger/README.md +1 -1
- package/connectors/sse-trigger/src/api/client.test.ts +12 -8
- package/connectors/sse-trigger/src/api/client.ts +4 -3
- package/connectors/sse-trigger/src/api/index.ts +1 -1
- package/connectors/sse-trigger/src/cli/index.ts +1 -1
- package/connectors/sse-trigger/src/index.ts +1 -1
- package/connectors/stability-api-platform/AGENTS.md +1 -1
- package/connectors/stability-api-platform/CLAUDE.md +1 -1
- package/connectors/stability-api-platform/README.md +2 -2
- package/connectors/stability-api-platform/src/api/client.test.ts +17 -12
- package/connectors/stability-api-platform/src/api/client.ts +4 -3
- package/connectors/stability-api-platform/src/api/index.ts +0 -1
- package/connectors/stability-api-platform/src/cli/index.ts +1 -1
- package/connectors/stability-api-platform/src/index.ts +0 -1
- package/connectors/stop-and-error/.env.example +1 -1
- package/connectors/stop-and-error/CLAUDE.md +1 -1
- package/connectors/stop-and-error/README.md +1 -1
- package/connectors/stop-and-error/src/api/client.test.ts +12 -8
- package/connectors/stop-and-error/src/api/client.ts +4 -3
- package/connectors/stop-and-error/src/cli/index.ts +2 -2
- package/connectors/stripe-financial-connections/.env.example +1 -1
- package/connectors/stripe-financial-connections/CLAUDE.md +2 -2
- package/connectors/stripe-financial-connections/src/api/client.test.ts +34 -0
- package/connectors/stripe-financial-connections/src/api/client.ts +4 -3
- package/connectors/stripe-financial-connections/src/cli/index.ts +1 -1
- package/connectors/sucuri-api-platform/.env.example +1 -1
- package/connectors/sucuri-api-platform/CLAUDE.md +1 -1
- package/connectors/sucuri-api-platform/README.md +2 -2
- package/connectors/sucuri-api-platform/src/api/client.test.ts +9 -7
- package/connectors/sucuri-api-platform/src/api/client.ts +4 -3
- package/connectors/sucuri-api-platform/src/api/index.ts +1 -1
- package/connectors/sucuri-api-platform/src/cli/index.ts +1 -1
- package/connectors/sucuri-api-platform/src/index.ts +1 -1
- package/connectors/tettra-api-platform/CLAUDE.md +1 -1
- package/connectors/tettra-api-platform/README.md +2 -2
- package/connectors/tettra-api-platform/src/api/client.test.ts +7 -8
- package/connectors/tettra-api-platform/src/api/client.ts +4 -3
- package/connectors/tettra-api-platform/src/api/index.ts +1 -1
- package/connectors/tettra-api-platform/src/cli/index.ts +1 -1
- package/connectors/tettra-api-platform/src/index.ts +1 -1
- package/connectors/together-api-platform/.env.example +1 -1
- package/connectors/together-api-platform/CLAUDE.md +1 -1
- package/connectors/together-api-platform/README.md +1 -1
- package/connectors/together-api-platform/src/api/client.test.ts +11 -7
- package/connectors/together-api-platform/src/api/client.ts +4 -4
- package/connectors/together-api-platform/src/api/index.ts +1 -1
- package/connectors/together-api-platform/src/cli/index.ts +1 -1
- package/connectors/together-api-platform/src/index.ts +1 -1
- package/connectors/travo-real-estate/CLAUDE.md +1 -1
- package/connectors/travo-real-estate/README.md +1 -1
- package/connectors/travo-real-estate/src/api/client.test.ts +20 -16
- package/connectors/travo-real-estate/src/api/client.ts +4 -3
- package/connectors/travo-real-estate/src/utils/config.ts +2 -4
- package/connectors/tray-api-platform/CLAUDE.md +1 -1
- package/connectors/tray-api-platform/src/api/client.test.ts +17 -13
- package/connectors/tray-api-platform/src/api/client.ts +4 -3
- package/connectors/tray-api-platform/src/api/index.ts +1 -1
- package/connectors/tray-api-platform/src/cli/index.ts +1 -1
- package/connectors/tray-api-platform/src/index.ts +0 -1
- package/connectors/turso-api-platform/CLAUDE.md +1 -1
- package/connectors/turso-api-platform/README.md +2 -2
- package/connectors/turso-api-platform/src/api/client.test.ts +17 -13
- package/connectors/turso-api-platform/src/api/client.ts +4 -3
- package/connectors/turso-api-platform/src/cli/index.ts +2 -2
- package/connectors/twilio-api-platform/CLAUDE.md +1 -1
- package/connectors/twilio-api-platform/src/api/client.test.ts +11 -11
- package/connectors/twilio-api-platform/src/api/client.ts +4 -3
- package/connectors/twilio-api-platform/src/api/index.ts +1 -1
- package/connectors/twilio-api-platform/src/cli/index.ts +1 -1
- package/connectors/twilio-api-platform/src/index.ts +1 -1
- package/connectors/tyk-api-platform/.env.example +1 -1
- package/connectors/tyk-api-platform/CLAUDE.md +2 -2
- package/connectors/tyk-api-platform/README.md +1 -1
- package/connectors/tyk-api-platform/src/api/client.test.ts +14 -15
- package/connectors/tyk-api-platform/src/api/client.ts +4 -3
- package/connectors/tyk-api-platform/src/api/index.ts +1 -1
- package/connectors/tyk-api-platform/src/cli/index.ts +1 -1
- package/connectors/tyk-api-platform/src/index.ts +1 -1
- package/connectors/vector-legal/.env.example +1 -1
- package/connectors/vector-legal/AGENTS.md +1 -1
- package/connectors/vector-legal/CLAUDE.md +1 -1
- package/connectors/vector-legal/README.md +1 -1
- package/connectors/vector-legal/src/api/client.test.ts +9 -5
- package/connectors/vector-legal/src/api/client.ts +4 -3
- package/connectors/vector-legal/src/api/index.ts +1 -1
- package/connectors/vector-legal/src/cli/index.ts +2 -2
- package/connectors/vector-legal/src/index.ts +0 -1
- package/connectors/vector-legal-api/CLAUDE.md +1 -1
- package/connectors/vector-legal-api/README.md +2 -2
- package/connectors/vector-legal-api/src/api/client.test.ts +12 -7
- package/connectors/vector-legal-api/src/api/client.ts +4 -3
- package/connectors/vector-legal-api/src/api/index.ts +1 -1
- package/connectors/vector-legal-api/src/cli/index.ts +1 -1
- package/connectors/vector-legal-api/src/index.ts +1 -2
- package/connectors/velum-data-quality/.env.example +1 -1
- package/connectors/velum-data-quality/CLAUDE.md +1 -1
- package/connectors/velum-data-quality/src/api/client.test.ts +15 -16
- package/connectors/velum-data-quality/src/api/client.ts +4 -3
- package/connectors/velum-data-quality/src/api/index.ts +1 -1
- package/connectors/velum-data-quality/src/cli/index.ts +1 -1
- package/connectors/velum-data-quality/src/index.ts +0 -1
- package/connectors/vercel-api-platform/.env.example +1 -1
- package/connectors/vercel-api-platform/CLAUDE.md +2 -2
- package/connectors/vercel-api-platform/README.md +2 -2
- package/connectors/vercel-api-platform/src/api/client.test.ts +27 -6
- package/connectors/vercel-api-platform/src/api/client.ts +4 -3
- package/connectors/vercel-api-platform/src/api/index.ts +1 -1
- package/connectors/vercel-api-platform/src/cli/index.ts +2 -2
- package/connectors/vercel-api-platform/src/index.ts +0 -1
- package/connectors/veriphone/README.md +2 -2
- package/connectors/wave-accounting/CLAUDE.md +1 -1
- package/connectors/wave-accounting/src/utils/auth.ts +1 -1
- package/connectors/weaviate-api-platform/CLAUDE.md +1 -1
- package/connectors/weaviate-api-platform/src/api/client.test.ts +32 -7
- package/connectors/weaviate-api-platform/src/api/client.ts +4 -3
- package/connectors/weaviate-api-platform/src/api/index.ts +1 -1
- package/connectors/weaviate-api-platform/src/cli/index.ts +1 -1
- package/connectors/weaviate-api-platform/src/index.ts +1 -1
- package/connectors/workflow-trigger/.env.example +1 -1
- package/connectors/workflow-trigger/CLAUDE.md +1 -1
- package/connectors/workflow-trigger/README.md +1 -1
- package/connectors/workflow-trigger/src/api/client.test.ts +10 -6
- package/connectors/workflow-trigger/src/api/client.ts +4 -3
- package/connectors/workflow-trigger/src/cli/index.ts +1 -1
- package/connectors/write-binary-file/CLAUDE.md +1 -1
- package/connectors/write-binary-file/README.md +1 -1
- package/connectors/write-binary-file/src/api/client.test.ts +16 -12
- package/connectors/write-binary-file/src/api/client.ts +4 -3
- package/connectors/write-binary-file/src/api/index.ts +1 -1
- package/connectors/write-binary-file/src/index.ts +1 -1
- package/connectors/wubookratechecker/src/api/client.test.ts +34 -0
- package/connectors/wubookratechecker/src/api/client.ts +3 -1
- package/connectors/wubookratechecker/src/api/index.ts +1 -1
- package/connectors/wubookratechecker/src/types/index.ts +1 -1
- package/connectors/xai-api-platform/.env.example +1 -1
- package/connectors/xai-api-platform/CLAUDE.md +1 -1
- package/connectors/xai-api-platform/README.md +1 -1
- package/connectors/xai-api-platform/src/api/client.test.ts +33 -8
- package/connectors/xai-api-platform/src/api/client.ts +4 -3
- package/connectors/xai-api-platform/src/api/index.ts +1 -1
- package/connectors/xai-api-platform/src/index.ts +1 -1
- package/connectors/xai-api-platform/src/utils/config.ts +2 -3
- package/connectors/zapier-api-platform/CLAUDE.md +1 -1
- package/connectors/zapier-api-platform/README.md +1 -1
- package/connectors/zapier-api-platform/src/api/client.test.ts +19 -14
- package/connectors/zapier-api-platform/src/api/client.ts +4 -3
- package/connectors/zapier-api-platform/src/api/index.ts +1 -1
- package/connectors/zapier-api-platform/src/cli/index.ts +1 -1
- package/connectors/zapier-api-platform/src/index.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Vercel Api Platform API credentials
|
|
2
2
|
VERCEL_API_PLATFORM_API_KEY=your-api-key-here
|
|
3
3
|
|
|
4
|
-
# Optional: override API base URL (default
|
|
4
|
+
# Optional: override API base URL (no default - must be configured)
|
|
5
5
|
# VERCEL_API_PLATFORM_BASE_URL=https://api.vercelapiplatform.com/v1
|
|
@@ -4,11 +4,11 @@ Guidance for working with the Vercel Api Platform connector.
|
|
|
4
4
|
|
|
5
5
|
## Distinction from connect-vercel
|
|
6
6
|
|
|
7
|
-
This connector targets **Vercel Api Platform** at `
|
|
7
|
+
This connector targets **Vercel Api Platform** at `configured.example.com/v1` (items, events, search). It is **not** the same as `connect-vercel`, which wraps `api.vercel.com` for deployments and projects.
|
|
8
8
|
|
|
9
9
|
## API Reference
|
|
10
10
|
|
|
11
|
-
- **Base URL**:
|
|
11
|
+
- **Base URL**: no default (must be configured) (override via profile or `VERCEL_API_PLATFORM_BASE_URL`)
|
|
12
12
|
- **Auth**: Bearer token (`Authorization: Bearer <api_key>`)
|
|
13
13
|
- **Endpoints**:
|
|
14
14
|
- `GET /items` — list items
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @hasna/connect-vercel-api-platform
|
|
2
2
|
|
|
3
|
-
TypeScript connector and CLI for the [Vercel Api Platform](
|
|
3
|
+
TypeScript connector and CLI for the [Vercel Api Platform](configured.example.com/v1) REST API.
|
|
4
4
|
|
|
5
5
|
> **Note:** This is distinct from `@hasna/connect-vercel`, which targets `api.vercel.com` for Vercel deployments.
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ bun add @hasna/connect-vercel-api-platform
|
|
|
15
15
|
```bash
|
|
16
16
|
export VERCEL_API_PLATFORM_API_KEY=your-api-key
|
|
17
17
|
# optional
|
|
18
|
-
export VERCEL_API_PLATFORM_BASE_URL=https://
|
|
18
|
+
export VERCEL_API_PLATFORM_BASE_URL=https://configured.example.com/v1
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Or use the CLI profile/config commands.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, test, expect, mock, beforeEach, afterEach } from 'bun:test';
|
|
2
|
-
import { ConnectorClient
|
|
2
|
+
import { ConnectorClient } from './client';
|
|
3
3
|
import { Connector } from './index';
|
|
4
4
|
import { ConnectorApiError } from '../types';
|
|
5
5
|
|
|
@@ -38,10 +38,9 @@ describe('ConnectorClient', () => {
|
|
|
38
38
|
expect(client.getBaseUrl()).toBe(TEST_BASE_URL);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
41
|
+
test('refuses to send without a configured base URL (no default endpoint)', () => {
|
|
42
|
+
expect(() => new ConnectorClient({ apiKey: 'test-key' })).toThrow(/baseUrl/);
|
|
43
|
+
});
|
|
45
44
|
|
|
46
45
|
test('strips trailing slashes from base URL', () => {
|
|
47
46
|
const client = new ConnectorClient({ apiKey: 'key', baseUrl: 'https://api.example.com/v1///' });
|
|
@@ -56,7 +55,7 @@ describe('ConnectorClient', () => {
|
|
|
56
55
|
});
|
|
57
56
|
|
|
58
57
|
test('returns *** for short keys', () => {
|
|
59
|
-
const client = new ConnectorClient({ apiKey: 'short' });
|
|
58
|
+
const client = new ConnectorClient({ apiKey: 'short', baseUrl: 'https://configured.example.com/v1' });
|
|
60
59
|
expect(client.getApiKeyPreview()).toBe('***');
|
|
61
60
|
});
|
|
62
61
|
});
|
|
@@ -198,10 +197,32 @@ describe('Connector API modules', () => {
|
|
|
198
197
|
test('raw.request uses configured base URL override', async () => {
|
|
199
198
|
const connector = new Connector({
|
|
200
199
|
apiKey: 'key',
|
|
200
|
+
baseUrl: 'https://configured.example.com/v1',
|
|
201
|
+
baseUrl: 'https://configured.example.com/v1',
|
|
201
202
|
baseUrl: 'https://override.example.com/v1',
|
|
202
203
|
});
|
|
203
204
|
await connector.raw.request({ path: '/items', method: 'GET' });
|
|
204
205
|
const [url] = getFetchMock().mock.calls[0];
|
|
205
206
|
expect(url).toBe('https://override.example.com/v1/items');
|
|
206
207
|
});
|
|
208
|
+
|
|
209
|
+
test('sends the API key only to the configured base URL', async () => {
|
|
210
|
+
const recorded: string[] = [];
|
|
211
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
212
|
+
recorded.push(typeof input === 'string' ? input : input.toString());
|
|
213
|
+
return {
|
|
214
|
+
ok: true,
|
|
215
|
+
status: 200,
|
|
216
|
+
statusText: 'OK',
|
|
217
|
+
headers: new Headers({ 'content-type': 'application/json' }),
|
|
218
|
+
async text() { return JSON.stringify({ ok: true }); },
|
|
219
|
+
async json() { return { ok: true }; },
|
|
220
|
+
} as Response;
|
|
221
|
+
}) as typeof fetch;
|
|
222
|
+
const client = new ConnectorClient({ apiKey: 'test-key', baseUrl: 'https://configured.example.com/v1' });
|
|
223
|
+
await client.request('/ping');
|
|
224
|
+
expect(recorded).toHaveLength(1);
|
|
225
|
+
expect(recorded[0].startsWith('https://configured.example.com/v1/')).toBe(true);
|
|
226
|
+
expect(recorded[0]).not.toContain('api.vercelapiplatform.com');
|
|
227
|
+
});
|
|
207
228
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ConnectorConfig } from '../types';
|
|
2
2
|
import { ConnectorApiError, parseApiError } from '../types';
|
|
3
3
|
|
|
4
|
-
export const DEFAULT_BASE_URL = 'https://api.vercelapiplatform.com/v1';
|
|
5
|
-
|
|
6
4
|
export interface RequestOptions {
|
|
7
5
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
8
6
|
params?: Record<string, string | number | boolean | undefined>;
|
|
@@ -22,7 +20,10 @@ export class ConnectorClient {
|
|
|
22
20
|
throw new Error('API key, token, or accessToken is required');
|
|
23
21
|
}
|
|
24
22
|
this.apiKey = key;
|
|
25
|
-
|
|
23
|
+
if (!config.baseUrl) {
|
|
24
|
+
throw new Error('baseUrl is required: no default endpoint is configured; set baseUrl (profile, config, or the connector BASE_URL environment variable)');
|
|
25
|
+
}
|
|
26
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, '');
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
getBaseUrl(): string {
|
|
@@ -41,7 +41,7 @@ export class Connector {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export { ConnectorClient
|
|
44
|
+
export { ConnectorClient } from './client';
|
|
45
45
|
export { ItemsApi } from './items';
|
|
46
46
|
export { EventsApi } from './events';
|
|
47
47
|
export { SearchApi } from './search';
|
|
@@ -140,7 +140,7 @@ profileCmd.command('show [name]').description('Show profile configuration').acti
|
|
|
140
140
|
const active = getCurrentProfile();
|
|
141
141
|
console.log(chalk.bold(`Profile: ${profileName}${profileName === active ? chalk.green(' (active)') : ''}`));
|
|
142
142
|
info(`API Key: ${config.apiKey ? `${config.apiKey.substring(0, 8)}...` : chalk.gray('not set')}`);
|
|
143
|
-
info(`Base URL: ${config.baseUrl || chalk.gray('
|
|
143
|
+
info(`Base URL: ${config.baseUrl || chalk.gray('none configured')}`);
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
const configCmd = program.command('config').description('Manage CLI configuration');
|
|
@@ -162,7 +162,7 @@ configCmd.command('show').description('Show current configuration').action(() =>
|
|
|
162
162
|
console.log(chalk.bold(`Active Profile: ${profileName}`));
|
|
163
163
|
info(`Config directory: ${getConfigDir()}`);
|
|
164
164
|
info(`API Key: ${apiKey ? `${apiKey.substring(0, 8)}...` : chalk.gray('not set')}`);
|
|
165
|
-
info(`Base URL: ${baseUrl || chalk.gray('
|
|
165
|
+
info(`Base URL: ${baseUrl || chalk.gray('none configured')}`);
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
configCmd.command('clear').description('Clear configuration for active profile').action(() => {
|
|
@@ -21,7 +21,7 @@ bun install
|
|
|
21
21
|
Set your API key via environment variable or CLI profile:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
export VERIPHONE_API_KEY
|
|
24
|
+
export VERIPHONE_API_KEY=<your-api-key>
|
|
25
25
|
# or
|
|
26
26
|
bun run dev config set-key your-api-key-here
|
|
27
27
|
```
|
|
@@ -35,7 +35,7 @@ Get an API key at [veriphone.io](https://veriphone.io).
|
|
|
35
35
|
bun run dev verify "+4915123577723"
|
|
36
36
|
|
|
37
37
|
# With default country hint
|
|
38
|
-
bun run dev verify "
|
|
38
|
+
bun run dev verify "0151-23577723" --default-country DE
|
|
39
39
|
|
|
40
40
|
# Use POST method
|
|
41
41
|
bun run dev verify "+14155552671" --method post
|
|
@@ -29,7 +29,7 @@ bun test
|
|
|
29
29
|
## Authentication
|
|
30
30
|
|
|
31
31
|
- **Bearer token (dev):** Full-access token from Wave developer portal
|
|
32
|
-
- **OAuth2 (production):** Scopes per
|
|
32
|
+
- **OAuth2 (production):** Scopes per the Wave OAuth scopes documentation (developer.waveapps.com)
|
|
33
33
|
|
|
34
34
|
Auth type: `oauth` / `bearer`
|
|
35
35
|
|
|
@@ -6,7 +6,7 @@ const DEFAULT_AUTH_URL = 'https://api.waveapps.com/oauth2/authorize/';
|
|
|
6
6
|
const DEFAULT_TOKEN_URL = 'https://api.waveapps.com/oauth2/token/';
|
|
7
7
|
|
|
8
8
|
// Wave OAuth scopes for accounting/invoicing operations
|
|
9
|
-
//
|
|
9
|
+
// (see developer.waveapps.com OAuth scopes documentation)
|
|
10
10
|
const DEFAULT_SCOPES = [
|
|
11
11
|
'business:read',
|
|
12
12
|
'invoice:read',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { ConnectorClient } from './client';
|
|
3
|
+
import { Connector } from './index';
|
|
3
4
|
|
|
4
5
|
const realFetch = globalThis.fetch;
|
|
5
6
|
|
|
@@ -44,25 +45,25 @@ afterEach(() => {
|
|
|
44
45
|
describe('WeaviateApiPlatform client', () => {
|
|
45
46
|
test('uses bearer auth and default base URL for listItems', async () => {
|
|
46
47
|
const recorded = installFetch();
|
|
47
|
-
const client = new Connector({ apiKey: 'test-api-key' });
|
|
48
|
+
const client = new Connector({ apiKey: 'test-api-key', baseUrl: 'https://configured.example.com/v1' });
|
|
48
49
|
await client.listItems();
|
|
49
|
-
expect(recorded[0].url).toBe(
|
|
50
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/items`);
|
|
50
51
|
expect(recorded[0].method).toBe('GET');
|
|
51
52
|
expect(recorded[0].headers.authorization || recorded[0].headers.Authorization).toBe('Bearer test-api-key');
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
test('encodes item IDs in getItem path', async () => {
|
|
55
56
|
const recorded = installFetch();
|
|
56
|
-
const client = new Connector({ apiKey: 'test-api-key' });
|
|
57
|
+
const client = new Connector({ apiKey: 'test-api-key', baseUrl: 'https://configured.example.com/v1' });
|
|
57
58
|
await client.getItem('item/with/slash');
|
|
58
|
-
expect(recorded[0].url).toBe(
|
|
59
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/items/${encodeURIComponent('item/with/slash')}`);
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
test('posts search body to /search', async () => {
|
|
62
63
|
const recorded = installFetch();
|
|
63
|
-
const client = new Connector({ apiKey: 'test-api-key' });
|
|
64
|
+
const client = new Connector({ apiKey: 'test-api-key', baseUrl: 'https://configured.example.com/v1' });
|
|
64
65
|
await client.search({ query: 'hello', limit: 5 });
|
|
65
|
-
expect(recorded[0].url).toBe(
|
|
66
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/search`);
|
|
66
67
|
expect(recorded[0].method).toBe('POST');
|
|
67
68
|
expect(recorded[0].body).toBe(JSON.stringify({ query: 'hello', limit: 5 }));
|
|
68
69
|
});
|
|
@@ -80,4 +81,28 @@ describe('WeaviateApiPlatform client', () => {
|
|
|
80
81
|
test('requires API key', () => {
|
|
81
82
|
expect(() => new Connector({})).toThrow('API key is required');
|
|
82
83
|
});
|
|
84
|
+
|
|
85
|
+
test('refuses to send without a configured base URL (no default endpoint)', () => {
|
|
86
|
+
expect(() => new ConnectorClient({ apiKey: 'test-key' })).toThrow(/baseUrl/);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('sends the API key only to the configured base URL', async () => {
|
|
90
|
+
const recorded: string[] = [];
|
|
91
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
92
|
+
recorded.push(typeof input === 'string' ? input : input.toString());
|
|
93
|
+
return {
|
|
94
|
+
ok: true,
|
|
95
|
+
status: 200,
|
|
96
|
+
statusText: 'OK',
|
|
97
|
+
headers: new Headers({ 'content-type': 'application/json' }),
|
|
98
|
+
async text() { return JSON.stringify({ ok: true }); },
|
|
99
|
+
async json() { return { ok: true }; },
|
|
100
|
+
} as Response;
|
|
101
|
+
}) as typeof fetch;
|
|
102
|
+
const client = new ConnectorClient({ apiKey: 'test-key', baseUrl: 'https://configured.example.com/v1' });
|
|
103
|
+
await client.request('/ping');
|
|
104
|
+
expect(recorded).toHaveLength(1);
|
|
105
|
+
expect(recorded[0].startsWith('https://configured.example.com/v1/')).toBe(true);
|
|
106
|
+
expect(recorded[0]).not.toContain('api.weaviateapiplatform.com');
|
|
107
|
+
});
|
|
83
108
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ConnectorConfig, RawRequestOptions } from '../types';
|
|
2
2
|
import { ConnectorApiError, parseApiError } from '../types';
|
|
3
3
|
|
|
4
|
-
export const DEFAULT_BASE_URL = 'https://api.weaviateapiplatform.com/v1';
|
|
5
|
-
|
|
6
4
|
export interface RequestOptions {
|
|
7
5
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
8
6
|
params?: Record<string, string | number | boolean | undefined>;
|
|
@@ -22,7 +20,10 @@ export class ConnectorClient {
|
|
|
22
20
|
throw new Error('Weaviate API Platform API key is required');
|
|
23
21
|
}
|
|
24
22
|
this.apiKey = key;
|
|
25
|
-
|
|
23
|
+
if (!config.baseUrl) {
|
|
24
|
+
throw new Error('baseUrl is required: no default endpoint is configured; set baseUrl (profile, config, or the connector BASE_URL environment variable)');
|
|
25
|
+
}
|
|
26
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
getBaseUrl(): string {
|
|
@@ -166,7 +166,7 @@ configCmd.command('show').description('Show current configuration').action(() =>
|
|
|
166
166
|
console.log(chalk.bold(`Active Profile: ${profileName}`));
|
|
167
167
|
info(`Config directory: ${getConfigDir()}`);
|
|
168
168
|
info(`API Key: ${apiKey ? `${apiKey.substring(0, 8)}...` : chalk.gray('not set')}`);
|
|
169
|
-
info(`Base URL: ${baseUrl || chalk.gray('
|
|
169
|
+
info(`Base URL: ${baseUrl || chalk.gray('none configured')}`);
|
|
170
170
|
});
|
|
171
171
|
|
|
172
172
|
configCmd.command('clear').description('Clear configuration for active profile').action(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# WorkflowTrigger API credentials (placeholders only)
|
|
2
2
|
WORKFLOW_TRIGGER_API_KEY=your-api-key-here
|
|
3
3
|
|
|
4
|
-
# Optional: override API base URL (default
|
|
4
|
+
# Optional: override API base URL (no default - must be configured)
|
|
5
5
|
# WORKFLOW_TRIGGER_BASE_URL=https://api.workflow-trigger.com/v1
|
|
@@ -56,7 +56,7 @@ src/
|
|
|
56
56
|
|
|
57
57
|
## API Details
|
|
58
58
|
|
|
59
|
-
- **Base URL**:
|
|
59
|
+
- **Base URL**: no default (must be configured) (override with `WORKFLOW_TRIGGER_BASE_URL`)
|
|
60
60
|
- **Auth**: Bearer token (`Authorization: Bearer <api_key>`)
|
|
61
61
|
- **Endpoints**:
|
|
62
62
|
- `GET /triggers` - List triggers
|
|
@@ -13,7 +13,7 @@ bun install
|
|
|
13
13
|
```bash
|
|
14
14
|
export WORKFLOW_TRIGGER_API_KEY=your-api-key
|
|
15
15
|
# optional:
|
|
16
|
-
export WORKFLOW_TRIGGER_BASE_URL=https://
|
|
16
|
+
export WORKFLOW_TRIGGER_BASE_URL=https://configured.example.com/v1
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Or use the CLI profile:
|
|
@@ -54,22 +54,22 @@ describe('WorkflowTrigger API client', () => {
|
|
|
54
54
|
|
|
55
55
|
test('list triggers uses Bearer auth and GET /triggers', async () => {
|
|
56
56
|
const recorded = installFetch(() => ({ data: [] }));
|
|
57
|
-
const client = new ConnectorClient({ apiKey: 'test-key' });
|
|
57
|
+
const client = new ConnectorClient({ apiKey: 'test-key', baseUrl: 'https://configured.example.com/v1' });
|
|
58
58
|
await client.get('/triggers');
|
|
59
59
|
|
|
60
60
|
expect(recorded).toHaveLength(1);
|
|
61
|
-
expect(recorded[0].url).toBe('https://
|
|
61
|
+
expect(recorded[0].url).toBe('https://configured.example.com/v1/triggers');
|
|
62
62
|
expect(recorded[0].method).toBe('GET');
|
|
63
63
|
expect(recorded[0].headers.Authorization || recorded[0].headers.authorization).toBe('Bearer test-key');
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
test('get trigger encodes ID in path', async () => {
|
|
67
67
|
const recorded = installFetch(() => ({ id: 'item-1' }));
|
|
68
|
-
const connector = new Connector({ apiKey: 'workflow-trigger-key' });
|
|
68
|
+
const connector = new Connector({ apiKey: 'workflow-trigger-key', baseUrl: 'https://configured.example.com/v1' });
|
|
69
69
|
await connector.triggers.get('item-1');
|
|
70
70
|
|
|
71
71
|
expect(recorded).toHaveLength(1);
|
|
72
|
-
expect(recorded[0].url).toBe('https://
|
|
72
|
+
expect(recorded[0].url).toBe('https://configured.example.com/v1/triggers/item-1');
|
|
73
73
|
expect(recorded[0].headers.Authorization || recorded[0].headers.authorization).toBe('Bearer workflow-trigger-key');
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -86,10 +86,14 @@ describe('WorkflowTrigger API client', () => {
|
|
|
86
86
|
|
|
87
87
|
test('search posts to /search', async () => {
|
|
88
88
|
const recorded = installFetch(() => ({ results: [] }));
|
|
89
|
-
const connector = new Connector({ apiKey: 'key' });
|
|
89
|
+
const connector = new Connector({ apiKey: 'key', baseUrl: 'https://configured.example.com/v1' });
|
|
90
90
|
await connector.search.search({ query: 'test' });
|
|
91
91
|
|
|
92
|
-
expect(recorded[0].url).toBe('https://
|
|
92
|
+
expect(recorded[0].url).toBe('https://configured.example.com/v1/search');
|
|
93
93
|
expect(recorded[0].method).toBe('POST');
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
test('refuses to send without a configured base URL (no default endpoint)', () => {
|
|
97
|
+
expect(() => new ConnectorClient({ apiKey: 'test-key' })).toThrow(/baseUrl/);
|
|
98
|
+
});
|
|
95
99
|
});
|
|
@@ -2,8 +2,6 @@ import type { ConnectorConfig } from '../types';
|
|
|
2
2
|
import { ConnectorApiError, parseApiError } from '../types';
|
|
3
3
|
import type { RawRequestParams } from '../types';
|
|
4
4
|
|
|
5
|
-
const DEFAULT_BASE_URL = 'https://api.workflow-trigger.com/v1';
|
|
6
|
-
|
|
7
5
|
export interface RequestOptions {
|
|
8
6
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
9
7
|
params?: Record<string, string | number | boolean | undefined>;
|
|
@@ -23,7 +21,10 @@ export class ConnectorClient {
|
|
|
23
21
|
throw new Error('WorkflowTrigger API key is required');
|
|
24
22
|
}
|
|
25
23
|
this.apiKey = key;
|
|
26
|
-
|
|
24
|
+
if (!config.baseUrl) {
|
|
25
|
+
throw new Error('baseUrl is required: no default endpoint is configured; set baseUrl (profile, config, or the connector BASE_URL environment variable)');
|
|
26
|
+
}
|
|
27
|
+
this.baseUrl = config.baseUrl;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
private buildUrl(path: string, params?: Record<string, string | number | boolean | undefined>): string {
|
|
@@ -204,7 +204,7 @@ configCmd
|
|
|
204
204
|
console.log(chalk.bold(`Active Profile: ${profileName}`));
|
|
205
205
|
info(`Config directory: ${getConfigDir()}`);
|
|
206
206
|
info(`API Key: ${apiKey ? `${apiKey.substring(0, 8)}...` : chalk.gray('not set')}`);
|
|
207
|
-
info(`Base URL: ${baseUrl || chalk.gray('
|
|
207
|
+
info(`Base URL: ${baseUrl || chalk.gray('none configured')}`);
|
|
208
208
|
});
|
|
209
209
|
|
|
210
210
|
configCmd
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { WriteBinaryFileClient } from './client';
|
|
3
3
|
|
|
4
4
|
const realFetch = globalThis.fetch;
|
|
5
5
|
|
|
@@ -36,46 +36,50 @@ afterEach(() => {
|
|
|
36
36
|
describe('WriteBinaryFileClient transport', () => {
|
|
37
37
|
test('listFiles uses bearer auth and default base URL', async () => {
|
|
38
38
|
const recorded = installFetch();
|
|
39
|
-
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key' });
|
|
39
|
+
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key', baseUrl: 'https://configured.example.com/v1' });
|
|
40
40
|
await client.listFiles();
|
|
41
|
-
expect(recorded[0].url).toBe(
|
|
41
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/files`);
|
|
42
42
|
expect(recorded[0].method).toBe('GET');
|
|
43
43
|
expect(recorded[0].headers.get('Authorization')).toBe('Bearer write-binary-file-key');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test('getFile encodes file id in path', async () => {
|
|
47
47
|
const recorded = installFetch();
|
|
48
|
-
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key' });
|
|
48
|
+
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key', baseUrl: 'https://configured.example.com/v1' });
|
|
49
49
|
await client.getFile('item-1');
|
|
50
|
-
expect(recorded[0].url).toBe(
|
|
50
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/files/item-1`);
|
|
51
51
|
expect(recorded[0].headers.get('Authorization')).toBe('Bearer write-binary-file-key');
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
test('createFile posts JSON body', async () => {
|
|
55
55
|
const recorded = installFetch();
|
|
56
|
-
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key' });
|
|
56
|
+
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key', baseUrl: 'https://configured.example.com/v1' });
|
|
57
57
|
await client.createFile({ name: 'demo.bin' });
|
|
58
|
-
expect(recorded[0].url).toBe(
|
|
58
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/files`);
|
|
59
59
|
expect(recorded[0].method).toBe('POST');
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
test('search posts to /search', async () => {
|
|
63
63
|
const recorded = installFetch();
|
|
64
|
-
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key' });
|
|
64
|
+
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key', baseUrl: 'https://configured.example.com/v1' });
|
|
65
65
|
await client.search({ q: 'report' });
|
|
66
|
-
expect(recorded[0].url).toBe(
|
|
66
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/search`);
|
|
67
67
|
expect(recorded[0].method).toBe('POST');
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
test('rawRequest honors custom path and method', async () => {
|
|
71
71
|
const recorded = installFetch();
|
|
72
|
-
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key' });
|
|
72
|
+
const client = new WriteBinaryFileClient({ apiKey: 'write-binary-file-key', baseUrl: 'https://configured.example.com/v1' });
|
|
73
73
|
await client.rawRequest({ path: '/events', method: 'GET', query: { limit: 5 } });
|
|
74
|
-
expect(recorded[0].url).toBe(
|
|
74
|
+
expect(recorded[0].url).toBe(`https://configured.example.com/v1/events?limit=5`);
|
|
75
75
|
expect(recorded[0].method).toBe('GET');
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
test('requires api key', () => {
|
|
79
|
-
expect(() => new WriteBinaryFileClient({ apiKey: '' })).toThrow('API key is required');
|
|
79
|
+
expect(() => new WriteBinaryFileClient({ apiKey: '', baseUrl: 'https://configured.example.com/v1' })).toThrow('API key is required');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('refuses to send without a configured base URL (no default endpoint)', () => {
|
|
83
|
+
expect(() => new WriteBinaryFileClient({ apiKey: 'test-key' })).toThrow(/baseUrl/);
|
|
80
84
|
});
|
|
81
85
|
});
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
type WriteBinaryFileConfig,
|
|
7
7
|
} from '../types';
|
|
8
8
|
|
|
9
|
-
export const DEFAULT_BASE_URL = 'https://api.write-binary-file.com/v1';
|
|
10
|
-
|
|
11
9
|
export function encodePathSegment(value: string): string {
|
|
12
10
|
return encodeURIComponent(value);
|
|
13
11
|
}
|
|
@@ -32,7 +30,10 @@ export class WriteBinaryFileClient {
|
|
|
32
30
|
throw new Error('API key is required');
|
|
33
31
|
}
|
|
34
32
|
this.apiKey = config.apiKey;
|
|
35
|
-
|
|
33
|
+
if (!config.baseUrl) {
|
|
34
|
+
throw new Error('baseUrl is required: no default endpoint is configured; set baseUrl (profile, config, or the connector BASE_URL environment variable)');
|
|
35
|
+
}
|
|
36
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
private buildUrl(path: string, query?: Record<string, string | number | boolean | undefined>): string {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { WuBookrateClient } from './client';
|
|
3
|
+
|
|
4
|
+
const realFetch = globalThis.fetch;
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
globalThis.fetch = realFetch;
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('WuBookrateClient transport', () => {
|
|
11
|
+
test('refuses to send without a configured base URL (no default endpoint)', () => {
|
|
12
|
+
expect(() => new WuBookrateClient({ apiKey: 'test-key' })).toThrow(/baseUrl/);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('sends the API key only to the configured base URL', async () => {
|
|
16
|
+
const recorded: string[] = [];
|
|
17
|
+
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
|
|
18
|
+
recorded.push(typeof input === 'string' ? input : input.toString());
|
|
19
|
+
return {
|
|
20
|
+
ok: true,
|
|
21
|
+
status: 200,
|
|
22
|
+
statusText: 'OK',
|
|
23
|
+
headers: new Headers({ 'content-type': 'application/json' }),
|
|
24
|
+
async text() { return JSON.stringify({ ok: true }); },
|
|
25
|
+
async json() { return { ok: true }; },
|
|
26
|
+
} as Response;
|
|
27
|
+
}) as typeof fetch;
|
|
28
|
+
const client = new WuBookrateClient({ apiKey: 'test-key', baseUrl: 'https://configured.example.com/v1' });
|
|
29
|
+
await client.request('/ping');
|
|
30
|
+
expect(recorded).toHaveLength(1);
|
|
31
|
+
expect(recorded[0].startsWith('https://configured.example.com/v1/')).toBe(true);
|
|
32
|
+
expect(recorded[0]).not.toContain('api.wubookratechecker.com');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -3,11 +3,13 @@ import { WuBookrateApiError } from '../types';
|
|
|
3
3
|
|
|
4
4
|
export class WuBookrateClient {
|
|
5
5
|
private readonly apiKey: string;
|
|
6
|
-
private readonly baseUrl
|
|
6
|
+
private readonly baseUrl: string;
|
|
7
7
|
|
|
8
8
|
constructor(config: WuBookrateConfig) {
|
|
9
9
|
if (!config.apiKey) throw new Error('Wu Bookrate Checker apiKey is required');
|
|
10
|
+
if (!config.baseUrl) throw new Error('baseUrl is required: no default endpoint is configured; set baseUrl (profile, config, or the connector BASE_URL environment variable)');
|
|
10
11
|
this.apiKey = config.apiKey;
|
|
12
|
+
this.baseUrl = config.baseUrl;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
async request<T>(path: string, params?: Record<string, string | number | undefined>): Promise<T> {
|
|
@@ -9,7 +9,7 @@ export class WuBookrateChecker {
|
|
|
9
9
|
static fromEnv(): WuBookrateChecker {
|
|
10
10
|
const apiKey = process.env.WUBOOKRATE_API_KEY;
|
|
11
11
|
if (!apiKey) throw new Error('WUBOOKRATE_API_KEY is required');
|
|
12
|
-
return new WuBookrateChecker({ apiKey });
|
|
12
|
+
return new WuBookrateChecker({ apiKey, baseUrl: process.env.WUBOOKRATE_BASE_URL });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async lookupByISBN(isbn: string): Promise<WBBook> { return this.client.request<WBBook>(`/books/${isbn}`); }
|