glitch-javascript-sdk 3.2.9 → 3.2.12

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.
@@ -0,0 +1,38 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ /**
5
+ * Glitch MCP paid facade (/mcp/v1).
6
+ *
7
+ * Mirrors the routes served by McpAgentController. These endpoints authenticate
8
+ * with either a Glitch user JWT or a title-scoped MCP token and keep all planner,
9
+ * billing, and executor logic server-side. The public @glitch/mcp adapter calls
10
+ * the same endpoints; this SDK surface lets first-party TypeScript clients reuse them.
11
+ */
12
+ class McpRoute {
13
+ public static routes: { [key: string]: Route } = {
14
+ authStatus: { url: "/mcp/v1/auth/status", method: HTTP_METHODS.GET },
15
+ listTitles: { url: "/mcp/v1/titles", method: HTTP_METHODS.GET },
16
+ titleContext: { url: "/mcp/v1/titles/{title_id}/context", method: HTTP_METHODS.GET },
17
+ billing: { url: "/mcp/v1/titles/{title_id}/billing", method: HTTP_METHODS.GET },
18
+ startRun: { url: "/mcp/v1/titles/{title_id}/runs", method: HTTP_METHODS.POST },
19
+ viewRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}", method: HTTP_METHODS.GET },
20
+ runEvents: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/events", method: HTTP_METHODS.GET },
21
+ streamRun: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/stream", method: HTTP_METHODS.GET },
22
+ finalReport: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/report", method: HTTP_METHODS.GET },
23
+ artifacts: { url: "/mcp/v1/titles/{title_id}/runs/{run_id}/artifacts", method: HTTP_METHODS.GET },
24
+ listActions: { url: "/mcp/v1/titles/{title_id}/actions", method: HTTP_METHODS.GET },
25
+ approveAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/approve", method: HTTP_METHODS.POST },
26
+ rejectAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/reject", method: HTTP_METHODS.POST },
27
+ executeAction: { url: "/mcp/v1/titles/{title_id}/actions/{action_id}/execute", method: HTTP_METHODS.POST },
28
+ listGuidance: { url: "/mcp/v1/titles/{title_id}/guidance", method: HTTP_METHODS.GET },
29
+ answerGuidance: { url: "/mcp/v1/titles/{title_id}/guidance/{guidance_id}/answer", method: HTTP_METHODS.POST },
30
+ createUpload: { url: "/mcp/v1/titles/{title_id}/uploads", method: HTTP_METHODS.POST },
31
+ uploadFile: { url: "/mcp/v1/titles/{title_id}/files", method: HTTP_METHODS.POST },
32
+ listTokens: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.GET },
33
+ createToken: { url: "/mcp/v1/titles/{title_id}/tokens", method: HTTP_METHODS.POST },
34
+ revokeToken: { url: "/mcp/v1/titles/{title_id}/tokens/{token_id}", method: HTTP_METHODS.DELETE },
35
+ };
36
+ }
37
+
38
+ export default McpRoute;
@@ -0,0 +1,25 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ /**
5
+ * Route declarations for the PR Directory API.
6
+ *
7
+ * These mirror the Laravel routes under `/api/pr/*` and the title-scoped
8
+ * matcher route under `/api/titles/{title_id}/pr/matches`. Keeping the URL
9
+ * templates in one place lets the SDK methods stay small and consistent with
10
+ * the rest of the package's route-wrapper pattern.
11
+ */
12
+ class PrDirectoryRoutes {
13
+ public static routes: { [key: string]: Route } = {
14
+ listPublications: { url: "/pr/publications", method: HTTP_METHODS.GET },
15
+ viewPublication: { url: "/pr/publications/{publication_id}", method: HTTP_METHODS.GET },
16
+ listPeople: { url: "/pr/people", method: HTTP_METHODS.GET },
17
+ viewPerson: { url: "/pr/people/{person_id}", method: HTTP_METHODS.GET },
18
+ listTags: { url: "/pr/tags", method: HTTP_METHODS.GET },
19
+ report: { url: "/pr/report", method: HTTP_METHODS.GET },
20
+ titleMatches: { url: "/titles/{title_id}/pr/matches", method: HTTP_METHODS.GET },
21
+ queueVerification: { url: "/admin/pr/verification/queue", method: HTTP_METHODS.POST },
22
+ };
23
+ }
24
+
25
+ export default PrDirectoryRoutes;
@@ -18,6 +18,7 @@ class UserRoutes {
18
18
  clearTwitchAuth: { url: '/users/clearTwitchAuth', method: HTTP_METHODS.DELETE },
19
19
  clearFacebookAuth: { url: '/users/clearFacebookAuth', method: HTTP_METHODS.DELETE },
20
20
  clearGoogleAuth: { url: '/users/clearGoogleAuth', method: HTTP_METHODS.DELETE },
21
+ clearGmailAuth: { url: '/users/clearGmailAuth', method: HTTP_METHODS.DELETE },
21
22
  clearStripeAuth: { url: '/users/clearStripeAuth', method: HTTP_METHODS.DELETE },
22
23
  clearTikTokAuth: { url: '/users/clearTikTokAuth', method: HTTP_METHODS.DELETE },
23
24
  clearYoutubeAuth: { url: '/users/clearYoutubeAuth', method: HTTP_METHODS.DELETE },
@@ -75,4 +76,4 @@ class UserRoutes {
75
76
 
76
77
  }
77
78
 
78
- export default UserRoutes;
79
+ export default UserRoutes;
@@ -28,6 +28,35 @@ class Requests {
28
28
  Requests.community_id = community_id;
29
29
  }
30
30
 
31
+ /**
32
+ * Build an absolute API URL using the currently configured base URL.
33
+ *
34
+ * This is useful for browser primitives such as EventSource that need a URL
35
+ * string instead of an Axios request wrapper.
36
+ */
37
+ public static buildUrl(url: string, params?: Record<string, any>): string {
38
+ let path = url;
39
+
40
+ if (params && Object.keys(params).length > 0) {
41
+ const queryString = Object.entries(params)
42
+ .filter(([, value]) => value !== undefined && value !== null && value !== '')
43
+ .map(([key, value]) => {
44
+ if (Array.isArray(value)) {
45
+ return value.map((item) => `${key}[]=${encodeURIComponent(item)}`).join('&');
46
+ }
47
+ return `${key}=${encodeURIComponent(value)}`;
48
+ })
49
+ .filter(Boolean)
50
+ .join('&');
51
+
52
+ if (queryString) {
53
+ path = `${path}${path.includes('?') ? '&' : '?'}${queryString}`;
54
+ }
55
+ }
56
+
57
+ return Requests.baseUrl.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '');
58
+ }
59
+
31
60
  private static request<T>(
32
61
  method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE',
33
62
  url: string,