@parallelworks/client 6.12.0
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/README.md +114 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +245 -0
- package/dist/index.js.map +1 -0
- package/dist/swr/index.d.ts +44 -0
- package/dist/swr/index.d.ts.map +1 -0
- package/dist/swr/index.js +43 -0
- package/dist/swr/index.js.map +1 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @parallelworks/client
|
|
2
|
+
|
|
3
|
+
Official TypeScript client for the Parallel Works ACTIVATE platform API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @parallelworks/client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For SWR hooks support (React):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @parallelworks/client swr swr-openapi
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
The simplest way to create a client - just pass your credential:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Client } from '@parallelworks/client'
|
|
23
|
+
|
|
24
|
+
// The platform host is automatically extracted from your credential
|
|
25
|
+
const client = Client.fromCredential(process.env.PW_API_KEY!)
|
|
26
|
+
|
|
27
|
+
const { data, error } = await client.GET('/api/buckets')
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See the [examples](./examples) directory for complete runnable examples.
|
|
31
|
+
|
|
32
|
+
## Authentication
|
|
33
|
+
|
|
34
|
+
### Automatic Host Detection
|
|
35
|
+
|
|
36
|
+
API keys (`pwt_...`) and JWT tokens contain the platform host encoded within them. Use `fromCredential` to automatically extract it:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// API key - host decoded from first segment after pwt_
|
|
40
|
+
const client = Client.fromCredential('pwt_Y2xvdWQucGFyYWxsZWwud29ya3M.xxxxx')
|
|
41
|
+
// Connects to: https://activate.parallel.works
|
|
42
|
+
|
|
43
|
+
// JWT token - host read from platform_host claim
|
|
44
|
+
const client = Client.fromCredential('eyJhbGci...')
|
|
45
|
+
// Connects to the host in the token's platform_host claim
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Explicit Host
|
|
49
|
+
|
|
50
|
+
If you prefer to specify the host explicitly:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// API Key (Basic Auth) - best for long-running integrations
|
|
54
|
+
const client = new Client('https://activate.parallel.works')
|
|
55
|
+
.withApiKey('pwt_...')
|
|
56
|
+
|
|
57
|
+
// JWT Token (Bearer) - best for scripts, expires in 24h
|
|
58
|
+
const client = new Client('https://activate.parallel.works')
|
|
59
|
+
.withToken('eyJhbGci...')
|
|
60
|
+
|
|
61
|
+
// Auto-detect credential type
|
|
62
|
+
const client = new Client('https://activate.parallel.works')
|
|
63
|
+
.withCredential(process.env.PW_CREDENTIAL!)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Credential Helpers
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { isApiKey, isToken, extractPlatformHost } from '@parallelworks/client'
|
|
70
|
+
|
|
71
|
+
isApiKey('pwt_abc.xyz') // true
|
|
72
|
+
isToken('eyJ.abc.def') // true
|
|
73
|
+
extractPlatformHost('pwt_...') // "activate.parallel.works"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## SWR Hooks (React)
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
// lib/api.ts
|
|
80
|
+
import { Client } from '@parallelworks/client'
|
|
81
|
+
import { createSwrHooks } from '@parallelworks/client/swr'
|
|
82
|
+
|
|
83
|
+
const client = Client.fromCredential(process.env.NEXT_PUBLIC_PW_API_KEY!)
|
|
84
|
+
|
|
85
|
+
export const { useQuery, useImmutable, useInfinite } = createSwrHooks(client)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
// components/BucketList.tsx
|
|
90
|
+
import { useQuery } from '@/lib/api'
|
|
91
|
+
|
|
92
|
+
export function BucketList() {
|
|
93
|
+
const { data, error, isLoading } = useQuery('/api/buckets')
|
|
94
|
+
|
|
95
|
+
if (isLoading) return <div>Loading...</div>
|
|
96
|
+
if (error) return <div>Error: {error.message}</div>
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<ul>
|
|
100
|
+
{data?.map(bucket => (
|
|
101
|
+
<li key={bucket.id}>{bucket.name}</li>
|
|
102
|
+
))}
|
|
103
|
+
</ul>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
For full API documentation, visit [https://parallelworks.com/docs](https://parallelworks.com/docs).
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import createClient, { type ClientOptions as OpenAPIClientOptions } from 'openapi-fetch';
|
|
2
|
+
import type { paths } from './types/api';
|
|
3
|
+
export type { paths };
|
|
4
|
+
export type { components } from './types/api';
|
|
5
|
+
type OpenAPIFetchClient = ReturnType<typeof createClient<paths>>;
|
|
6
|
+
export interface ClientOptions extends Omit<OpenAPIClientOptions, 'baseUrl'> {
|
|
7
|
+
}
|
|
8
|
+
/** Prefix for Parallel Works API keys */
|
|
9
|
+
export declare const API_KEY_PREFIX = "pwt_";
|
|
10
|
+
/** Error thrown when credential parsing fails */
|
|
11
|
+
export declare class CredentialError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if a credential is an API key.
|
|
16
|
+
*
|
|
17
|
+
* API keys start with the prefix "pwt_".
|
|
18
|
+
*
|
|
19
|
+
* @param credential - The credential string to check
|
|
20
|
+
* @returns True if the credential appears to be an API key
|
|
21
|
+
*/
|
|
22
|
+
export declare function isApiKey(credential: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a credential is a JWT token.
|
|
25
|
+
*
|
|
26
|
+
* JWTs have three base64-encoded parts separated by dots.
|
|
27
|
+
*
|
|
28
|
+
* @param credential - The credential string to check
|
|
29
|
+
* @returns True if the credential appears to be a JWT token
|
|
30
|
+
*/
|
|
31
|
+
export declare function isToken(credential: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Extract the platform host from an API key or JWT token.
|
|
34
|
+
*
|
|
35
|
+
* For API keys (pwt_xxxx.yyyy): decodes the first part after pwt_ to get the host
|
|
36
|
+
* For JWT tokens: decodes the payload (second segment) and reads platform_host field
|
|
37
|
+
*
|
|
38
|
+
* @param credential - The API key or JWT token
|
|
39
|
+
* @returns The platform host (e.g., "activate.parallel.works")
|
|
40
|
+
* @throws CredentialError if the credential format is invalid
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractPlatformHost(credential: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Parallel Works API Client
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { Client } from '@parallelworks/client'
|
|
49
|
+
*
|
|
50
|
+
* // Using API Key (Basic Auth) - recommended for integrations
|
|
51
|
+
* const client = new Client('https://activate.parallel.works')
|
|
52
|
+
* .withApiKey('pwt_...')
|
|
53
|
+
*
|
|
54
|
+
* // Using Bearer Token (JWT) - for scripts
|
|
55
|
+
* const client = new Client('https://activate.parallel.works')
|
|
56
|
+
* .withToken('eyJ...')
|
|
57
|
+
*
|
|
58
|
+
* // Or let the client extract the host from your credential
|
|
59
|
+
* const client = Client.fromCredential(process.env.PW_API_KEY!)
|
|
60
|
+
*
|
|
61
|
+
* // Make requests
|
|
62
|
+
* const { data, error } = await client.GET('/api/buckets')
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare class Client {
|
|
66
|
+
private baseUrl;
|
|
67
|
+
private options;
|
|
68
|
+
private authHeader?;
|
|
69
|
+
constructor(baseUrl: string, options?: ClientOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Create a client using only a credential.
|
|
72
|
+
*
|
|
73
|
+
* The platform host is automatically extracted from the credential:
|
|
74
|
+
* - For API keys: host is decoded from the first part after pwt_
|
|
75
|
+
* - For JWT tokens: host is read from the platform_host claim
|
|
76
|
+
*
|
|
77
|
+
* @param credential - Your API key or JWT token
|
|
78
|
+
* @param options - Additional client options
|
|
79
|
+
* @returns Configured API client ready to make requests
|
|
80
|
+
* @throws CredentialError if the credential format is invalid
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* // Just pass your credential - no URL needed!
|
|
85
|
+
* const client = Client.fromCredential(process.env.PW_API_KEY!)
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static fromCredential(credential: string, options?: ClientOptions): OpenAPIFetchClient;
|
|
89
|
+
/**
|
|
90
|
+
* Authenticate with an API Key using Basic Auth
|
|
91
|
+
*
|
|
92
|
+
* Best for long-running integrations with configurable expiration.
|
|
93
|
+
* API keys can be generated from your ACTIVATE account settings.
|
|
94
|
+
*
|
|
95
|
+
* @param apiKey - Your API key from account settings
|
|
96
|
+
* @returns Configured API client ready to make requests
|
|
97
|
+
*/
|
|
98
|
+
withApiKey(apiKey: string): OpenAPIFetchClient;
|
|
99
|
+
/**
|
|
100
|
+
* Authenticate with a Bearer Token (JWT)
|
|
101
|
+
*
|
|
102
|
+
* Best for scripts and CLI tools. Tokens expire after 24 hours.
|
|
103
|
+
* Tokens can be generated from your ACTIVATE account settings.
|
|
104
|
+
*
|
|
105
|
+
* @param token - Your JWT token from account settings
|
|
106
|
+
* @returns Configured API client ready to make requests
|
|
107
|
+
*/
|
|
108
|
+
withToken(token: string): OpenAPIFetchClient;
|
|
109
|
+
/**
|
|
110
|
+
* Authenticate with automatic credential type detection
|
|
111
|
+
*
|
|
112
|
+
* Automatically detects whether the credential is an API key (starts with "pwt_")
|
|
113
|
+
* or a JWT token and configures the appropriate authentication method.
|
|
114
|
+
*
|
|
115
|
+
* @param credential - Your API key or JWT token
|
|
116
|
+
* @returns Configured API client ready to make requests
|
|
117
|
+
*/
|
|
118
|
+
withCredential(credential: string): OpenAPIFetchClient;
|
|
119
|
+
private build;
|
|
120
|
+
}
|
|
121
|
+
export default Client;
|
|
122
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAE,KAAK,aAAa,IAAI,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACxF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,YAAY,EAAE,KAAK,EAAE,CAAA;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;AAEhE,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;CAAG;AAE/E,yCAAyC;AACzC,eAAO,MAAM,cAAc,SAAS,CAAA;AAEpC,iDAAiD;AACjD,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAInD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAS9D;AAoFD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,UAAU,CAAC,CAAQ;gBAEf,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAKxD;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,kBAAkB;IAW1F;;;;;;;;OAQG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB;IAW9C;;;;;;;;OAQG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;IAM5C;;;;;;;;OAQG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB;IAOtD,OAAO,CAAC,KAAK;CAUd;AAED,eAAe,MAAM,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import createClient from 'openapi-fetch';
|
|
2
|
+
/** Prefix for Parallel Works API keys */
|
|
3
|
+
export const API_KEY_PREFIX = 'pwt_';
|
|
4
|
+
/** Error thrown when credential parsing fails */
|
|
5
|
+
export class CredentialError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'CredentialError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check if a credential is an API key.
|
|
13
|
+
*
|
|
14
|
+
* API keys start with the prefix "pwt_".
|
|
15
|
+
*
|
|
16
|
+
* @param credential - The credential string to check
|
|
17
|
+
* @returns True if the credential appears to be an API key
|
|
18
|
+
*/
|
|
19
|
+
export function isApiKey(credential) {
|
|
20
|
+
return credential.trim().startsWith(API_KEY_PREFIX);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if a credential is a JWT token.
|
|
24
|
+
*
|
|
25
|
+
* JWTs have three base64-encoded parts separated by dots.
|
|
26
|
+
*
|
|
27
|
+
* @param credential - The credential string to check
|
|
28
|
+
* @returns True if the credential appears to be a JWT token
|
|
29
|
+
*/
|
|
30
|
+
export function isToken(credential) {
|
|
31
|
+
const trimmed = credential.trim();
|
|
32
|
+
const parts = trimmed.split('.');
|
|
33
|
+
return parts.length === 3 && !trimmed.startsWith(API_KEY_PREFIX);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extract the platform host from an API key or JWT token.
|
|
37
|
+
*
|
|
38
|
+
* For API keys (pwt_xxxx.yyyy): decodes the first part after pwt_ to get the host
|
|
39
|
+
* For JWT tokens: decodes the payload (second segment) and reads platform_host field
|
|
40
|
+
*
|
|
41
|
+
* @param credential - The API key or JWT token
|
|
42
|
+
* @returns The platform host (e.g., "activate.parallel.works")
|
|
43
|
+
* @throws CredentialError if the credential format is invalid
|
|
44
|
+
*/
|
|
45
|
+
export function extractPlatformHost(credential) {
|
|
46
|
+
credential = credential.trim();
|
|
47
|
+
if (isApiKey(credential)) {
|
|
48
|
+
return extractHostFromApiKey(credential);
|
|
49
|
+
}
|
|
50
|
+
if (isToken(credential)) {
|
|
51
|
+
return extractHostFromToken(credential);
|
|
52
|
+
}
|
|
53
|
+
throw new CredentialError('Invalid credential format');
|
|
54
|
+
}
|
|
55
|
+
function extractHostFromApiKey(apiKey) {
|
|
56
|
+
// Remove pwt_ prefix
|
|
57
|
+
const withoutPrefix = apiKey.slice(API_KEY_PREFIX.length);
|
|
58
|
+
// Split by dot
|
|
59
|
+
const dotIndex = withoutPrefix.indexOf('.');
|
|
60
|
+
if (dotIndex === -1) {
|
|
61
|
+
throw new CredentialError('Invalid API key format');
|
|
62
|
+
}
|
|
63
|
+
const encodedHost = withoutPrefix.slice(0, dotIndex);
|
|
64
|
+
// Decode base64 (handle both browser and Node.js)
|
|
65
|
+
let host;
|
|
66
|
+
try {
|
|
67
|
+
if (typeof atob !== 'undefined') {
|
|
68
|
+
// Browser - handle URL-safe base64
|
|
69
|
+
const normalized = encodedHost.replace(/-/g, '+').replace(/_/g, '/');
|
|
70
|
+
host = atob(normalized);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// Node.js
|
|
74
|
+
host = Buffer.from(encodedHost, 'base64url').toString();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
try {
|
|
79
|
+
// Fallback to standard base64
|
|
80
|
+
if (typeof atob !== 'undefined') {
|
|
81
|
+
host = atob(encodedHost);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
host = Buffer.from(encodedHost, 'base64').toString();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
throw new CredentialError(`Could not decode API key host: ${e}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!host) {
|
|
92
|
+
throw new CredentialError('No platform host in API key');
|
|
93
|
+
}
|
|
94
|
+
return host;
|
|
95
|
+
}
|
|
96
|
+
function extractHostFromToken(token) {
|
|
97
|
+
const parts = token.split('.');
|
|
98
|
+
if (parts.length !== 3) {
|
|
99
|
+
throw new CredentialError('Invalid JWT format');
|
|
100
|
+
}
|
|
101
|
+
const payload = parts[1];
|
|
102
|
+
// Decode base64url payload
|
|
103
|
+
let payloadJson;
|
|
104
|
+
try {
|
|
105
|
+
if (typeof atob !== 'undefined') {
|
|
106
|
+
// Browser - handle URL-safe base64
|
|
107
|
+
const normalized = payload.replace(/-/g, '+').replace(/_/g, '/');
|
|
108
|
+
// Add padding if needed
|
|
109
|
+
const padded = normalized + '='.repeat((4 - (normalized.length % 4)) % 4);
|
|
110
|
+
payloadJson = atob(padded);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// Node.js
|
|
114
|
+
payloadJson = Buffer.from(payload, 'base64url').toString();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
throw new CredentialError(`Could not decode JWT payload: ${e}`);
|
|
119
|
+
}
|
|
120
|
+
let claims;
|
|
121
|
+
try {
|
|
122
|
+
claims = JSON.parse(payloadJson);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
throw new CredentialError(`Could not parse JWT claims: ${e}`);
|
|
126
|
+
}
|
|
127
|
+
if (!claims.platform_host) {
|
|
128
|
+
throw new CredentialError('No platform_host in JWT claims');
|
|
129
|
+
}
|
|
130
|
+
return claims.platform_host;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Parallel Works API Client
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { Client } from '@parallelworks/client'
|
|
138
|
+
*
|
|
139
|
+
* // Using API Key (Basic Auth) - recommended for integrations
|
|
140
|
+
* const client = new Client('https://activate.parallel.works')
|
|
141
|
+
* .withApiKey('pwt_...')
|
|
142
|
+
*
|
|
143
|
+
* // Using Bearer Token (JWT) - for scripts
|
|
144
|
+
* const client = new Client('https://activate.parallel.works')
|
|
145
|
+
* .withToken('eyJ...')
|
|
146
|
+
*
|
|
147
|
+
* // Or let the client extract the host from your credential
|
|
148
|
+
* const client = Client.fromCredential(process.env.PW_API_KEY!)
|
|
149
|
+
*
|
|
150
|
+
* // Make requests
|
|
151
|
+
* const { data, error } = await client.GET('/api/buckets')
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export class Client {
|
|
155
|
+
constructor(baseUrl, options = {}) {
|
|
156
|
+
this.baseUrl = baseUrl;
|
|
157
|
+
this.options = options;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a client using only a credential.
|
|
161
|
+
*
|
|
162
|
+
* The platform host is automatically extracted from the credential:
|
|
163
|
+
* - For API keys: host is decoded from the first part after pwt_
|
|
164
|
+
* - For JWT tokens: host is read from the platform_host claim
|
|
165
|
+
*
|
|
166
|
+
* @param credential - Your API key or JWT token
|
|
167
|
+
* @param options - Additional client options
|
|
168
|
+
* @returns Configured API client ready to make requests
|
|
169
|
+
* @throws CredentialError if the credential format is invalid
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* // Just pass your credential - no URL needed!
|
|
174
|
+
* const client = Client.fromCredential(process.env.PW_API_KEY!)
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
static fromCredential(credential, options = {}) {
|
|
178
|
+
let host = extractPlatformHost(credential);
|
|
179
|
+
// Ensure https:// prefix
|
|
180
|
+
if (!host.startsWith('http://') && !host.startsWith('https://')) {
|
|
181
|
+
host = `https://${host}`;
|
|
182
|
+
}
|
|
183
|
+
return new Client(host, options).withCredential(credential);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Authenticate with an API Key using Basic Auth
|
|
187
|
+
*
|
|
188
|
+
* Best for long-running integrations with configurable expiration.
|
|
189
|
+
* API keys can be generated from your ACTIVATE account settings.
|
|
190
|
+
*
|
|
191
|
+
* @param apiKey - Your API key from account settings
|
|
192
|
+
* @returns Configured API client ready to make requests
|
|
193
|
+
*/
|
|
194
|
+
withApiKey(apiKey) {
|
|
195
|
+
// Trim whitespace to handle env vars with trailing newlines
|
|
196
|
+
apiKey = apiKey.trim();
|
|
197
|
+
// API Keys use Basic Auth with base64(apiKey:)
|
|
198
|
+
const encoded = typeof btoa !== 'undefined'
|
|
199
|
+
? btoa(`${apiKey}:`)
|
|
200
|
+
: Buffer.from(`${apiKey}:`).toString('base64');
|
|
201
|
+
this.authHeader = `Basic ${encoded}`;
|
|
202
|
+
return this.build();
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Authenticate with a Bearer Token (JWT)
|
|
206
|
+
*
|
|
207
|
+
* Best for scripts and CLI tools. Tokens expire after 24 hours.
|
|
208
|
+
* Tokens can be generated from your ACTIVATE account settings.
|
|
209
|
+
*
|
|
210
|
+
* @param token - Your JWT token from account settings
|
|
211
|
+
* @returns Configured API client ready to make requests
|
|
212
|
+
*/
|
|
213
|
+
withToken(token) {
|
|
214
|
+
// Trim whitespace to handle env vars with trailing newlines
|
|
215
|
+
this.authHeader = `Bearer ${token.trim()}`;
|
|
216
|
+
return this.build();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Authenticate with automatic credential type detection
|
|
220
|
+
*
|
|
221
|
+
* Automatically detects whether the credential is an API key (starts with "pwt_")
|
|
222
|
+
* or a JWT token and configures the appropriate authentication method.
|
|
223
|
+
*
|
|
224
|
+
* @param credential - Your API key or JWT token
|
|
225
|
+
* @returns Configured API client ready to make requests
|
|
226
|
+
*/
|
|
227
|
+
withCredential(credential) {
|
|
228
|
+
if (isApiKey(credential)) {
|
|
229
|
+
return this.withApiKey(credential);
|
|
230
|
+
}
|
|
231
|
+
return this.withToken(credential);
|
|
232
|
+
}
|
|
233
|
+
build() {
|
|
234
|
+
return createClient({
|
|
235
|
+
baseUrl: this.baseUrl,
|
|
236
|
+
...this.options,
|
|
237
|
+
headers: {
|
|
238
|
+
...(this.authHeader && { Authorization: this.authHeader }),
|
|
239
|
+
...this.options.headers,
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export default Client;
|
|
245
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAA4D,MAAM,eAAe,CAAA;AAUxF,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AAEpC,iDAAiD;AACjD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,UAAkB;IACzC,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;AACrD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC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ACP,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC1D,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO;aACxB;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Client } from '../index';
|
|
2
|
+
export interface SwrHooksOptions {
|
|
3
|
+
/** Key prefix for SWR cache (default: 'api') */
|
|
4
|
+
prefix?: string;
|
|
5
|
+
}
|
|
6
|
+
type AuthenticatedClient = ReturnType<Client['withApiKey']>;
|
|
7
|
+
/**
|
|
8
|
+
* Create SWR hooks from an authenticated Parallel Works client
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { Client } from '@parallelworks/client'
|
|
13
|
+
* import { createSwrHooks } from '@parallelworks/client/swr'
|
|
14
|
+
*
|
|
15
|
+
* const client = new Client('https://activate.parallel.works')
|
|
16
|
+
* .withApiKey(process.env.NEXT_PUBLIC_PW_API_KEY!)
|
|
17
|
+
*
|
|
18
|
+
* export const { useQuery, useImmutable, useInfinite } = createSwrHooks(client)
|
|
19
|
+
*
|
|
20
|
+
* // In your component
|
|
21
|
+
* function BucketList() {
|
|
22
|
+
* const { data, error, isLoading } = useQuery('/api/buckets')
|
|
23
|
+
*
|
|
24
|
+
* if (isLoading) return <div>Loading...</div>
|
|
25
|
+
* if (error) return <div>Error: {error.message}</div>
|
|
26
|
+
*
|
|
27
|
+
* return (
|
|
28
|
+
* <ul>
|
|
29
|
+
* {data?.map(org => <li key={org.id}>{org.name}</li>)}
|
|
30
|
+
* </ul>
|
|
31
|
+
* )
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createSwrHooks(client: AuthenticatedClient, options?: SwrHooksOptions): {
|
|
36
|
+
/** Hook for standard queries with SWR caching and revalidation */
|
|
37
|
+
useQuery: <Path extends import("openapi-typescript-helpers").PathsWithMethod<import("../index").paths, "get">, R extends import("swr-openapi").TypesForGetRequest<import("../index").paths, Path>, Init extends import("type-fest").Exact<R["Init"], Init>, Data extends R["Data"], Error extends R["Error"], Config extends R["SWRConfig"]>(path: Path, ...[init, config]: import("openapi-typescript-helpers").RequiredKeysOf<Init> extends never ? [(Init | null | undefined)?, (Config | undefined)?] : [Init | null, (Config | undefined)?]) => import("swr").SWRResponse<Data, Error, Config>;
|
|
38
|
+
/** Hook for immutable data that never revalidates */
|
|
39
|
+
useImmutable: <Path extends import("openapi-typescript-helpers").PathsWithMethod<import("../index").paths, "get">, R extends import("swr-openapi").TypesForGetRequest<import("../index").paths, Path>, Init extends import("type-fest").Exact<R["Init"], Init>, Data extends R["Data"], Error extends R["Error"], Config extends R["SWRConfig"]>(path: Path, ...[init, config]: import("openapi-typescript-helpers").RequiredKeysOf<Init> extends never ? [(Init | null | undefined)?, (Config | undefined)?] : [Init | null, (Config | undefined)?]) => import("swr").SWRResponse<Data, Error, Config>;
|
|
40
|
+
/** Hook for paginated/infinite loading */
|
|
41
|
+
useInfinite: <Path extends import("openapi-typescript-helpers").PathsWithMethod<import("../index").paths, "get">, R extends import("swr-openapi").TypesForGetRequest<import("../index").paths, Path>, Init extends import("type-fest").Exact<R["Init"], Init>, Data extends R["Data"], Error extends R["Error"], Config extends import("swr/infinite").SWRInfiniteConfiguration<Data, Error, import("swr").BareFetcher<Data>>>(path: Path, getInit: import("swr/infinite").SWRInfiniteKeyLoader<Data, Init | null>, config?: Config | undefined) => import("swr/infinite").SWRInfiniteResponse<Data, Error>;
|
|
42
|
+
};
|
|
43
|
+
export default createSwrHooks;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swr/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,KAAK,mBAAmB,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,GAAE,eAAoB;IAK3B,kEAAkE;;IAElE,qDAAqD;;IAErD,0CAA0C;;EAG7C;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createImmutableHook, createInfiniteHook, createQueryHook, } from 'swr-openapi';
|
|
3
|
+
/**
|
|
4
|
+
* Create SWR hooks from an authenticated Parallel Works client
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { Client } from '@parallelworks/client'
|
|
9
|
+
* import { createSwrHooks } from '@parallelworks/client/swr'
|
|
10
|
+
*
|
|
11
|
+
* const client = new Client('https://activate.parallel.works')
|
|
12
|
+
* .withApiKey(process.env.NEXT_PUBLIC_PW_API_KEY!)
|
|
13
|
+
*
|
|
14
|
+
* export const { useQuery, useImmutable, useInfinite } = createSwrHooks(client)
|
|
15
|
+
*
|
|
16
|
+
* // In your component
|
|
17
|
+
* function BucketList() {
|
|
18
|
+
* const { data, error, isLoading } = useQuery('/api/buckets')
|
|
19
|
+
*
|
|
20
|
+
* if (isLoading) return <div>Loading...</div>
|
|
21
|
+
* if (error) return <div>Error: {error.message}</div>
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <ul>
|
|
25
|
+
* {data?.map(org => <li key={org.id}>{org.name}</li>)}
|
|
26
|
+
* </ul>
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function createSwrHooks(client, options = {}) {
|
|
32
|
+
const { prefix = 'api' } = options;
|
|
33
|
+
return {
|
|
34
|
+
/** Hook for standard queries with SWR caching and revalidation */
|
|
35
|
+
useQuery: createQueryHook(client, prefix),
|
|
36
|
+
/** Hook for immutable data that never revalidates */
|
|
37
|
+
useImmutable: createImmutableHook(client, prefix),
|
|
38
|
+
/** Hook for paginated/infinite loading */
|
|
39
|
+
useInfinite: createInfiniteHook(client, prefix),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export default createSwrHooks;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/swr/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAChB,MAAM,aAAa,CAAA;AAUpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA2B,EAC3B,UAA2B,EAAE;IAE7B,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IAElC,OAAO;QACL,kEAAkE;QAClE,QAAQ,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC;QACzC,qDAAqD;QACrD,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC;QACjD,0CAA0C;QAC1C,WAAW,EAAE,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC;KAChD,CAAA;AACH,CAAC;AAED,eAAe,cAAc,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parallelworks/client",
|
|
3
|
+
"version": "6.12.0",
|
|
4
|
+
"description": "Official TypeScript client for Parallel Works ACTIVATE API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./swr": {
|
|
15
|
+
"import": "./dist/swr/index.js",
|
|
16
|
+
"types": "./dist/swr/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"openapi-fetch": "^0.15.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"swr": "^2.0.0",
|
|
27
|
+
"swr-openapi": "^5.0.0",
|
|
28
|
+
"openapi-typescript-helpers": "^0.0.15",
|
|
29
|
+
"type-fest": "^4.0.0 || ^5.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"swr": {
|
|
33
|
+
"optional": true
|
|
34
|
+
},
|
|
35
|
+
"swr-openapi": {
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
"openapi-typescript-helpers": {
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
"type-fest": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"openapi-typescript": "^7.9.1",
|
|
48
|
+
"openapi-typescript-helpers": "^0.0.15",
|
|
49
|
+
"type-fest": "^5.4.1",
|
|
50
|
+
"typescript": "^5.4.0",
|
|
51
|
+
"swr": "^2.3.6",
|
|
52
|
+
"swr-openapi": "^5.4.1"
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/parallelworks/sdk.git",
|
|
57
|
+
"directory": "typescript"
|
|
58
|
+
},
|
|
59
|
+
"keywords": [
|
|
60
|
+
"parallelworks",
|
|
61
|
+
"client",
|
|
62
|
+
"api",
|
|
63
|
+
"activate",
|
|
64
|
+
"openapi"
|
|
65
|
+
],
|
|
66
|
+
"author": "Parallel Works <support@parallelworks.com>",
|
|
67
|
+
"license": "MIT",
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/parallelworks/sdk/issues"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/parallelworks/sdk#readme",
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"registry": "https://registry.npmjs.org",
|
|
74
|
+
"access": "public"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsc",
|
|
78
|
+
"generate": "openapi-typescript ../openapi.json -o ./src/types/api.d.ts",
|
|
79
|
+
"clean": "rm -rf dist"
|
|
80
|
+
}
|
|
81
|
+
}
|