@zapier/zapier-sdk 0.0.1 → 0.0.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.
Files changed (49) hide show
  1. package/dist/actions-sdk.d.ts +47 -0
  2. package/dist/actions-sdk.js +208 -0
  3. package/dist/api.d.ts +62 -0
  4. package/dist/api.js +227 -0
  5. package/dist/functions/bundleCode.d.ts +18 -0
  6. package/dist/functions/bundleCode.js +91 -0
  7. package/dist/functions/generateTypes.d.ts +16 -0
  8. package/dist/functions/generateTypes.js +271 -0
  9. package/dist/functions/getAction.d.ts +16 -0
  10. package/dist/functions/getAction.js +25 -0
  11. package/dist/functions/getApp.d.ts +14 -0
  12. package/dist/functions/getApp.js +41 -0
  13. package/dist/functions/listActions.d.ts +15 -0
  14. package/dist/functions/listActions.js +127 -0
  15. package/dist/functions/listApps.d.ts +16 -0
  16. package/dist/functions/listApps.js +50 -0
  17. package/dist/functions/listAuths.d.ts +18 -0
  18. package/dist/functions/listAuths.js +118 -0
  19. package/dist/functions/listFields.d.ts +18 -0
  20. package/dist/functions/listFields.js +67 -0
  21. package/dist/functions/runAction.d.ts +18 -0
  22. package/dist/functions/runAction.js +156 -0
  23. package/dist/index.d.ts +12 -3
  24. package/dist/index.js +24 -5
  25. package/dist/output-schemas.d.ts +95 -0
  26. package/dist/output-schemas.js +138 -0
  27. package/dist/schemas.d.ts +338 -0
  28. package/dist/schemas.js +336 -0
  29. package/dist/sdk.d.ts +5 -5
  30. package/dist/sdk.js +8 -8
  31. package/dist/types.d.ts +196 -0
  32. package/dist/types.js +41 -0
  33. package/package.json +5 -3
  34. package/src/actions-sdk.ts +356 -0
  35. package/src/api.ts +361 -0
  36. package/src/functions/bundleCode.ts +85 -0
  37. package/src/functions/generateTypes.ts +309 -0
  38. package/src/functions/getAction.ts +34 -0
  39. package/src/functions/getApp.ts +47 -0
  40. package/src/functions/listActions.ts +151 -0
  41. package/src/functions/listApps.ts +65 -0
  42. package/src/functions/listAuths.ts +161 -0
  43. package/src/functions/listFields.ts +95 -0
  44. package/src/functions/runAction.ts +256 -0
  45. package/src/index.ts +15 -4
  46. package/src/output-schemas.ts +196 -0
  47. package/src/schemas.ts +467 -0
  48. package/src/sdk.ts +13 -13
  49. package/src/types.ts +257 -0
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.generateTypes = generateTypes;
37
+ const listActions_1 = require("./listActions");
38
+ const listFields_1 = require("./listFields");
39
+ /**
40
+ * Generate TypeScript types for a specific app
41
+ *
42
+ * This function can be used standalone without instantiating a full SDK,
43
+ * which enables better tree-shaking in applications that only need this functionality.
44
+ *
45
+ * @param options - App key, auth ID, output path, and API configuration options
46
+ * @returns Promise<string> - Generated TypeScript code
47
+ */
48
+ async function generateTypes(options) {
49
+ const { appKey, authId, output = `./types/${appKey}.d.ts` } = options;
50
+ // Parse app identifier (support app@version format)
51
+ const { app, version } = parseAppIdentifier(appKey);
52
+ // Fetch all actions for the app
53
+ const actions = await (0, listActions_1.listActions)({
54
+ ...options,
55
+ appKey: app,
56
+ });
57
+ if (actions.length === 0) {
58
+ const typeDefinitions = generateEmptyTypesFile(app, version);
59
+ if (output) {
60
+ const fs = await Promise.resolve().then(() => __importStar(require("fs")));
61
+ const path = await Promise.resolve().then(() => __importStar(require("path")));
62
+ fs.mkdirSync(path.dirname(output), { recursive: true });
63
+ fs.writeFileSync(output, typeDefinitions, "utf8");
64
+ }
65
+ return typeDefinitions;
66
+ }
67
+ // Fetch input fields for each action
68
+ const actionsWithFields = [];
69
+ if (authId) {
70
+ for (const action of actions) {
71
+ try {
72
+ const fields = await (0, listFields_1.listFields)({
73
+ ...options,
74
+ app: action.appKey,
75
+ action: action.key,
76
+ type: action.type,
77
+ authId: authId,
78
+ });
79
+ actionsWithFields.push({ ...action, inputFields: fields });
80
+ }
81
+ catch {
82
+ // If we can't get fields for an action, include it without fields
83
+ actionsWithFields.push({ ...action, inputFields: [] });
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ // Convert actions to have empty input fields (will generate generic types)
89
+ actions.forEach((action) => {
90
+ actionsWithFields.push({ ...action, inputFields: [] });
91
+ });
92
+ }
93
+ // Generate TypeScript types
94
+ const typeDefinitions = generateTypeDefinitions(app, actionsWithFields, version);
95
+ // Write to file if output path specified
96
+ if (output) {
97
+ const fs = await Promise.resolve().then(() => __importStar(require("fs")));
98
+ const path = await Promise.resolve().then(() => __importStar(require("path")));
99
+ fs.mkdirSync(path.dirname(output), { recursive: true });
100
+ fs.writeFileSync(output, typeDefinitions, "utf8");
101
+ }
102
+ return typeDefinitions;
103
+ }
104
+ function parseAppIdentifier(identifier) {
105
+ const parts = identifier.split("@");
106
+ return {
107
+ app: parts[0],
108
+ version: parts[1],
109
+ };
110
+ }
111
+ function generateTypeDefinitions(appKey, actions, version) {
112
+ // Handle empty actions
113
+ if (actions.length === 0) {
114
+ return generateEmptyTypesFile(appKey, version);
115
+ }
116
+ // Group actions by type
117
+ const actionsByType = actions.reduce((acc, action) => {
118
+ if (!acc[action.type]) {
119
+ acc[action.type] = [];
120
+ }
121
+ acc[action.type].push(action);
122
+ return acc;
123
+ }, {});
124
+ const appName = capitalize(appKey);
125
+ const versionComment = version
126
+ ? ` * Generated for ${appKey}@${version}`
127
+ : ` * Generated for ${appKey}`;
128
+ let output = `/* eslint-disable @typescript-eslint/naming-convention */
129
+ /**
130
+ * Auto-generated TypeScript types for Zapier ${appKey} actions
131
+ ${versionComment}
132
+ * Generated on: ${new Date().toISOString()}
133
+ *
134
+ * Usage:
135
+ * import type { ${appName}Actions } from './path/to/this/file'
136
+ * const sdk: ActionsSdk & { actions: ${appName}Actions } = createActionsSdk(...)
137
+ */
138
+
139
+ import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapier-sdk'
140
+
141
+ `;
142
+ // Generate input types for each action
143
+ actions.forEach((action) => {
144
+ if (action.inputFields.length > 0) {
145
+ const inputTypeName = `${appName}${capitalize(action.type)}${capitalize(sanitizeActionName(action.key))}Inputs`;
146
+ output += `interface ${inputTypeName} {\n`;
147
+ action.inputFields.forEach((field) => {
148
+ const isOptional = !field.required;
149
+ const fieldType = mapFieldTypeToTypeScript(field);
150
+ const description = field.helpText
151
+ ? ` /** ${escapeComment(field.helpText)} */\n`
152
+ : "";
153
+ output += `${description} ${sanitizeFieldName(field.key)}${isOptional ? "?" : ""}: ${fieldType}\n`;
154
+ });
155
+ output += `}\n\n`;
156
+ }
157
+ });
158
+ // Generate action type interfaces for each action type
159
+ Object.entries(actionsByType).forEach(([actionType, typeActions]) => {
160
+ const typeName = `${appName}${capitalize(actionType)}Actions`;
161
+ output += `interface ${typeName} {\n`;
162
+ typeActions.forEach((action) => {
163
+ const actionName = sanitizeActionName(action.key);
164
+ const description = action.description
165
+ ? ` /** ${escapeComment(action.description)} */\n`
166
+ : "";
167
+ // Generate type-safe action method signature
168
+ if (action.inputFields.length > 0) {
169
+ const inputTypeName = `${appName}${capitalize(action.type)}${capitalize(sanitizeActionName(action.key))}Inputs`;
170
+ output += `${description} ${actionName}: (options: { inputs: ${inputTypeName} } & Omit<ActionExecutionOptions, 'inputs'>) => Promise<ActionExecutionResult>\n`;
171
+ }
172
+ else {
173
+ // No specific input fields available - use generic Record<string, any> for inputs
174
+ output += `${description} ${actionName}: (options?: { inputs?: Record<string, any> } & ActionExecutionOptions) => Promise<ActionExecutionResult>\n`;
175
+ }
176
+ });
177
+ output += `}\n\n`;
178
+ });
179
+ // Generate the main app actions interface
180
+ output += `export interface ${appName}Actions {\n`;
181
+ output += ` run: {\n`;
182
+ output += ` ${appKey}: {\n`;
183
+ Object.keys(actionsByType).forEach((actionType) => {
184
+ const typeName = `${appName}${capitalize(actionType)}Actions`;
185
+ output += ` ${actionType}: ${typeName}\n`;
186
+ });
187
+ output += ` }\n`;
188
+ output += ` }\n`;
189
+ output += `}\n`;
190
+ return output;
191
+ }
192
+ function generateEmptyTypesFile(appKey, version) {
193
+ const appName = capitalize(appKey);
194
+ const versionComment = version
195
+ ? ` * Generated for ${appKey}@${version}`
196
+ : ` * Generated for ${appKey}`;
197
+ return `/* eslint-disable @typescript-eslint/naming-convention */
198
+ /**
199
+ * Auto-generated TypeScript types for Zapier ${appKey} actions
200
+ ${versionComment}
201
+ * Generated on: ${new Date().toISOString()}
202
+ *
203
+ * No actions found for this app.
204
+ */
205
+
206
+ import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapier-sdk'
207
+
208
+ export interface ${appName}Actions {
209
+ run: {
210
+ ${appKey}: {
211
+ // No actions available
212
+ }
213
+ }
214
+ }
215
+ `;
216
+ }
217
+ function capitalize(str) {
218
+ return str.charAt(0).toUpperCase() + str.slice(1).replace(/[-_]/g, "");
219
+ }
220
+ function sanitizeActionName(actionKey) {
221
+ // Ensure the action name is a valid TypeScript identifier
222
+ return actionKey.replace(/[^a-zA-Z0-9_$]/g, "_");
223
+ }
224
+ function sanitizeFieldName(fieldKey) {
225
+ // Ensure the field name is a valid TypeScript identifier
226
+ return fieldKey.replace(/[^a-zA-Z0-9_$]/g, "_");
227
+ }
228
+ function escapeComment(comment) {
229
+ // Escape comment text to prevent breaking the JSDoc comment
230
+ return comment.replace(/\*\//g, "*\\/").replace(/\r?\n/g, " ");
231
+ }
232
+ function mapFieldTypeToTypeScript(field) {
233
+ // Handle choices (enum-like fields)
234
+ if (field.choices && field.choices.length > 0) {
235
+ const choiceValues = field.choices
236
+ .filter((choice) => choice.value !== undefined &&
237
+ choice.value !== null &&
238
+ choice.value !== "")
239
+ .map((choice) => typeof choice.value === "string" ? `"${choice.value}"` : choice.value);
240
+ if (choiceValues.length > 0) {
241
+ return choiceValues.join(" | ");
242
+ }
243
+ // If all choices were filtered out, fall through to default type handling
244
+ }
245
+ // Map Zapier field types to TypeScript types
246
+ switch (field.type?.toLowerCase()) {
247
+ case "string":
248
+ case "text":
249
+ case "email":
250
+ case "url":
251
+ case "password":
252
+ return "string";
253
+ case "integer":
254
+ case "number":
255
+ return "number";
256
+ case "boolean":
257
+ return "boolean";
258
+ case "datetime":
259
+ case "date":
260
+ return "string"; // ISO date strings
261
+ case "file":
262
+ return "string"; // File URL or content
263
+ case "array":
264
+ return "any[]";
265
+ case "object":
266
+ return "Record<string, any>";
267
+ default:
268
+ // Default to string for unknown types, with union for common cases
269
+ return "string | number | boolean";
270
+ }
271
+ }
@@ -0,0 +1,16 @@
1
+ import type { Action, FunctionConfig } from "../types";
2
+ export interface GetActionOptions extends FunctionConfig {
3
+ app: string;
4
+ action: string;
5
+ type: string;
6
+ }
7
+ /**
8
+ * Get a specific action by app, action key, and type
9
+ *
10
+ * This function can be used standalone without instantiating a full SDK,
11
+ * which enables better tree-shaking in applications that only need this functionality.
12
+ *
13
+ * @param options - App key, action key, type, and API configuration options
14
+ * @returns Promise<Action>
15
+ */
16
+ export declare function getAction(options: GetActionOptions): Promise<Action>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAction = getAction;
4
+ const listActions_1 = require("./listActions");
5
+ /**
6
+ * Get a specific action by app, action key, and type
7
+ *
8
+ * This function can be used standalone without instantiating a full SDK,
9
+ * which enables better tree-shaking in applications that only need this functionality.
10
+ *
11
+ * @param options - App key, action key, type, and API configuration options
12
+ * @returns Promise<Action>
13
+ */
14
+ async function getAction(options) {
15
+ const { app, action: actionKey, type } = options;
16
+ const actions = await (0, listActions_1.listActions)({
17
+ ...options,
18
+ appKey: app,
19
+ });
20
+ const action = actions.find((a) => a.key === actionKey && a.type === type);
21
+ if (!action) {
22
+ throw new Error(`Action not found: ${actionKey} with type ${type}`);
23
+ }
24
+ return action;
25
+ }
@@ -0,0 +1,14 @@
1
+ import type { Integration, FunctionConfig } from "../types";
2
+ export interface GetAppOptions extends FunctionConfig {
3
+ key: string;
4
+ }
5
+ /**
6
+ * Get a specific app by key
7
+ *
8
+ * This function can be used standalone without instantiating a full SDK,
9
+ * which enables better tree-shaking in applications that only need this functionality.
10
+ *
11
+ * @param options - App key and API configuration options
12
+ * @returns Promise<Integration>
13
+ */
14
+ export declare function getApp(options: GetAppOptions): Promise<Integration>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApp = getApp;
4
+ const api_1 = require("../api");
5
+ /**
6
+ * Get a specific app by key
7
+ *
8
+ * This function can be used standalone without instantiating a full SDK,
9
+ * which enables better tree-shaking in applications that only need this functionality.
10
+ *
11
+ * @param options - App key and API configuration options
12
+ * @returns Promise<Integration>
13
+ */
14
+ async function getApp(options) {
15
+ const api = (0, api_1.getOrCreateApiClient)(options);
16
+ const { key } = options;
17
+ const app = await api.get(`/api/v4/apps/${key}/`, {
18
+ customErrorHandler: (response) => {
19
+ if (response.status === 404) {
20
+ const AppNotFoundError = class extends Error {
21
+ constructor(appKey) {
22
+ super(`App not found: ${appKey}`);
23
+ this.name = "AppNotFoundError";
24
+ }
25
+ };
26
+ return new AppNotFoundError(key);
27
+ }
28
+ return undefined;
29
+ },
30
+ });
31
+ return {
32
+ key: app.slug,
33
+ name: app.name,
34
+ description: app.description,
35
+ version: "1.0.0",
36
+ category: app.category?.name,
37
+ actions: [],
38
+ triggers: [],
39
+ current_implementation_id: app.current_implementation_id,
40
+ };
41
+ }
@@ -0,0 +1,15 @@
1
+ import type { Action, FunctionConfig } from "../types";
2
+ export interface ListActionsOptions extends FunctionConfig {
3
+ appKey?: string;
4
+ type?: string;
5
+ }
6
+ /**
7
+ * List available actions with optional filtering
8
+ *
9
+ * This function can be used standalone without instantiating a full SDK,
10
+ * which enables better tree-shaking in applications that only need this functionality.
11
+ *
12
+ * @param options - Filtering and API configuration options
13
+ * @returns Promise<Action[]> with pagination metadata
14
+ */
15
+ export declare function listActions(options?: ListActionsOptions): Promise<Action[]>;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listActions = listActions;
4
+ const api_1 = require("../api");
5
+ const getApp_1 = require("./getApp");
6
+ /**
7
+ * List available actions with optional filtering
8
+ *
9
+ * This function can be used standalone without instantiating a full SDK,
10
+ * which enables better tree-shaking in applications that only need this functionality.
11
+ *
12
+ * @param options - Filtering and API configuration options
13
+ * @returns Promise<Action[]> with pagination metadata
14
+ */
15
+ async function listActions(options = {}) {
16
+ const api = (0, api_1.getOrCreateApiClient)(options);
17
+ // If filtering by appKey, use optimized approach with selected_apis parameter
18
+ if (options.appKey) {
19
+ try {
20
+ // Use the standalone getApp function
21
+ const appData = await (0, getApp_1.getApp)({
22
+ key: options.appKey,
23
+ api,
24
+ token: options.token,
25
+ baseUrl: options.baseUrl,
26
+ debug: options.debug,
27
+ fetch: options.fetch,
28
+ });
29
+ // Extract implementation name from current_implementation_id (e.g., "SlackCLIAPI@1.20.0" -> "SlackCLIAPI")
30
+ const implementationId = appData.current_implementation_id?.split("@")[0];
31
+ if (!implementationId) {
32
+ throw new Error("No current_implementation_id found for app");
33
+ }
34
+ const searchParams = {
35
+ global: "true",
36
+ public_only: "true",
37
+ selected_apis: implementationId,
38
+ };
39
+ const data = await api.get("/api/v4/implementations/", {
40
+ searchParams,
41
+ });
42
+ const actions = [];
43
+ // Transform implementations to actions
44
+ for (const implementation of data.results || []) {
45
+ if (implementation.actions) {
46
+ for (const action of implementation.actions) {
47
+ const transformedAction = {
48
+ key: action.key,
49
+ name: action.name || action.label,
50
+ description: action.description || "",
51
+ appKey: implementation.slug || "",
52
+ type: action.type || action.type_of || "read",
53
+ inputFields: [], // Would need additional API call for detailed fields
54
+ outputFields: [],
55
+ };
56
+ // Apply type filter if provided
57
+ if (options?.type && transformedAction.type !== options.type) {
58
+ continue;
59
+ }
60
+ actions.push(transformedAction);
61
+ }
62
+ }
63
+ }
64
+ // Add pagination metadata for app-specific queries
65
+ if (actions.length > 0) {
66
+ actions.__pagination = {
67
+ count: data.count,
68
+ hasNext: !!data.next,
69
+ hasPrevious: !!data.previous,
70
+ nextUrl: data.next,
71
+ previousUrl: data.previous,
72
+ };
73
+ }
74
+ return actions;
75
+ }
76
+ catch (error) {
77
+ // If it's an AppNotFoundError, don't try fallback - just re-throw
78
+ if (error instanceof Error && error.name === "AppNotFoundError") {
79
+ throw error;
80
+ }
81
+ // Fallback to original approach if optimized approach fails
82
+ console.warn("Optimized app lookup failed, falling back to full scan:", error);
83
+ }
84
+ }
85
+ // Original approach for general queries or when optimization fails
86
+ const searchParams = {
87
+ global: "true",
88
+ public_only: "true",
89
+ };
90
+ const data = await api.get("/api/v4/implementations/", { searchParams });
91
+ const actions = [];
92
+ // Transform implementations to actions
93
+ for (const implementation of data.results || []) {
94
+ if (implementation.actions) {
95
+ for (const action of implementation.actions) {
96
+ const transformedAction = {
97
+ key: action.key,
98
+ name: action.name || action.label,
99
+ description: action.description || "",
100
+ appKey: implementation.slug || "",
101
+ type: action.type || action.type_of || "read",
102
+ inputFields: [], // Would need additional API call for detailed fields
103
+ outputFields: [],
104
+ };
105
+ // Apply filters
106
+ if (options?.appKey && transformedAction.appKey !== options.appKey) {
107
+ continue;
108
+ }
109
+ if (options?.type && transformedAction.type !== options.type) {
110
+ continue;
111
+ }
112
+ actions.push(transformedAction);
113
+ }
114
+ }
115
+ }
116
+ // Add pagination metadata for general queries
117
+ if (actions.length > 0) {
118
+ actions.__pagination = {
119
+ count: data.count,
120
+ hasNext: !!data.next,
121
+ hasPrevious: !!data.previous,
122
+ nextUrl: data.next,
123
+ previousUrl: data.previous,
124
+ };
125
+ }
126
+ return actions;
127
+ }
@@ -0,0 +1,16 @@
1
+ import type { Integration, FunctionConfig } from "../types";
2
+ export interface ListAppsOptions extends FunctionConfig {
3
+ category?: string;
4
+ limit?: number;
5
+ offset?: number;
6
+ }
7
+ /**
8
+ * List available apps with optional filtering
9
+ *
10
+ * This function can be used standalone without instantiating a full SDK,
11
+ * which enables better tree-shaking in applications that only need this functionality.
12
+ *
13
+ * @param options - Filtering, pagination, and API configuration options
14
+ * @returns Promise<Integration[]> with pagination metadata
15
+ */
16
+ export declare function listApps(options?: ListAppsOptions): Promise<Integration[]>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listApps = listApps;
4
+ const api_1 = require("../api");
5
+ /**
6
+ * List available apps with optional filtering
7
+ *
8
+ * This function can be used standalone without instantiating a full SDK,
9
+ * which enables better tree-shaking in applications that only need this functionality.
10
+ *
11
+ * @param options - Filtering, pagination, and API configuration options
12
+ * @returns Promise<Integration[]> with pagination metadata
13
+ */
14
+ async function listApps(options = {}) {
15
+ const api = (0, api_1.getOrCreateApiClient)(options);
16
+ // Build search parameters
17
+ const searchParams = {};
18
+ if (options.category) {
19
+ searchParams.category = options.category;
20
+ }
21
+ if (options.limit) {
22
+ searchParams.limit = options.limit.toString();
23
+ }
24
+ if (options.offset) {
25
+ searchParams.offset = options.offset.toString();
26
+ }
27
+ const data = await api.get("/api/v4/apps/", { searchParams });
28
+ // Transform API response to our Integration interface
29
+ const apps = data.results?.map((app) => ({
30
+ key: app.slug,
31
+ name: app.name,
32
+ description: app.description,
33
+ version: "1.0.0", // API doesn't provide version
34
+ category: app.category?.name,
35
+ actions: [], // Will be populated separately
36
+ triggers: [],
37
+ current_implementation_id: app.current_implementation_id,
38
+ })) || [];
39
+ // Add pagination metadata to the response
40
+ if (apps.length > 0) {
41
+ apps.__pagination = {
42
+ count: data.count,
43
+ hasNext: !!data.next,
44
+ hasPrevious: !!data.previous,
45
+ nextUrl: data.next,
46
+ previousUrl: data.previous,
47
+ };
48
+ }
49
+ return apps;
50
+ }
@@ -0,0 +1,18 @@
1
+ import type { Authentication, FunctionConfig } from "../types";
2
+ export interface ListAuthsOptions extends FunctionConfig {
3
+ appKey?: string;
4
+ account_id?: string;
5
+ owner?: string;
6
+ limit?: number;
7
+ offset?: number;
8
+ }
9
+ /**
10
+ * List available authentications with optional filtering
11
+ *
12
+ * This function can be used standalone without instantiating a full SDK,
13
+ * which enables better tree-shaking in applications that only need this functionality.
14
+ *
15
+ * @param options - Filtering, pagination, and API configuration options
16
+ * @returns Promise<Authentication[]> with pagination metadata
17
+ */
18
+ export declare function listAuths(options?: ListAuthsOptions): Promise<Authentication[]>;