@dugjason/front-node 0.1.0 → 0.2.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/{LICENSE.md → LICENSE} +2 -2
- package/README.md +40 -297
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11907 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +11907 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -32
- package/dist/src/client.d.ts +0 -48
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js +0 -218
- package/dist/src/client.js.map +0 -1
- package/dist/src/front.d.ts +0 -29
- package/dist/src/front.d.ts.map +0 -1
- package/dist/src/front.js +0 -44
- package/dist/src/front.js.map +0 -1
- package/dist/src/index.d.ts +0 -8
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -10
- package/dist/src/index.js.map +0 -1
- package/dist/src/oauth.d.ts +0 -28
- package/dist/src/oauth.d.ts.map +0 -1
- package/dist/src/oauth.js +0 -82
- package/dist/src/oauth.js.map +0 -1
- package/dist/src/resources/accounts.d.ts +0 -39
- package/dist/src/resources/accounts.d.ts.map +0 -1
- package/dist/src/resources/accounts.js +0 -57
- package/dist/src/resources/accounts.js.map +0 -1
- package/dist/src/resources/conversations.d.ts +0 -41
- package/dist/src/resources/conversations.d.ts.map +0 -1
- package/dist/src/resources/conversations.js +0 -55
- package/dist/src/resources/conversations.js.map +0 -1
- package/dist/src/resources/teammates.d.ts +0 -29
- package/dist/src/resources/teammates.d.ts.map +0 -1
- package/dist/src/resources/teammates.js +0 -37
- package/dist/src/resources/teammates.js.map +0 -1
- package/dist/src/types.d.ts +0 -147
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/tests/client.test.d.ts +0 -2
- package/dist/tests/client.test.d.ts.map +0 -1
- package/dist/tests/client.test.js +0 -226
- package/dist/tests/client.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,43 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dugjason/front-node",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Modern
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Modern Typescript SDK for the Front.com API",
|
|
14
5
|
"keywords": [
|
|
15
|
-
"front",
|
|
16
6
|
"api",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
7
|
+
"customer-support",
|
|
8
|
+
"front",
|
|
9
|
+
"frontapp",
|
|
10
|
+
"sdk"
|
|
20
11
|
],
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"@biomejs/biome": "2.0.6",
|
|
25
|
-
"@types/node": "^20.19.1",
|
|
26
|
-
"typescript": "^5.8.3",
|
|
27
|
-
"vitest": "3.2.4"
|
|
12
|
+
"homepage": "https://github.com/dugjason/front-node#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/dugjason/front-node/issues"
|
|
28
15
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/dugjason/front-node.git"
|
|
31
20
|
},
|
|
32
21
|
"files": [
|
|
33
22
|
"dist"
|
|
34
23
|
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.mjs",
|
|
27
|
+
"types": "./dist/index.d.cts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/index.d.mts",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/index.d.cts",
|
|
36
|
+
"default": "./dist/index.cjs"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
35
43
|
"scripts": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
"test": "bun test",
|
|
45
|
+
"build": "tsdown",
|
|
46
|
+
"check": "bun x ultracite check . && bun x tsc --noEmit",
|
|
47
|
+
"changeset": "changeset",
|
|
48
|
+
"version-packages": "changeset version",
|
|
49
|
+
"release": "bun run build && changeset publish",
|
|
50
|
+
"prepack": "bun run build",
|
|
51
|
+
"generate": "bun ./scripts/build.ts && bun run build",
|
|
52
|
+
"lint": "bun x oxlint -c oxlint.config.ts .",
|
|
53
|
+
"fmt": "bun x oxfmt -c oxfmt.config.ts .",
|
|
54
|
+
"fmt:check": "bun x oxfmt --check -c oxfmt.config.ts .",
|
|
55
|
+
"fix": "bun x ultracite fix .",
|
|
56
|
+
"ultracite": "bun x ultracite check ."
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@arethetypeswrong/core": "0.18.5",
|
|
60
|
+
"@changesets/cli": "3.0.1",
|
|
61
|
+
"@types/bun": "1.4.0",
|
|
62
|
+
"@types/node": "26.4.1",
|
|
63
|
+
"lint-staged": "17.4.1",
|
|
64
|
+
"openapi-typescript": "7.13.0",
|
|
65
|
+
"oxfmt": "0.66.0",
|
|
66
|
+
"oxlint": "1.81.0",
|
|
67
|
+
"tsdown": "0.22.14",
|
|
68
|
+
"typescript": "7.0.2",
|
|
69
|
+
"ultracite": "7.10.7",
|
|
70
|
+
"unrun": "0.3.1"
|
|
71
|
+
},
|
|
72
|
+
"lint-staged": {
|
|
73
|
+
"*.{js,ts,json,jsonc,md,mdx}": [
|
|
74
|
+
"ultracite fix"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "bun@1.3.14"
|
|
78
|
+
}
|
package/dist/src/client.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { OAuthTokenManager } from "./oauth";
|
|
2
|
-
import type { FrontConfig, RequestOptions } from "./types";
|
|
3
|
-
export declare class FrontClient {
|
|
4
|
-
private apiKey?;
|
|
5
|
-
private baseUrl;
|
|
6
|
-
private oauthManager?;
|
|
7
|
-
constructor(config: FrontConfig);
|
|
8
|
-
request<T>(options: RequestOptions): Promise<T>;
|
|
9
|
-
private requestWithRetry;
|
|
10
|
-
/**
|
|
11
|
-
* Calculate retry delay based on retry-after header and exponential backoff
|
|
12
|
-
*/
|
|
13
|
-
private getRetryDelay;
|
|
14
|
-
/**
|
|
15
|
-
* Calculate exponential backoff delay with jitter
|
|
16
|
-
*/
|
|
17
|
-
private calculateExponentialBackoff;
|
|
18
|
-
/**
|
|
19
|
-
* Sleep for the specified number of milliseconds
|
|
20
|
-
*/
|
|
21
|
-
private sleep;
|
|
22
|
-
/**
|
|
23
|
-
* Get the appropriate auth token (OAuth access token or API key)
|
|
24
|
-
*/
|
|
25
|
-
private getAuthToken;
|
|
26
|
-
/**
|
|
27
|
-
* Handle the response from the API
|
|
28
|
-
*/
|
|
29
|
-
private handleResponse;
|
|
30
|
-
get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
|
|
31
|
-
post<T>(path: string, body?: unknown): Promise<T>;
|
|
32
|
-
put<T>(path: string, body?: unknown): Promise<T>;
|
|
33
|
-
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
34
|
-
delete<T>(path: string): Promise<T>;
|
|
35
|
-
/**
|
|
36
|
-
* Get the OAuth token manager (if using OAuth)
|
|
37
|
-
*/
|
|
38
|
-
getOAuthManager(): OAuthTokenManager | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Check if the client is using OAuth authentication
|
|
41
|
-
*/
|
|
42
|
-
isUsingOAuth(): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Update OAuth configuration (useful for updating tokens)
|
|
45
|
-
*/
|
|
46
|
-
updateOAuthConfig(updates: Partial<import("./types").OAuthConfig>): void;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/src/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAc,cAAc,EAAE,MAAM,SAAS,CAAA;AAUtE,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,CAAQ;IACvB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,YAAY,CAAC,CAAmB;gBAE5B,MAAM,EAAE,WAAW;IAiBzB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;YAIvC,gBAAgB;IAwF9B;;OAEG;IACH,OAAO,CAAC,aAAa;IAyBrB;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAgBnC;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;OAEG;IACH,OAAO,CAAC,YAAY;IAcpB;;OAEG;YACW,cAAc;IAyBtB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlE,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzC;;OAEG;IACH,eAAe,IAAI,iBAAiB,GAAG,SAAS;IAIhD;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;CAMzE"}
|
package/dist/src/client.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { OAuthTokenManager } from "./oauth";
|
|
2
|
-
// Rate limiting configuration
|
|
3
|
-
const RATE_LIMIT_CONFIG = {
|
|
4
|
-
maxRetries: 3,
|
|
5
|
-
baseDelay: 1_000, // 1 second
|
|
6
|
-
maxDelay: 30_000, // 30 seconds
|
|
7
|
-
jitterFactor: 0.2, // 20% jitter to avoid thundering herd problem
|
|
8
|
-
};
|
|
9
|
-
export class FrontClient {
|
|
10
|
-
apiKey;
|
|
11
|
-
baseUrl;
|
|
12
|
-
oauthManager;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.baseUrl = config.baseUrl || "https://api2.frontapp.com";
|
|
15
|
-
if ("oauth" in config && config.oauth) {
|
|
16
|
-
// OAuth configuration provided
|
|
17
|
-
this.oauthManager = new OAuthTokenManager(config.oauth);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
// API key configuration
|
|
21
|
-
this.apiKey = config.apiKey || process.env.FRONT_API_KEY;
|
|
22
|
-
if (!this.apiKey) {
|
|
23
|
-
throw new Error("API key is required when not using OAuth. Provide apiKey via config or FRONT_API_KEY environment variable.");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async request(options) {
|
|
28
|
-
return this.requestWithRetry(options, 0);
|
|
29
|
-
}
|
|
30
|
-
async requestWithRetry(options, retryCount) {
|
|
31
|
-
const { method, path, body, params } = options;
|
|
32
|
-
// Build URL with query parameters
|
|
33
|
-
const url = new URL(path, this.baseUrl);
|
|
34
|
-
if (params) {
|
|
35
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
36
|
-
if (value !== undefined && value !== null) {
|
|
37
|
-
url.searchParams.append(key, String(value));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
// Get the authorization token (OAuth or API key)
|
|
42
|
-
const authToken = this.getAuthToken();
|
|
43
|
-
// Prepare headers
|
|
44
|
-
const headers = {
|
|
45
|
-
Authorization: `Bearer ${authToken}`,
|
|
46
|
-
Accept: "application/json",
|
|
47
|
-
};
|
|
48
|
-
// Add content-type for requests with body
|
|
49
|
-
if (body) {
|
|
50
|
-
headers["Content-Type"] = "application/json";
|
|
51
|
-
}
|
|
52
|
-
// Prepare fetch options
|
|
53
|
-
const fetchOptions = {
|
|
54
|
-
method,
|
|
55
|
-
headers,
|
|
56
|
-
};
|
|
57
|
-
// Add body for non-GET requests
|
|
58
|
-
if (body) {
|
|
59
|
-
fetchOptions.body = JSON.stringify(body);
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const response = await fetch(url.toString(), fetchOptions);
|
|
63
|
-
// Handle token expiration for OAuth
|
|
64
|
-
if (response.status === 401 && this.oauthManager) {
|
|
65
|
-
// Token might be expired, try to refresh and retry once
|
|
66
|
-
const refreshedToken = await this.oauthManager.refreshToken();
|
|
67
|
-
// Token was refreshed, retry the request
|
|
68
|
-
headers.Authorization = `Bearer ${refreshedToken}`;
|
|
69
|
-
const retryResponse = await fetch(url.toString(), {
|
|
70
|
-
...fetchOptions,
|
|
71
|
-
headers,
|
|
72
|
-
});
|
|
73
|
-
return this.handleResponse(retryResponse);
|
|
74
|
-
}
|
|
75
|
-
// Handle rate limiting (429 status)
|
|
76
|
-
if (response.status === 429) {
|
|
77
|
-
if (retryCount < RATE_LIMIT_CONFIG.maxRetries) {
|
|
78
|
-
const retryAfterMs = this.getRetryDelay(response, retryCount);
|
|
79
|
-
await this.sleep(retryAfterMs);
|
|
80
|
-
return this.requestWithRetry(options, retryCount + 1);
|
|
81
|
-
}
|
|
82
|
-
// Max retries exceeded, handle as normal error response
|
|
83
|
-
}
|
|
84
|
-
return this.handleResponse(response);
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
if (error instanceof Error && "status" in error) {
|
|
88
|
-
// Re-throw Front API errors
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
// Handle network or other errors - retry if we haven't exceeded max retries
|
|
92
|
-
if (retryCount < RATE_LIMIT_CONFIG.maxRetries) {
|
|
93
|
-
const retryAfterMs = this.calculateExponentialBackoff(retryCount);
|
|
94
|
-
await this.sleep(retryAfterMs);
|
|
95
|
-
return this.requestWithRetry(options, retryCount + 1);
|
|
96
|
-
}
|
|
97
|
-
// Max retries exceeded for network errors
|
|
98
|
-
throw new Error(`Request failed after ${RATE_LIMIT_CONFIG.maxRetries} retries: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Calculate retry delay based on retry-after header and exponential backoff
|
|
103
|
-
*/
|
|
104
|
-
getRetryDelay(response, retryCount) {
|
|
105
|
-
const retryAfterHeader = response.headers.get("retry-after");
|
|
106
|
-
let retryAfterMs = 0;
|
|
107
|
-
if (retryAfterHeader) {
|
|
108
|
-
// retry-after can be in seconds (integer) or HTTP date
|
|
109
|
-
const retryAfterSeconds = Number.parseInt(retryAfterHeader, 10);
|
|
110
|
-
if (!Number.isNaN(retryAfterSeconds)) {
|
|
111
|
-
retryAfterMs = retryAfterSeconds * 1000;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// Try parsing as HTTP date
|
|
115
|
-
const retryAfterDate = new Date(retryAfterHeader);
|
|
116
|
-
if (!Number.isNaN(retryAfterDate.getTime())) {
|
|
117
|
-
retryAfterMs = Math.max(0, retryAfterDate.getTime() - Date.now());
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// Calculate exponential backoff delay
|
|
122
|
-
const exponentialBackoffMs = this.calculateExponentialBackoff(retryCount);
|
|
123
|
-
// Use the maximum of retry-after and exponential backoff to ensure we wait AT LEAST retry-after time
|
|
124
|
-
return Math.max(retryAfterMs, exponentialBackoffMs);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Calculate exponential backoff delay with jitter
|
|
128
|
-
*/
|
|
129
|
-
calculateExponentialBackoff(retryCount) {
|
|
130
|
-
const { baseDelay, maxDelay, jitterFactor } = RATE_LIMIT_CONFIG;
|
|
131
|
-
// Calculate exponential delay: baseDelay * (2 ^ retryCount)
|
|
132
|
-
const exponentialDelay = baseDelay * 2 ** retryCount;
|
|
133
|
-
// Apply maximum delay cap
|
|
134
|
-
const cappedDelay = Math.min(exponentialDelay, maxDelay);
|
|
135
|
-
// Add jitter to avoid thundering herd problem
|
|
136
|
-
// Jitter is a random value between +-jitterFactor of the delay
|
|
137
|
-
const jitter = cappedDelay * jitterFactor * (Math.random() * 2 - 1);
|
|
138
|
-
return Math.max(0, cappedDelay + jitter);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Sleep for the specified number of milliseconds
|
|
142
|
-
*/
|
|
143
|
-
sleep(ms) {
|
|
144
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get the appropriate auth token (OAuth access token or API key)
|
|
148
|
-
*/
|
|
149
|
-
getAuthToken() {
|
|
150
|
-
if (this.oauthManager) {
|
|
151
|
-
return this.oauthManager.getAccessToken();
|
|
152
|
-
}
|
|
153
|
-
if (!this.apiKey) {
|
|
154
|
-
throw new Error("No authentication method available. This should not happen with proper configuration.");
|
|
155
|
-
}
|
|
156
|
-
return this.apiKey;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Handle the response from the API
|
|
160
|
-
*/
|
|
161
|
-
async handleResponse(response) {
|
|
162
|
-
// Handle non-JSON responses (like 204 No Content)
|
|
163
|
-
if (response.status === 204) {
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
|
-
const responseData = await response.json();
|
|
167
|
-
if (!response.ok) {
|
|
168
|
-
// Type guard for error response structure
|
|
169
|
-
const errorData = responseData;
|
|
170
|
-
const error = {
|
|
171
|
-
message: (typeof errorData.message === "string"
|
|
172
|
-
? errorData.message
|
|
173
|
-
: undefined) || `HTTP ${response.status}: ${response.statusText}`,
|
|
174
|
-
status: response.status,
|
|
175
|
-
code: typeof errorData.code === "string" ? errorData.code : undefined,
|
|
176
|
-
};
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
return responseData;
|
|
180
|
-
}
|
|
181
|
-
async get(path, params) {
|
|
182
|
-
return this.request({ method: "GET", path, params });
|
|
183
|
-
}
|
|
184
|
-
async post(path, body) {
|
|
185
|
-
return this.request({ method: "POST", path, body });
|
|
186
|
-
}
|
|
187
|
-
async put(path, body) {
|
|
188
|
-
return this.request({ method: "PUT", path, body });
|
|
189
|
-
}
|
|
190
|
-
async patch(path, body) {
|
|
191
|
-
return this.request({ method: "PATCH", path, body });
|
|
192
|
-
}
|
|
193
|
-
async delete(path) {
|
|
194
|
-
return this.request({ method: "DELETE", path });
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get the OAuth token manager (if using OAuth)
|
|
198
|
-
*/
|
|
199
|
-
getOAuthManager() {
|
|
200
|
-
return this.oauthManager;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Check if the client is using OAuth authentication
|
|
204
|
-
*/
|
|
205
|
-
isUsingOAuth() {
|
|
206
|
-
return !!this.oauthManager;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Update OAuth configuration (useful for updating tokens)
|
|
210
|
-
*/
|
|
211
|
-
updateOAuthConfig(updates) {
|
|
212
|
-
if (!this.oauthManager) {
|
|
213
|
-
throw new Error("OAuth is not configured for this client");
|
|
214
|
-
}
|
|
215
|
-
this.oauthManager.updateConfig(updates);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
//# sourceMappingURL=client.js.map
|
package/dist/src/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAG3C,8BAA8B;AAC9B,MAAM,iBAAiB,GAAG;IACxB,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,KAAK,EAAE,WAAW;IAC7B,QAAQ,EAAE,MAAM,EAAE,aAAa;IAC/B,YAAY,EAAE,GAAG,EAAE,8CAA8C;CACzD,CAAA;AAEV,MAAM,OAAO,WAAW;IACd,MAAM,CAAS;IACf,OAAO,CAAQ;IACf,YAAY,CAAoB;IAExC,YAAY,MAAmB;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,2BAA2B,CAAA;QAE5D,IAAI,OAAO,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACtC,+BAA+B;YAC/B,IAAI,CAAC,YAAY,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACzD,CAAC;aAAM,CAAC;YACN,wBAAwB;YACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAA;YACxD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAA;YACH,C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AAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,CAAC,MAAM,CAAI,IAAY;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,OAA+C;QAC/D,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAC5D,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC;CACF"}
|
package/dist/src/front.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { FrontClient } from "./client";
|
|
2
|
-
import { Accounts } from "./resources/accounts";
|
|
3
|
-
import { Conversations } from "./resources/conversations";
|
|
4
|
-
import { Teammates } from "./resources/teammates";
|
|
5
|
-
import type { FrontConfig } from "./types";
|
|
6
|
-
export declare class Front {
|
|
7
|
-
private client;
|
|
8
|
-
readonly teammates: Teammates;
|
|
9
|
-
readonly conversations: Conversations;
|
|
10
|
-
readonly accounts: Accounts;
|
|
11
|
-
constructor(config: FrontConfig);
|
|
12
|
-
/**
|
|
13
|
-
* Get the underlying HTTP client for advanced usage
|
|
14
|
-
*/
|
|
15
|
-
getClient(): FrontClient;
|
|
16
|
-
/**
|
|
17
|
-
* Check if the SDK is using OAuth authentication
|
|
18
|
-
*/
|
|
19
|
-
isUsingOAuth(): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Get the OAuth token manager (if using OAuth)
|
|
22
|
-
*/
|
|
23
|
-
getOAuthManager(): import("./oauth").OAuthTokenManager | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Update OAuth configuration (useful for updating tokens)
|
|
26
|
-
*/
|
|
27
|
-
updateOAuthConfig(updates: Partial<FrontConfig["oauth"]>): void;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=front.d.ts.map
|
package/dist/src/front.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"front.d.ts","sourceRoot":"","sources":["../../src/front.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAa;IAE3B,SAAgB,SAAS,EAAE,SAAS,CAAA;IACpC,SAAgB,aAAa,EAAE,aAAa,CAAA;IAC5C,SAAgB,QAAQ,EAAE,QAAQ,CAAA;gBAEtB,MAAM,EAAE,WAAW;IAS/B;;OAEG;IACH,SAAS,IAAI,WAAW;IAIxB;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,eAAe;IAIf;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;CAIzD"}
|
package/dist/src/front.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { FrontClient } from "./client";
|
|
2
|
-
import { Accounts } from "./resources/accounts";
|
|
3
|
-
import { Conversations } from "./resources/conversations";
|
|
4
|
-
import { Teammates } from "./resources/teammates";
|
|
5
|
-
export class Front {
|
|
6
|
-
client;
|
|
7
|
-
teammates;
|
|
8
|
-
conversations;
|
|
9
|
-
accounts;
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.client = new FrontClient(config);
|
|
12
|
-
// Initialize resource classes
|
|
13
|
-
this.teammates = new Teammates(this.client);
|
|
14
|
-
this.conversations = new Conversations(this.client);
|
|
15
|
-
this.accounts = new Accounts(this.client);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get the underlying HTTP client for advanced usage
|
|
19
|
-
*/
|
|
20
|
-
getClient() {
|
|
21
|
-
return this.client;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Check if the SDK is using OAuth authentication
|
|
25
|
-
*/
|
|
26
|
-
isUsingOAuth() {
|
|
27
|
-
return this.client.isUsingOAuth();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get the OAuth token manager (if using OAuth)
|
|
31
|
-
*/
|
|
32
|
-
getOAuthManager() {
|
|
33
|
-
return this.client.getOAuthManager();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Update OAuth configuration (useful for updating tokens)
|
|
37
|
-
*/
|
|
38
|
-
updateOAuthConfig(updates) {
|
|
39
|
-
if (!updates)
|
|
40
|
-
return;
|
|
41
|
-
this.client.updateOAuthConfig(updates);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=front.js.map
|
package/dist/src/front.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"front.js","sourceRoot":"","sources":["../../src/front.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGjD,MAAM,OAAO,KAAK;IACR,MAAM,CAAa;IAEX,SAAS,CAAW;IACpB,aAAa,CAAe;IAC5B,QAAQ,CAAU;IAElC,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;QAErC,8BAA8B;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,OAAsC;QACtD,IAAI,CAAC,OAAO;YAAE,OAAM;QACpB,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;CACF"}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { FrontClient } from "./client";
|
|
2
|
-
export { Front, Front as default } from "./front";
|
|
3
|
-
export { OAuthTokenManager } from "./oauth";
|
|
4
|
-
export { Accounts } from "./resources/accounts";
|
|
5
|
-
export { Conversations } from "./resources/conversations";
|
|
6
|
-
export { Teammates } from "./resources/teammates";
|
|
7
|
-
export type { Account, AccountContactsParams, Conversation, CreateAccountData, FrontConfig, FrontError, ListResponse, OAuthConfig, OAuthTokens, PaginationParams, RequestOptions, Teammate, UpdateAccountData, UpdateTeammateData, } from "./types";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,YAAY,EACV,OAAO,EACP,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAA"}
|
package/dist/src/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Main SDK class
|
|
2
|
-
// Client and configuration types
|
|
3
|
-
export { FrontClient } from "./client";
|
|
4
|
-
export { Front, Front as default } from "./front";
|
|
5
|
-
export { OAuthTokenManager } from "./oauth";
|
|
6
|
-
export { Accounts } from "./resources/accounts";
|
|
7
|
-
export { Conversations } from "./resources/conversations";
|
|
8
|
-
// Resource classes
|
|
9
|
-
export { Teammates } from "./resources/teammates";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AAEjB,iCAAiC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/src/oauth.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { OAuthConfig } from "./types";
|
|
2
|
-
export declare class OAuthTokenManager {
|
|
3
|
-
private config;
|
|
4
|
-
private isRefreshing;
|
|
5
|
-
private refreshPromise;
|
|
6
|
-
constructor(config: OAuthConfig);
|
|
7
|
-
/**
|
|
8
|
-
* Get the current access token
|
|
9
|
-
*/
|
|
10
|
-
getAccessToken(): string;
|
|
11
|
-
/**
|
|
12
|
-
* Refresh the access token using the refresh token
|
|
13
|
-
*/
|
|
14
|
-
refreshToken(): Promise<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Perform the actual token refresh
|
|
17
|
-
*/
|
|
18
|
-
private performTokenRefresh;
|
|
19
|
-
/**
|
|
20
|
-
* Update the OAuth configuration (useful when tokens are refreshed externally)
|
|
21
|
-
*/
|
|
22
|
-
updateConfig(updates: Partial<OAuthConfig>): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get the current OAuth configuration
|
|
25
|
-
*/
|
|
26
|
-
getConfig(): Readonly<OAuthConfig>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=oauth.d.ts.map
|
package/dist/src/oauth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO1C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,cAAc,CAA6B;gBAEvC,MAAM,EAAE,WAAW;IAI/B;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAoBrC;;OAEG;YACW,mBAAmB;IA2CjC;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAIjD;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,WAAW,CAAC;CAGnC"}
|
package/dist/src/oauth.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export class OAuthTokenManager {
|
|
2
|
-
config;
|
|
3
|
-
isRefreshing = false;
|
|
4
|
-
refreshPromise = null;
|
|
5
|
-
constructor(config) {
|
|
6
|
-
this.config = { ...config };
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Get the current access token
|
|
10
|
-
*/
|
|
11
|
-
getAccessToken() {
|
|
12
|
-
return this.config.accessToken;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Refresh the access token using the refresh token
|
|
16
|
-
*/
|
|
17
|
-
async refreshToken() {
|
|
18
|
-
// If already refreshing, wait for the existing refresh to complete
|
|
19
|
-
if (this.isRefreshing && this.refreshPromise) {
|
|
20
|
-
await this.refreshPromise;
|
|
21
|
-
return this.config.accessToken;
|
|
22
|
-
}
|
|
23
|
-
// Start the refresh process
|
|
24
|
-
this.isRefreshing = true;
|
|
25
|
-
this.refreshPromise = this.performTokenRefresh();
|
|
26
|
-
try {
|
|
27
|
-
await this.refreshPromise;
|
|
28
|
-
return this.config.accessToken;
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
this.isRefreshing = false;
|
|
32
|
-
this.refreshPromise = null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Perform the actual token refresh
|
|
37
|
-
*/
|
|
38
|
-
async performTokenRefresh() {
|
|
39
|
-
const oauthUrl = "https://app.frontapp.com/oauth/token";
|
|
40
|
-
// Create Basic Auth header
|
|
41
|
-
const credentials = btoa(`${this.config.clientId}:${this.config.clientSecret}`);
|
|
42
|
-
const response = await fetch(oauthUrl, {
|
|
43
|
-
method: "POST",
|
|
44
|
-
headers: {
|
|
45
|
-
Authorization: `Basic ${credentials}`,
|
|
46
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
47
|
-
},
|
|
48
|
-
body: new URLSearchParams({
|
|
49
|
-
grant_type: "refresh_token",
|
|
50
|
-
refresh_token: this.config.refreshToken,
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
if (!response.ok) {
|
|
54
|
-
const errorText = await response.text();
|
|
55
|
-
throw new Error(`Failed to refresh OAuth token: ${response.status} ${errorText}`);
|
|
56
|
-
}
|
|
57
|
-
const apiResponse = (await response.json());
|
|
58
|
-
// Update the stored tokens
|
|
59
|
-
this.config.accessToken = apiResponse.access_token;
|
|
60
|
-
this.config.refreshToken = apiResponse.refresh_token;
|
|
61
|
-
// Call the callback if provided
|
|
62
|
-
if (this.config.onTokenRefresh) {
|
|
63
|
-
await this.config.onTokenRefresh({
|
|
64
|
-
access_token: this.config.accessToken,
|
|
65
|
-
refresh_token: this.config.refreshToken,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Update the OAuth configuration (useful when tokens are refreshed externally)
|
|
71
|
-
*/
|
|
72
|
-
updateConfig(updates) {
|
|
73
|
-
this.config = { ...this.config, ...updates };
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get the current OAuth configuration
|
|
77
|
-
*/
|
|
78
|
-
getConfig() {
|
|
79
|
-
return { ...this.config };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=oauth.js.map
|
package/dist/src/oauth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/oauth.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,iBAAiB;IACp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